configure 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. :
  2. #!/bin/sh -x
  3. # The above : is necessary on some buggy systems.
  4. # configure: Guess values for system-dependent variables
  5. # Output the flag definitions to the file "flags".
  6. #
  7. # Parameters: $1 = $CC, $2 = $CFLAGS, $3 = $IZ_BZIP2
  8. #
  9. # This file is typically called from Makefile rather than executed
  10. # from the command line.
  11. #
  12. # To construct zip automatically using this file, type
  13. # "make -f unix/Makefile generic".
  14. # If this fails, then type "make list" to get a list of special targets.
  15. trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
  16. CC=${1-cc}
  17. CFLAGS=${2-"-I. -DUNIX"}
  18. LFLAGS1=''
  19. LFLAGS2=''
  20. LN="ln -s"
  21. CFLAGS_OPT=''
  22. # bzip2
  23. IZ_BZIP2=${3-}
  24. CFLAGS_BZ=''
  25. echo 'Check C compiler type (optimization options)'
  26. # Sun C?
  27. cat > conftest.c << _EOF_
  28. int main()
  29. {
  30. #ifndef __SUNPRO_C
  31. bad code
  32. #endif
  33. return 0;
  34. }
  35. _EOF_
  36. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  37. if test $? -eq 0; then
  38. CFLAGS_OPT='-xO3'
  39. echo " Sun C ($CFLAGS_OPT)"
  40. else
  41. # Tru64 DEC/Compaq/HP C?
  42. cat > conftest.c << _EOF_
  43. int main()
  44. {
  45. #ifndef __DECC
  46. bad code
  47. #endif
  48. return 0;
  49. }
  50. _EOF_
  51. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  52. if test $? -eq 0; then
  53. CFLAGS_OPT='-O3'
  54. echo " DEC C ($CFLAGS_OPT)"
  55. else
  56. # HP-UX HP C?
  57. cat > conftest.c << _EOF_
  58. int main()
  59. {
  60. #ifdef __GNUC__
  61. bad code
  62. #endif
  63. #ifndef __hpux
  64. bad code
  65. #endif
  66. return 0;
  67. }
  68. _EOF_
  69. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  70. if test $? -eq 0; then
  71. # HP-UX, not GCC. Lame bundled or real ANSI compiler?
  72. CFLAGS_OPT_TRY="+O3 +Onolimit"
  73. $CC $CFLAGS $CFLAGS_OPT_TRY -c conftest.c 2>&1 | \
  74. grep '(Bundled)' > /dev/null
  75. if test $? -ne 0; then
  76. CFLAGS_OPT="$CFLAGS_OPT_TRY"
  77. echo " HP-UX ANSI C ($CFLAGS_OPT)"
  78. else
  79. echo ' HP-UX Bundled C (no opt)'
  80. fi
  81. else
  82. # GNU C?
  83. cat > conftest.c << _EOF_
  84. int main()
  85. {
  86. #ifndef __GNUC__
  87. bad code
  88. #endif
  89. return 0;
  90. }
  91. _EOF_
  92. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  93. if test $? -eq 0; then
  94. CFLAGS_OPT='-O3'
  95. echo " GNU C ($CFLAGS_OPT)"
  96. # Special Mac OS X shared library "ld" option?
  97. if test ` uname -s 2> /dev/null ` = 'Darwin'; then
  98. lf='-Wl,-search_paths_first'
  99. $CC $CFLAGS $lf conftest.c > /dev/null 2>/dev/null
  100. if test $? -eq 0; then
  101. LFLAGS2="${LFLAGS2} ${lf}"
  102. fi
  103. rm -f conftest
  104. fi
  105. else
  106. CFLAGS_OPT='-O'
  107. echo " Other-unknown C ($CFLAGS_OPT)"
  108. fi
  109. fi
  110. fi
  111. fi
  112. # optimization flags
  113. if test -n "${CFLAGS_OPT}"; then
  114. CFLAGS="${CFLAGS} ${CFLAGS_OPT}"
  115. CFLAGS_BZ="${CFLAGS_BZ} ${CFLAGS_OPT}"
  116. fi
  117. # bzip2
  118. echo "Check bzip2 support"
  119. CC_BZ="${CC}"
  120. LIB_BZ=''
  121. if test -n "${IZ_BZIP2}"; then
  122. echo " Check for bzip2 compiled library in IZ_BZIP2 (${IZ_BZIP2})"
  123. if test -f "${IZ_BZIP2}/libbz2.a"; then
  124. #
  125. # A bzip2 library built with BZ_NO_STDIO should have an
  126. # unresolved external, "bz_internal_error". The default,
  127. # full-function library will not mention it.
  128. #
  129. nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
  130. if test $? -eq 0; then
  131. echo " Found bzip2 BZ_NO_STDIO library, ${IZ_BZIP2}/libbz2.a"
  132. else
  133. echo " Found bzip2 library, ${IZ_BZIP2}/libbz2.a,"
  134. echo " but library not compiled with BZ_NO_STDIO"
  135. echo " WARNING: We recommend using a bzip2 library compiled"
  136. echo " with BZ_NO_STDIO defined for proper error handling"
  137. echo " Please see the Zip installation instructions in bzip2/install.txt"
  138. echo " Continuing anyway with standard bzip2 library..."
  139. fi
  140. if test -f "${IZ_BZIP2}/bzlib.h"; then
  141. CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
  142. LFLAGS2="${LFLAGS2} -L${IZ_BZIP2} -lbz2"
  143. echo "-- Found bzip2 library - linking in bzip2"
  144. else
  145. echo " ${IZ_BZIP2}/bzlib.h not found"
  146. echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 dir checks - no bzip2"
  147. fi
  148. else
  149. echo " ${IZ_BZIP2}/libbz2.a not found"
  150. echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 checks - no bzip2"
  151. fi
  152. else
  153. echo " Check for bzip2 in bzip2 directory"
  154. IZ_BZIP2=bzip2
  155. if test -f "${IZ_BZIP2}/libbz2.a"; then
  156. nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
  157. if test $? -eq 0; then
  158. echo " Found bzip2 BZ_NO_STDIO library in bzip2 directory"
  159. else
  160. echo " Found bzip2 library in bzip2 directory,"
  161. echo " but not built with the BZ_NO_STDIO option"
  162. echo " WARNING: We recommend using a bzip2 library compiled"
  163. echo " with BZ_NO_STDIO defined for proper error handling"
  164. echo " Please see the Zip installation instructions"
  165. echo " Continuing anyway with standard bzip2 library..."
  166. fi
  167. fi
  168. if test -f "bzip2/bzlib.h" -a -f "bzip2/libbz2.a"; then
  169. CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
  170. LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
  171. echo "-- Found bzip2 library - linking in bzip2"
  172. else
  173. if test -f "bzip2/bzlib.c" -a -f "bzip2/bzlib.h"; then
  174. echo "-- No library, but found bzip2 source in bzip2 directory"
  175. echo "-- Will try to build bzip2 library from source and link in"
  176. #
  177. # Arrange to build a BZ_NO_STDIO bzip2 object library using the
  178. # same compiler and optimization options as used for Zip, and
  179. # to compile and link Zip with bzip2.
  180. #
  181. CFLAGS_BZ="${CFLAGS_BZ} -DBZ_NO_STDIO"
  182. LIB_BZ="bzip2/libbz2.a"
  183. CFLAGS="${CFLAGS} -Ibzip2 -DBZIP2_SUPPORT"
  184. LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
  185. else
  186. echo " Check if OS already has bzip2 library installed"
  187. cat > conftest.c << _EOF_
  188. #include "bzlib.h"
  189. int main()
  190. {
  191. bz_stream strm;
  192. BZ2_bzCompressEnd(&strm);
  193. return 0;
  194. }
  195. _EOF_
  196. $CC $CFLAGS -o conftest conftest.c -lbz2 > /dev/null 2>/dev/null
  197. if test $? -eq 0; then
  198. echo "-- OS supports bzip2 - linking in bzip2"
  199. CFLAGS="${CFLAGS} -DBZIP2_SUPPORT"
  200. LFLAGS2="${LFLAGS2} -lbz2"
  201. else
  202. echo "-- Either bzlib.h or libbz2.a not found - no bzip2"
  203. fi
  204. fi
  205. fi
  206. fi
  207. echo Check for the C preprocessor
  208. # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
  209. CPP="${CC} -E"
  210. # solaris as(1) needs -P, maybe others as well ?
  211. [ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
  212. [ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
  213. [ -f /lib/cpp ] && CPP=/lib/cpp
  214. [ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
  215. [ -f /xenix ] && CPP="${CC} -E"
  216. [ -f /lynx.os ] && CPP="${CC} -E"
  217. echo "#include <stdio.h>" > conftest.c
  218. $CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"
  219. echo Check if we can use asm code
  220. OBJA=""
  221. OCRCU8=""
  222. if eval "$CPP match.S > _match.s 2>/dev/null"; then
  223. if test ! -s _match.s || grep error < _match.s > /dev/null; then
  224. :
  225. elif eval "$CC -c _match.s >/dev/null 2>/dev/null" && [ -f _match.o ]; then
  226. CFLAGS="${CFLAGS} -DASMV"
  227. OBJA="match.o"
  228. echo "int foo() { return 0;}" > conftest.c
  229. $CC -c conftest.c >/dev/null 2>/dev/null
  230. echo Check if compiler generates underlines
  231. nm conftest.o | grep "(^|[^_])foo" >/dev/null 2>/dev/null
  232. [ $? -eq 0 ] && CPP="${CPP} -DNO_UNDERLINE"
  233. if eval "$CPP crc_i386.S > _crc_i386.s 2>/dev/null"; then
  234. if eval "$CC -c _crc_i386.s >/dev/null 2>/dev/null" && [ -f _crc_i386.o ]
  235. then
  236. OBJA="$OBJA crc_i386.o"
  237. OCRCU8="crc_i386.o"
  238. CFLAGS="${CFLAGS} -DASM_CRC"
  239. fi
  240. fi
  241. fi
  242. fi
  243. rm -f _match.s _match.o _crc_i386.s _crc_i386.o
  244. # ANSI options for compilers that don't have __STDC__ defined by default
  245. # Currently HPUX, pyramid, Dynix, AIX, OSF/1 and ultrix
  246. echo Check for ANSI options
  247. cat > conftest.c << _EOF_
  248. int main()
  249. {
  250. #ifndef __STDC__
  251. forget it
  252. #endif
  253. return 0;
  254. }
  255. _EOF_
  256. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  257. if [ $? -ne 0 ]; then
  258. for OPT in -Ae -Xa -qlanglvl=ansi -std1 -std
  259. do
  260. $CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
  261. [ $? -eq 0 ] && CFLAGS="${CFLAGS} ${OPT}" && break
  262. done
  263. fi
  264. echo Check for prototypes
  265. echo "int main(int argc, char *argv[]) { return 0; }" > conftest.c
  266. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  267. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_PROTO"
  268. # const check currently handles mips cc and non ANSI compilers.
  269. # does it need more ?
  270. echo Check the handling of const
  271. cat > conftest.c << _EOF_
  272. typedef int charset[2];
  273. int main()
  274. {
  275. const charset x;
  276. const char *foo;
  277. return 0;
  278. }
  279. _EOF_
  280. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  281. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_CONST"
  282. echo Check for time_t
  283. cat > conftest.c << _EOF_
  284. #include <sys/types.h>
  285. #include <time.h>
  286. int main()
  287. {
  288. time_t t;
  289. return 0;
  290. }
  291. _EOF_
  292. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  293. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_TIME_T"
  294. echo Check for size_t
  295. cat > conftest.c << _EOF_
  296. #include <sys/types.h>
  297. int main()
  298. {
  299. size_t s;
  300. return 0;
  301. }
  302. _EOF_
  303. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  304. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_SIZE_T"
  305. echo Check for off_t
  306. cat > conftest.c << _EOF_
  307. #include <sys/types.h>
  308. int main()
  309. {
  310. off_t s;
  311. return 0;
  312. }
  313. _EOF_
  314. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  315. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_OFF_T"
  316. echo Check size of UIDs and GIDs
  317. echo "(Now zip stores variable size UIDs/GIDs using a new extra field. This"
  318. echo " tests if this OS uses 16-bit UIDs/GIDs and so if the old 16-bit storage"
  319. echo " should also be used for backward compatibility.)"
  320. # Added 2008-04-15 CS
  321. cat > conftest.c << _EOF_
  322. # define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
  323. # define _LARGEFILE64_SOURCE
  324. # define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
  325. # define _LARGE_FILES /* some OSes need this for 64-bit off_t */
  326. #include <sys/types.h>
  327. #include <sys/stat.h>
  328. #include <unistd.h>
  329. #include <stdio.h>
  330. int main()
  331. {
  332. struct stat s;
  333. printf(" s.st_uid is %u bytes\n", sizeof(s.st_uid));
  334. printf(" s.st_gid is %u bytes\n", sizeof(s.st_gid));
  335. /* see if have 16-bit UID */
  336. if (sizeof(s.st_uid) != 2) {
  337. return 1;
  338. }
  339. /* see if have 16-bit GID */
  340. if (sizeof(s.st_gid) != 2) {
  341. return 2;
  342. }
  343. return 3;
  344. }
  345. _EOF_
  346. # compile it
  347. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  348. if [ $? -ne 0 ]; then
  349. echo -- UID/GID test failed on compile - disabling old 16-bit UID/GID support
  350. CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  351. else
  352. # run it
  353. ./conftest
  354. r=$?
  355. if [ $r -eq 1 ]; then
  356. echo -- UID not 2 bytes - disabling old 16-bit UID/GID support
  357. CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  358. elif [ $r -eq 2 ]; then
  359. echo -- GID not 2 bytes - disabling old 16-bit UID/GID support
  360. CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  361. elif [ $r -eq 3 ]; then
  362. echo -- 16-bit UIDs and GIDs - keeping old 16-bit UID/GID support
  363. else
  364. echo -- test failed - conftest returned $r - disabling old 16-bit UID/GID support
  365. CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  366. fi
  367. fi
  368. # Now we set the 64-bit file environment and check the size of off_t
  369. # Added 11/4/2003 EG
  370. # Revised 8/12/2004 EG
  371. echo Check for Large File Support
  372. cat > conftest.c << _EOF_
  373. # define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
  374. # define _LARGEFILE64_SOURCE
  375. # define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
  376. # define _LARGE_FILES /* some OSes need this for 64-bit off_t */
  377. #include <sys/types.h>
  378. #include <sys/stat.h>
  379. #include <unistd.h>
  380. #include <stdio.h>
  381. int main()
  382. {
  383. off_t offset;
  384. struct stat s;
  385. /* see if have 64-bit off_t */
  386. if (sizeof(offset) < 8)
  387. return 1;
  388. printf(" off_t is %d bytes\n", sizeof(off_t));
  389. /* see if have 64-bit stat */
  390. if (sizeof(s.st_size) < 8) {
  391. printf(" s.st_size is %d bytes\n", sizeof(s.st_size));
  392. return 2;
  393. }
  394. return 3;
  395. }
  396. _EOF_
  397. # compile it
  398. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  399. if [ $? -ne 0 ]; then
  400. echo -- no Large File Support
  401. else
  402. # run it
  403. ./conftest
  404. r=$?
  405. if [ $r -eq 1 ]; then
  406. echo -- no Large File Support - no 64-bit off_t
  407. elif [ $r -eq 2 ]; then
  408. echo -- no Large File Support - no 64-bit stat
  409. elif [ $r -eq 3 ]; then
  410. echo -- yes we have Large File Support!
  411. CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
  412. else
  413. echo -- no Large File Support - conftest returned $r
  414. fi
  415. fi
  416. # Check for wide char for Unicode support
  417. # Added 11/24/2005 EG
  418. echo Check for wide char support
  419. cat > conftest.c << _EOF_
  420. #include <stdlib.h>
  421. #include <stdio.h>
  422. int main()
  423. {
  424. int wsize;
  425. wchar_t *wide_string;
  426. if ((wide_string = (wchar_t *)malloc(4 * sizeof(wchar_t))) == NULL) {
  427. return 0;
  428. }
  429. /* get wide string */
  430. wsize = mbstowcs(wide_string, "foo", 3);
  431. wide_string[wsize] = (wchar_t) NULL;
  432. return 1;
  433. }
  434. _EOF_
  435. # compile it
  436. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  437. # OCRCU8 is used by all utilities if Unicode is enabled
  438. # OCRCTB is only used by zipcloak
  439. if [ $? -ne 0 ]; then
  440. echo -- no Unicode support
  441. OCRCU8=""
  442. OCRCTB="crc32_.o"
  443. else
  444. # have wide char support
  445. echo -- have wchar_t - enabling Unicode support
  446. CFLAGS="${CFLAGS} -DUNICODE_SUPPORT"
  447. OCRCU8="crc32_.o ${OCRCU8}"
  448. OCRCTB=""
  449. fi
  450. # from configure 2.4i (Onno) 12/5/04
  451. echo Check for gcc no-builtin flag
  452. # -fno-builtin since version 2
  453. cat > conftest.c << _EOF_
  454. int main()
  455. {
  456. #if __GNUC__ >= 2
  457. return 0;
  458. #else
  459. forget it
  460. #endif
  461. }
  462. _EOF_
  463. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  464. [ $? -eq 0 ] && BFLAG="-fno-builtin"
  465. # Check for missing functions
  466. # add NO_'function_name' to flags if missing
  467. for func in rmdir strchr strrchr rename mktemp mktime mkstemp
  468. do
  469. echo Check for $func
  470. echo "int main(){ $func(); return 0; }" > conftest.c
  471. $CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
  472. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
  473. done
  474. echo Check for memset
  475. echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
  476. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  477. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
  478. echo Check for memmove
  479. cat > conftest.c << _EOF_
  480. #include <string.h>
  481. int main() { int a; int b = 0; memmove( &a, &b, sizeof( a)); return a; }
  482. _EOF_
  483. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  484. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_MEMMOVE"
  485. echo Check for strerror
  486. cat > conftest.c << _EOF_
  487. #include <string.h>
  488. int main() { strerror( 0); return 0; }
  489. _EOF_
  490. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  491. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_STRERROR"
  492. echo Check for errno declaration
  493. cat > conftest.c << _EOF_
  494. #include <errno.h>
  495. main()
  496. {
  497. errno = 0;
  498. return 0;
  499. }
  500. _EOF_
  501. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  502. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO"
  503. echo Check for directory libraries
  504. cat > conftest.c << _EOF_
  505. int main() { return closedir(opendir(".")); }
  506. _EOF_
  507. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  508. if [ $? -ne 0 ]; then
  509. OPT=""
  510. for lib in ndir dir ucb bsd BSD PW x dirent
  511. do
  512. $CC -o conftest conftest.c -l$lib >/dev/null 2>/dev/null
  513. [ $? -eq 0 ] && OPT=-l$lib && break
  514. done
  515. if [ ${OPT} ]; then
  516. LFLAGS2="${LFLAGS2} ${OPT}"
  517. else
  518. CFLAGS="${CFLAGS} -DNO_DIR"
  519. fi
  520. fi
  521. # Dynix/ptx 1.3 needed this
  522. echo Check for readlink
  523. echo "int main(){ return readlink(); }" > conftest.c
  524. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  525. if [ $? -ne 0 ]; then
  526. $CC -o conftest conftest.c -lseq >/dev/null 2>/dev/null
  527. [ $? -eq 0 ] && LFLAGS2="${LFLAGS2} -lseq"
  528. fi
  529. echo Check for directory include file
  530. OPT=""
  531. for inc in dirent.h sys/ndir.h ndir.h sys/dir.h
  532. do
  533. echo "#include <$inc>" > conftest.c
  534. $CPP conftest.c > /dev/null 2>/dev/null
  535. [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
  536. done
  537. CFLAGS="${CFLAGS} ${OPT}"
  538. echo Check for nonexistent include files
  539. for inc in stdlib.h stddef.h unistd.h fcntl.h string.h
  540. do
  541. echo "#include <$inc>" > conftest.c
  542. $CPP conftest.c >/dev/null 2>/dev/null
  543. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
  544. done
  545. echo Check for term I/O include file
  546. OPT=""
  547. for inc in termios.h termio.h sgtty.h
  548. do
  549. echo "#include <$inc>" > conftest.c
  550. $CPP conftest.c > /dev/null 2>/dev/null
  551. [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
  552. done
  553. CFLAGS="${CFLAGS} ${OPT}"
  554. # needed for AIX (and others ?) when mmap is used
  555. echo Check for valloc
  556. cat > conftest.c << _EOF_
  557. main()
  558. {
  559. #ifdef MMAP
  560. valloc();
  561. #endif
  562. }
  563. _EOF_
  564. $CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
  565. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC"
  566. echo Check for /usr/local/bin and /usr/local/man
  567. BINDIR=$HOME/bin
  568. [ -d /usr/local/bin ] && BINDIR=/usr/local/bin
  569. MANDIR=manl
  570. [ -d /usr/man/manl ] && MANDIR=/usr/man/manl
  571. [ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
  572. [ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1
  573. echo Check for OS-specific flags
  574. if [ -f /usr/bin/hostinfo ]; then
  575. if /usr/bin/hostinfo | grep NeXT > /dev/null; then
  576. CFLAGS="${CFLAGS} -posix"
  577. LFLAGS1="${LFLAGS1} -posix -object"
  578. fi
  579. # XXX ATT6300, Cray
  580. elif [ -f /xenix ]; then
  581. if uname -p | grep 286 > /dev/null; then
  582. CFLAGS="${CFLAGS} -LARGE -Mel2 -DMEDIUM_MEM -DWSIZE=16384 -DNO_VOID"
  583. LFLAGS1="${LFLAGS1} -LARGE -Mel2"
  584. fi
  585. elif uname -X >/dev/null 2>/dev/null; then
  586. # SCO shared library check
  587. echo "int main() { return 0;}" > conftest.c
  588. $CC -o conftest conftest.c -lc_s -nointl >/dev/null 2> /dev/null
  589. [ $? -eq 0 ] && LFLAGS2="-lc_s -nointl"
  590. else
  591. SYSTEM=`uname -s 2>/dev/null` || SYSTEM="unknown"
  592. echo "int main() { return 0;}" > conftest.c
  593. case $SYSTEM in
  594. OSF1|ULTRIX)
  595. echo Check for -Olimit option
  596. $CC ${CFLAGS} -Olimit 1000 -o conftest conftest.c >/dev/null 2>/dev/null
  597. [ $? -eq 0 ] && CFLAGS="${CFLAGS} -Olimit 1000"
  598. ;;
  599. ### HP-UX)
  600. ### echo Check for +Onolimit option
  601. ### $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
  602. ### [ $? -eq 0 ] && CFLAGS="${CFLAGS} +Onolimit"
  603. ### ;;
  604. ### SunOS)
  605. ### CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
  606. ### ;;
  607. esac
  608. fi
  609. echo Check for symbolic links
  610. ln -s /dev/null null > /dev/null 2>/dev/null || LN=ln
  611. rm -f a.out conftest.c conftest.o conftest null
  612. echo CC=\"${CC}\" CFLAGS=\"${CFLAGS}\" CPP=\"${CPP}\" OBJA=\"${OBJA}\" \
  613. OCRCU8=\"${OCRCU8}\" OCRCTB=\"${OCRCTB}\" \
  614. BINDIR=${BINDIR} MANDIR=${MANDIR} LFLAGS1=\"${LFLAGS1}\" \
  615. LFLAGS2=\"${LFLAGS2}\" LN=\"${LN}\" \
  616. CC_BZ=\"${CC_BZ}\" CFLAGS_BZ=\"${CFLAGS_BZ}\" \
  617. IZ_BZIP2=\"${IZ_BZIP2}\" LIB_BZ=\"${LIB_BZ}\" > flags