PageRenderTime 60ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/configure

http://github.com/multani/ocaml-mirror
Shell | 1689 lines | 1442 code | 172 blank | 75 comment | 195 complexity | 0db27a263abe8c718d0797e10d791e57 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. #! /bin/sh
  2. #########################################################################
  3. # #
  4. # OCaml #
  5. # #
  6. # Xavier Leroy, projet Cristal, INRIA Rocquencourt #
  7. # #
  8. # Copyright 1999 Institut National de Recherche en Informatique et #
  9. # en Automatique. All rights reserved. This file is distributed #
  10. # under the terms of the GNU Library General Public License, with #
  11. # the special exception on linking described in file LICENSE. #
  12. # #
  13. #########################################################################
  14. # $Id$
  15. configure_options="$*"
  16. prefix=/usr/local
  17. bindir=''
  18. libdir=''
  19. mandir=''
  20. manext=1
  21. host_type=unknown
  22. ccoption=''
  23. asoption=''
  24. asppoption=''
  25. cclibs=''
  26. curseslibs=''
  27. mathlib='-lm'
  28. dllib=''
  29. x11_include_dir=''
  30. x11_lib_dir=''
  31. tk_wanted=yes
  32. pthread_wanted=yes
  33. tk_defs=''
  34. tk_libs=''
  35. tk_x11=yes
  36. dl_defs=''
  37. verbose=no
  38. withcurses=yes
  39. debugruntime=noruntimed
  40. withsharedlibs=yes
  41. gcc_warnings="-Wall"
  42. partialld="ld -r"
  43. withcamlp4=camlp4
  44. # Try to turn internationalization off, can cause config.guess to malfunction!
  45. unset LANG
  46. unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
  47. # Turn off some MacOS X debugging stuff, same reason
  48. unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED
  49. # Parse command-line arguments
  50. while : ; do
  51. case "$1" in
  52. "") break;;
  53. -prefix|--prefix)
  54. prefix=$2; shift;;
  55. -bindir|--bindir)
  56. bindir=$2; shift;;
  57. -libdir|--libdir)
  58. libdir=$2; shift;;
  59. -mandir|--mandir)
  60. case "$2" in
  61. */man[1-9ln])
  62. mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
  63. manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
  64. *)
  65. mandir=$2
  66. manext=1;;
  67. esac
  68. shift;;
  69. -host*|--host*)
  70. host_type=$2; shift;;
  71. -cc*)
  72. ccoption="$2"; shift;;
  73. -as)
  74. asoption="$2"; shift;;
  75. -aspp)
  76. asppoption="$2"; shift;;
  77. -lib*)
  78. cclibs="$2 $cclibs"; shift;;
  79. -no-curses)
  80. withcurses=no;;
  81. -no-shared-libs)
  82. withsharedlibs=no;;
  83. -x11include*|--x11include*)
  84. x11_include_dir=$2; shift;;
  85. -x11lib*|--x11lib*)
  86. x11_lib_dir=$2; shift;;
  87. -with-pthread*|--with-pthread*)
  88. ;; # Ignored for backward compatibility
  89. -no-pthread*|--no-pthread*)
  90. pthread_wanted=no;;
  91. -no-tk|--no-tk)
  92. tk_wanted=no;;
  93. -partialld|--partialld)
  94. partialld="$2"; shift;;
  95. -tkdefs*|--tkdefs*)
  96. tk_defs=$2; shift;;
  97. -tklibs*|--tklibs*)
  98. tk_libs=$2; shift;;
  99. -tk-no-x11|--tk-no-x11)
  100. tk_x11=no;;
  101. -dldefs*|--dldefs*)
  102. dl_defs="$2"; shift;;
  103. -dllibs*|--dllibs*)
  104. dllib="$2"; shift;;
  105. -verbose|--verbose)
  106. verbose=yes;;
  107. -with-debug-runtime|--with-debug-runtime)
  108. debugruntime=runtimed;;
  109. -no-camlp4|--no-camlp4)
  110. withcamlp4="";;
  111. *) echo "Unknown option \"$1\"." 1>&2; exit 2;;
  112. esac
  113. shift
  114. done
  115. # Sanity checks
  116. case "$prefix" in
  117. /*) ;;
  118. *) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
  119. esac
  120. case "$bindir" in
  121. /*) ;;
  122. "") ;;
  123. '$(PREFIX)/'*) ;;
  124. *) echo 'The -bindir directory must be absolute or relative to $(PREFIX).'>&2
  125. exit 2;;
  126. esac
  127. case "$libdir" in
  128. /*) ;;
  129. "") ;;
  130. '$(PREFIX)/'*) ;;
  131. *) echo 'The -libdir directory must be absolute or relative to $(PREFIX).'>&2
  132. exit 2;;
  133. esac
  134. case "$mandir" in
  135. /*) ;;
  136. "") ;;
  137. '$(PREFIX)/'*) ;;
  138. *) echo 'The -mandir directory must be absolute or relative to $(PREFIX).'>&2
  139. exit 2;;
  140. esac
  141. # Generate the files
  142. cd config/auto-aux
  143. rm -f s.h m.h Makefile
  144. touch s.h m.h Makefile
  145. # Write options to Makefile
  146. echo "# generated by ./configure $configure_options" >> Makefile
  147. # Where to install
  148. echo "PREFIX=$prefix" >> Makefile
  149. case "$bindir" in
  150. "") echo 'BINDIR=$(PREFIX)/bin' >> Makefile
  151. bindir="$prefix/bin";;
  152. *) echo "BINDIR=$bindir" >> Makefile;;
  153. esac
  154. case "$libdir" in
  155. "") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile
  156. libdir="$prefix/lib/ocaml";;
  157. *) echo "LIBDIR=$libdir" >> Makefile;;
  158. esac
  159. echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile
  160. case "$mandir" in
  161. "") echo 'MANDIR=$(PREFIX)/man' >> Makefile
  162. mandir="$prefix/man";;
  163. *) echo "MANDIR=$mandir" >> Makefile;;
  164. esac
  165. echo "MANEXT=$manext" >> Makefile
  166. # Determine the system type
  167. if test "$host_type" = "unknown"; then
  168. if host_type=`../gnu/config.guess`; then :; else
  169. echo "Cannot guess host type"
  170. echo "You must specify one with the -host option"
  171. exit 2
  172. fi
  173. fi
  174. if host=`../gnu/config.sub $host_type`; then :; else
  175. echo "Please specify the correct host type with the -host option"
  176. exit 2
  177. fi
  178. echo "Configuring for a $host ..."
  179. # Do we have gcc?
  180. if test -z "$ccoption"; then
  181. if sh ./searchpath gcc; then
  182. echo "gcc found"
  183. cc=gcc
  184. else
  185. cc=cc
  186. fi
  187. else
  188. cc="$ccoption"
  189. fi
  190. # Check for buggy versions of GCC
  191. buggycc="no"
  192. case "$host,$cc" in
  193. i[3456]86-*-*,gcc*)
  194. case `$cc --version` in
  195. 2.7.2.1) cat <<'EOF'
  196. WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor.
  197. This version of gcc is known to generate incorrect code for the
  198. OCaml runtime system on some Intel x86 machines. (The symptom
  199. is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.)
  200. In particular, the version of gcc 2.7.2.1 that comes with
  201. Linux RedHat 4.x / Intel is affected by this problem.
  202. Other Linux distributions might also be affected.
  203. If you are using one of these configurations, you are strongly advised
  204. to use another version of gcc, such as 2.95, which are
  205. known to work well with OCaml.
  206. Press <enter> to proceed or <interrupt> to stop.
  207. EOF
  208. read reply;;
  209. 2.96*) cat <<'EOF'
  210. WARNING: you are using gcc version 2.96 on an Intel x86 processor.
  211. Certain patched versions of gcc 2.96 are known to generate incorrect
  212. code for the OCaml runtime system. (The symptom is a segmentation
  213. violation on boot/ocamlc.) Those incorrectly patched versions can be found
  214. in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions
  215. might also be affected. (See bug #57760 on bugzilla.redhat.com)
  216. Auto-configuration will now select gcc compiler flags that work around
  217. the problem. Still, if you observe segmentation faults while running
  218. ocamlc or ocamlopt, you are advised to try another version of gcc,
  219. such as 2.95.3 or 3.2.
  220. EOF
  221. buggycc="gcc.2.96";;
  222. esac;;
  223. esac
  224. # Configure the bytecode compiler
  225. bytecc="$cc"
  226. mkexe="\$(BYTECC)"
  227. bytecccompopts=""
  228. bytecclinkopts=""
  229. dllccompopts=""
  230. ostype="Unix"
  231. exe=""
  232. iflexdir=""
  233. case "$bytecc,$host" in
  234. cc,*-*-nextstep*)
  235. # GNU C extensions disabled, but __GNUC__ still defined!
  236. bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
  237. bytecclinkopts="-posix";;
  238. *,*-*-rhapsody*)
  239. # Almost the same as NeXTStep
  240. bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
  241. mathlib="";;
  242. *,*-*-darwin*)
  243. bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings"
  244. mathlib=""
  245. # Tell gcc that we can use 32-bit code addresses for threaded code
  246. # unless we are compiled for a shared library (-fPIC option)
  247. echo "#ifndef __PIC__" >> m.h
  248. echo "# define ARCH_CODE32" >> m.h
  249. echo "#endif" >> m.h;;
  250. *,*-*-beos*)
  251. bytecccompopts="-fno-defer-pop $gcc_warnings"
  252. # No -lm library
  253. mathlib="";;
  254. gcc,alpha*-*-osf*)
  255. bytecccompopts="-fno-defer-pop $gcc_warnings"
  256. if cc="$bytecc" sh ./hasgot -mieee; then
  257. bytecccompopts="-mieee $bytecccompopts";
  258. fi
  259. # Put code and static data in lower 4GB
  260. bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000"
  261. # Tell gcc that we can use 32-bit code addresses for threaded code
  262. echo "#define ARCH_CODE32" >> m.h;;
  263. cc,alpha*-*-osf*)
  264. bytecccompopts="-std1 -ieee";;
  265. gcc,alpha*-*-linux*)
  266. if cc="$bytecc" sh ./hasgot -mieee; then
  267. bytecccompopts="-mieee $bytecccompopts";
  268. fi;;
  269. cc,mips-*-irix6*)
  270. # Add -n32 flag to ensure compatibility with native-code compiler
  271. bytecccompopts="-n32"
  272. # Turn off warning "unused library"
  273. bytecclinkopts="-n32 -Wl,-woff,84";;
  274. cc*,mips-*-irix6*)
  275. # (For those who want to force "cc -64")
  276. # Turn off warning "unused library"
  277. bytecclinkopts="-Wl,-woff,84";;
  278. *,alpha*-*-unicos*)
  279. # For the Cray T3E
  280. bytecccompopts="-DUMK";;
  281. gcc*,powerpc-*-aix*)
  282. # Avoid name-space pollution by requiring Unix98-conformant includes
  283. bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
  284. *,powerpc-*-aix*)
  285. bytecccompopts="-D_XOPEN_SOURCE=500";;
  286. gcc*,*-*-cygwin*)
  287. bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
  288. dllccompopts="-U_WIN32 -DCAML_DLL"
  289. if test $withsharedlibs = yes; then
  290. flexlink="flexlink -chain cygwin -merge-manifest"
  291. flexdir=`$flexlink -where | dos2unix`
  292. if test -z "$flexdir"; then
  293. echo "flexlink not found: native shared libraries won't be available"
  294. withsharedlibs=no
  295. else
  296. iflexdir="-I\"$flexdir\""
  297. mkexe="$flexlink -exe"
  298. fi
  299. fi
  300. exe=".exe"
  301. ostype="Cygwin";;
  302. gcc*,x86_64-*-linux*)
  303. bytecccompopts="-fno-defer-pop $gcc_warnings"
  304. # Tell gcc that we can use 32-bit code addresses for threaded code
  305. # unless we are compiled for a shared library (-fPIC option)
  306. echo "#ifndef __PIC__" >> m.h
  307. echo "# define ARCH_CODE32" >> m.h
  308. echo "#endif" >> m.h;;
  309. gcc*)
  310. bytecccompopts="-fno-defer-pop $gcc_warnings";;
  311. esac
  312. # Configure compiler to use in further tests
  313. cc="$bytecc -O $bytecclinkopts"
  314. export cc cclibs verbose
  315. # Check C compiler
  316. sh ./runtest ansi.c
  317. case $? in
  318. 0) echo "The C compiler is ANSI-compliant.";;
  319. 1) echo "The C compiler $cc is not ANSI-compliant."
  320. echo "You need an ANSI C compiler to build OCaml."
  321. exit 2;;
  322. *) echo "Unable to compile the test program."
  323. echo "Make sure the C compiler $cc is properly installed."
  324. exit 2;;
  325. esac
  326. # Check the sizes of data types
  327. echo "Checking the sizes of integers and pointers..."
  328. set `sh ./runtest sizes.c`
  329. case "$2,$3" in
  330. 4,4) echo "OK, this is a regular 32 bit architecture."
  331. echo "#undef ARCH_SIXTYFOUR" >> m.h
  332. arch64=false;;
  333. *,8) echo "Wow! A 64 bit architecture!"
  334. echo "#define ARCH_SIXTYFOUR" >> m.h
  335. arch64=true;;
  336. *,*) echo "This architecture seems to be neither 32 bits nor 64 bits."
  337. echo "OCaml won't run on this architecture."
  338. exit 2;;
  339. *) echo "Unable to compile the test program."
  340. echo "Make sure the C compiler $cc is properly installed."
  341. exit 2;;
  342. esac
  343. if test $1 != 4 && test $2 != 4 && test $4 != 4; then
  344. echo "Sorry, we can't find a 32-bit integer type"
  345. echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)"
  346. echo "OCaml won't run on this architecture."
  347. exit 2
  348. fi
  349. echo "#define SIZEOF_INT $1" >> m.h
  350. echo "#define SIZEOF_LONG $2" >> m.h
  351. echo "#define SIZEOF_PTR $3" >> m.h
  352. echo "#define SIZEOF_SHORT $4" >> m.h
  353. if test $2 = 8; then
  354. echo "#define ARCH_INT64_TYPE long" >> m.h
  355. echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h
  356. echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h
  357. int64_native=true
  358. else
  359. sh ./runtest longlong.c
  360. case $? in
  361. 0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")."
  362. echo "#define ARCH_INT64_TYPE long long" >> m.h
  363. echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
  364. echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h
  365. int64_native=true;;
  366. 1) echo "64-bit \"long long\" integer type found (printf with \"%q\")."
  367. echo "#define ARCH_INT64_TYPE long long" >> m.h
  368. echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
  369. echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h
  370. int64_native=true;;
  371. 2) echo "64-bit \"long long\" integer type found (but no printf)."
  372. echo "#define ARCH_INT64_TYPE long long" >> m.h
  373. echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h
  374. echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
  375. int64_native=true;;
  376. *) echo "No suitable 64-bit integer type found, will use software emulation."
  377. echo "#undef ARCH_INT64_TYPE" >> m.h
  378. echo "#undef ARCH_UINT64_TYPE" >> m.h
  379. echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h
  380. int64_native=false;;
  381. esac
  382. fi
  383. if test $3 = 8 && test $int64_native = false; then
  384. echo "This architecture has 64-bit pointers but no 64-bit integer type."
  385. echo "OCaml won't run on this architecture."
  386. exit 2
  387. fi
  388. # Determine endianness
  389. sh ./runtest endian.c
  390. case $? in
  391. 0) echo "This is a big-endian architecture."
  392. echo "#define ARCH_BIG_ENDIAN" >> m.h;;
  393. 1) echo "This is a little-endian architecture."
  394. echo "#undef ARCH_BIG_ENDIAN" >> m.h;;
  395. 2) echo "This architecture seems to be neither big endian nor little endian."
  396. echo "OCaml won't run on this architecture."
  397. exit 2;;
  398. *) echo "Something went wrong during endianness determination."
  399. echo "You'll have to figure out endianness yourself"
  400. echo "(option ARCH_BIG_ENDIAN in m.h).";;
  401. esac
  402. # Determine alignment constraints
  403. case "$host" in
  404. sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*)
  405. # On Sparc V9 with certain versions of gcc, determination of double
  406. # alignment is not reliable (PR#1521), hence force it.
  407. # Same goes for hppa.
  408. # PR#5088 suggests same problem on ARM.
  409. # PR#5280 reports same problem on MIPS.
  410. # But there's a knack (PR#2572):
  411. # if we're in 64-bit mode (sizeof(long) == 8),
  412. # we must not doubleword-align floats...
  413. if test $2 = 8; then
  414. echo "Doubles can be word-aligned."
  415. echo "#undef ARCH_ALIGN_DOUBLE" >> m.h
  416. else
  417. echo "Doubles must be doubleword-aligned."
  418. echo "#define ARCH_ALIGN_DOUBLE" >> m.h
  419. fi;;
  420. *)
  421. sh ./runtest dblalign.c
  422. case $? in
  423. 0) echo "Doubles can be word-aligned."
  424. echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;;
  425. 1) echo "Doubles must be doubleword-aligned."
  426. echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
  427. *) echo "Something went wrong during alignment determination for doubles."
  428. echo "I'm going to assume this architecture has alignment constraints over doubles."
  429. echo "That's a safe bet: OCaml will work even if"
  430. echo "this architecture has actually no alignment constraints."
  431. echo "#define ARCH_ALIGN_DOUBLE" >> m.h;;
  432. esac;;
  433. esac
  434. if $int64_native; then
  435. case "$host" in
  436. # PR#5088: autodetection is unreliable on ARM. PR#5280: also on MIPS.
  437. sparc*-*-*|hppa*-*-*|arm*-*-*|mips*-*-*)
  438. if test $2 = 8; then
  439. echo "64-bit integers can be word-aligned."
  440. echo "#undef ARCH_ALIGN_INT64" >> m.h
  441. else
  442. echo "64-bit integers must be doubleword-aligned."
  443. echo "#define ARCH_ALIGN_INT64" >> m.h
  444. fi;;
  445. *)
  446. sh ./runtest int64align.c
  447. case $? in
  448. 0) echo "64-bit integers can be word-aligned."
  449. echo "#undef ARCH_ALIGN_INT64" >> m.h;;
  450. 1) echo "64-bit integers must be doubleword-aligned."
  451. echo "#define ARCH_ALIGN_INT64" >> m.h;;
  452. *) echo "Something went wrong during alignment determination for 64-bit integers."
  453. echo "I'm going to assume this architecture has alignment constraints."
  454. echo "That's a safe bet: OCaml will work even if"
  455. echo "this architecture has actually no alignment constraints."
  456. echo "#define ARCH_ALIGN_INT64" >> m.h;;
  457. esac
  458. esac
  459. else
  460. echo "#undef ARCH_ALIGN_INT64" >> m.h
  461. fi
  462. # Check semantics of division and modulus
  463. sh ./runtest divmod.c
  464. case $? in
  465. 0) echo "Native division and modulus have round-towards-zero semantics, will use them."
  466. echo "#undef NONSTANDARD_DIV_MOD" >> m.h;;
  467. 1) echo "Native division and modulus do not have round-towards-zero semantics, will use software emulation."
  468. echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
  469. *) echo "Something went wrong while checking native division and modulus, please report it."
  470. echo "#define NONSTANDARD_DIV_MOD" >> m.h;;
  471. esac
  472. # Shared library support
  473. shared_libraries_supported=false
  474. dl_needs_underscore=false
  475. sharedcccompopts=''
  476. mksharedlib=''
  477. byteccrpath=''
  478. mksharedlibrpath=''
  479. natdynlinkopts=""
  480. if test $withsharedlibs = "yes"; then
  481. case "$host" in
  482. *-*-cygwin*)
  483. mksharedlib="$flexlink"
  484. mkmaindll="$flexlink -maindll"
  485. shared_libraries_supported=true;;
  486. *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-openbsd*|*-*-netbsd*|*-*-gnu*)
  487. sharedcccompopts="-fPIC"
  488. mksharedlib="$bytecc -shared"
  489. bytecclinkopts="$bytecclinkopts -Wl,-E"
  490. byteccrpath="-Wl,-rpath,"
  491. mksharedlibrpath="-Wl,-rpath,"
  492. natdynlinkopts="-Wl,-E"
  493. shared_libraries_supported=true;;
  494. alpha*-*-osf*)
  495. case "$bytecc" in
  496. gcc*)
  497. sharedcccompopts="-fPIC"
  498. mksharedlib="$bytecc -shared"
  499. byteccrpath="-Wl,-rpath,"
  500. mksharedlibrpath="-Wl,-rpath,"
  501. shared_libraries_supported=true;;
  502. cc*)
  503. sharedcccompopts=""
  504. mksharedlib="ld -shared -expect_unresolved '*'"
  505. byteccrpath="-Wl,-rpath,"
  506. mksharedlibrpath="-rpath "
  507. shared_libraries_supported=true;;
  508. esac;;
  509. *-*-solaris2*)
  510. case "$bytecc" in
  511. gcc*)
  512. sharedcccompopts="-fPIC"
  513. if sh ./solaris-ld; then
  514. mksharedlib="$bytecc -shared"
  515. byteccrpath="-R"
  516. mksharedlibrpath="-R"
  517. else
  518. mksharedlib="$bytecc -shared"
  519. bytecclinkopts="$bytecclinkopts -Wl,-E"
  520. natdynlinkopts="-Wl,-E"
  521. byteccrpath="-Wl,-rpath,"
  522. mksharedlibrpath="-Wl,-rpath,"
  523. fi
  524. shared_libraries_supported=true;;
  525. *)
  526. sharedcccompopts="-KPIC"
  527. byteccrpath="-R"
  528. mksharedlibrpath="-R"
  529. mksharedlib="/usr/ccs/bin/ld -G"
  530. shared_libraries_supported=true;;
  531. esac;;
  532. mips*-*-irix[56]*)
  533. case "$bytecc" in
  534. cc*) sharedcccompopts="";;
  535. gcc*) sharedcccompopts="-fPIC";;
  536. esac
  537. mksharedlib="ld -shared -rdata_shared"
  538. byteccrpath="-Wl,-rpath,"
  539. mksharedlibrpath="-rpath "
  540. shared_libraries_supported=true;;
  541. i[3456]86-*-darwin[89].*)
  542. mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress -read_only_relocs suppress"
  543. bytecccompopts="$dl_defs $bytecccompopts"
  544. dl_needs_underscore=false
  545. shared_libraries_supported=true;;
  546. *-apple-darwin*)
  547. mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress"
  548. bytecccompopts="$dl_defs $bytecccompopts"
  549. dl_needs_underscore=false
  550. shared_libraries_supported=true;;
  551. m88k-*-openbsd*)
  552. shared_libraries_supported=false;;
  553. vax-*-openbsd*)
  554. shared_libraries_supported=false;;
  555. *-*-openbsd*)
  556. sharedcccompopts="-fPIC"
  557. mksharedlib="$bytecc -shared"
  558. bytecclinkopts="$bytecclinkopts -Wl,-E"
  559. natdynlinkopts="-Wl,-E"
  560. byteccrpath="-Wl,-rpath,"
  561. mksharedlibrpath="-Wl,-rpath,"
  562. shared_libraries_supported=true;;
  563. esac
  564. fi
  565. if test -z "$mkmaindll"; then
  566. mkmaindll=$mksharedlib
  567. fi
  568. # Configure native dynlink
  569. natdynlink=false
  570. if test $withsharedlibs = "yes"; then
  571. case "$host" in
  572. *-*-cygwin*) natdynlink=true;;
  573. i[3456]86-*-linux*) natdynlink=true;;
  574. x86_64-*-linux*) natdynlink=true;;
  575. i[3456]86-*-darwin[89].*) natdynlink=true;;
  576. i[3456]86-*-darwin*)
  577. if test $arch64 == true; then
  578. natdynlink=true
  579. fi;;
  580. x86_64-*-darwin*) natdynlink=true;;
  581. powerpc64-*-linux*) natdynlink=true;;
  582. sparc-*-linux*) natdynlink=true;;
  583. i686-*-kfreebsd*) natdynlink=true;;
  584. x86_64-*-kfreebsd*) natdynlink=true;;
  585. i[345]86-*-freebsd*) natdynlink=true;;
  586. x86_64-*-freebsd*) natdynlink=true;;
  587. i[345]86-*-openbsd*) natdynlink=true;;
  588. x86_64-*-openbsd*) natdynlink=true;;
  589. i[345]86-*-netbsd*) natdynlink=true;;
  590. x86_64-*-netbsd*) natdynlink=true;;
  591. i386-*-gnu0.3) natdynlink=true;;
  592. esac
  593. fi
  594. if test $natdynlink = "true"; then
  595. cmxs="cmxs"
  596. else
  597. cmxs="cmxa"
  598. fi
  599. # Configure the native-code compiler
  600. arch=none
  601. model=default
  602. system=unknown
  603. case "$host" in
  604. sparc*-*-sunos4.*) arch=sparc; system=sunos;;
  605. sparc*-*-solaris2.*) arch=sparc; system=solaris;;
  606. sparc*-*-*bsd*) arch=sparc; system=bsd;;
  607. sparc*-*-linux*) arch=sparc; system=linux;;
  608. sparc*-*-gnu*) arch=sparc; system=gnu;;
  609. i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;;
  610. i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;;
  611. i[3456]86-*-nextstep*) arch=i386; system=nextstep;;
  612. i[3456]86-*-solaris*) if $arch64; then
  613. arch=amd64; system=solaris
  614. else
  615. arch=i386; system=solaris
  616. fi;;
  617. i[3456]86-*-beos*) arch=i386; system=beos;;
  618. i[3456]86-*-cygwin*) arch=i386; system=cygwin;;
  619. i[3456]86-*-darwin*) if $arch64; then
  620. arch=amd64; system=macosx
  621. else
  622. arch=i386; system=macosx
  623. fi;;
  624. i[3456]86-*-gnu*) arch=i386; system=gnu;;
  625. powerpc*-*-linux*) arch=power; model=ppc; system=elf;;
  626. powerpc-*-netbsd*) arch=power; model=ppc; system=elf;;
  627. powerpc-*-rhapsody*) arch=power; model=ppc; system=rhapsody;;
  628. powerpc-*-darwin*) arch=power; system=rhapsody
  629. if $arch64; then model=ppc64; else model=ppc; fi;;
  630. arm*-*-linux*) arch=arm; system=linux;;
  631. arm*-*-gnu*) arch=arm; system=gnu;;
  632. x86_64-*-linux*) arch=amd64; system=linux;;
  633. x86_64-*-gnu*) arch=amd64; system=gnu;;
  634. x86_64-*-freebsd*) arch=amd64; system=freebsd;;
  635. x86_64-*-netbsd*) arch=amd64; system=netbsd;;
  636. x86_64-*-openbsd*) arch=amd64; system=openbsd;;
  637. x86_64-*-darwin*) arch=amd64; system=macosx;;
  638. esac
  639. # Some platforms exist both in 32-bit and 64-bit variants, not distinguished
  640. # by $host. Turn off native code compilation on platforms where 64-bit mode
  641. # is not supported. (PR#4441)
  642. if $arch64; then
  643. case "$arch,$model" in
  644. sparc,default|power,ppc)
  645. arch=none; model=default; system=unknown;;
  646. esac
  647. fi
  648. if test -z "$ccoption"; then
  649. nativecc="$bytecc"
  650. else
  651. nativecc="$ccoption"
  652. fi
  653. nativecccompopts=''
  654. nativecclinkopts=''
  655. nativeccrpath="$byteccrpath"
  656. case "$arch,$nativecc,$system,$host_type" in
  657. *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
  658. nativecclinkopts="-posix";;
  659. *,*,rhapsody,*darwin[1-5].*)
  660. nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
  661. *,*,rhapsody,*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs"
  662. if $arch64; then partialld="ld -r -arch ppc64"; fi;;
  663. *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";;
  664. amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
  665. amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
  666. *,gcc*,*,*) nativecccompopts="$gcc_warnings";;
  667. esac
  668. asppprofflags='-DPROFILING'
  669. case "$arch,$model,$system" in
  670. amd64,*,macosx) as='as -arch x86_64'
  671. aspp='gcc -arch x86_64 -c';;
  672. amd64,*,solaris) as='as --64'
  673. aspp='gcc -m64 -c';;
  674. amd64,*,*) as='as'
  675. aspp='gcc -c';;
  676. arm,*,*) as='as';
  677. aspp='gcc -c';;
  678. i386,*,solaris) as='as'
  679. aspp='/usr/ccs/bin/as -P';;
  680. i386,*,*) as='as'
  681. aspp='gcc -c';;
  682. power,*,elf) as='as -u -m ppc'
  683. aspp='gcc -c';;
  684. power,*,bsd) as='as'
  685. aspp='gcc -c';;
  686. power,*,rhapsody) as="as -arch $model"
  687. aspp="$bytecc -c";;
  688. sparc,*,solaris) as='as'
  689. case "$cc" in
  690. gcc*) aspp='gcc -c';;
  691. *) aspp='as -P';;
  692. esac;;
  693. sparc,*,*) as='as'
  694. aspp='gcc -c';;
  695. esac
  696. if test -n "$asoption"; then as="$asoption"; fi
  697. if test -n "$asppoption"; then aspp="$asppoption"; fi
  698. cc_profile='-pg'
  699. case "$arch,$model,$system" in
  700. i386,*,linux_elf) profiling='prof';;
  701. i386,*,gnu) profiling='prof';;
  702. i386,*,bsd_elf) profiling='prof';;
  703. amd64,*,macosx) profiling='prof';;
  704. i386,*,macosx) profiling='prof';;
  705. sparc,*,solaris)
  706. profiling='prof'
  707. case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;;
  708. amd64,*,linux) profiling='prof';;
  709. amd64,*,gnu) profiling='prof';;
  710. *) profiling='noprof';;
  711. esac
  712. # Where is ranlib?
  713. if sh ./searchpath ranlib; then
  714. echo "ranlib found"
  715. echo "RANLIB=ranlib" >> Makefile
  716. echo "RANLIBCMD=ranlib" >> Makefile
  717. else
  718. echo "ranlib not used"
  719. echo "RANLIB=ar rs" >> Makefile
  720. echo "RANLIBCMD=" >> Makefile
  721. fi
  722. echo "ARCMD=ar" >> Makefile
  723. # Do #! scripts work?
  724. if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then
  725. echo "#! appears to work in shell scripts"
  726. case "$host" in
  727. *-*-sunos*|*-*-unicos*)
  728. echo "We won't use it, though, because under SunOS and Unicos it breaks"
  729. echo "on pathnames longer than 30 characters"
  730. echo "SHARPBANGSCRIPTS=false" >> Makefile;;
  731. *-*-cygwin*)
  732. echo "We won't use it, though, because of conflicts with .exe extension"
  733. echo "under Cygwin"
  734. echo "SHARPBANGSCRIPTS=false" >> Makefile;;
  735. *)
  736. echo "SHARPBANGSCRIPTS=true" >> Makefile;;
  737. esac
  738. else
  739. echo "No support for #! in shell scripts"
  740. echo "SHARPBANGSCRIPTS=false" >> Makefile
  741. fi
  742. # Write the OS type (Unix or Cygwin)
  743. echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h
  744. echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h
  745. # Use 64-bit file offset if possible
  746. bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64"
  747. nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64"
  748. # Check the semantics of signal handlers
  749. if sh ./hasgot sigaction sigprocmask; then
  750. echo "POSIX signal handling found."
  751. echo "#define POSIX_SIGNALS" >> s.h
  752. else
  753. if sh ./runtest signals.c; then
  754. echo "Signals have the BSD semantics."
  755. echo "#define BSD_SIGNALS" >> s.h
  756. else
  757. echo "Signals have the System V semantics."
  758. fi
  759. if sh ./hasgot sigsetmask; then
  760. echo "sigsetmask() found"
  761. echo "#define HAS_SIGSETMASK" >> s.h
  762. fi
  763. fi
  764. # For the Pervasives module
  765. if sh ./hasgot2 -i math.h $mathlib expm1 log1p hypot copysign; then
  766. echo "expm1(), log1p(), hypot(), copysign() found."
  767. echo "#define HAS_C99_FLOAT_OPS" >> s.h
  768. fi
  769. # For the Sys module
  770. if sh ./hasgot getrusage; then
  771. echo "getrusage() found."
  772. echo "#define HAS_GETRUSAGE" >> s.h
  773. fi
  774. if sh ./hasgot times; then
  775. echo "times() found."
  776. echo "#define HAS_TIMES" >> s.h
  777. fi
  778. # For the terminfo module
  779. if test "$withcurses" = "yes"; then
  780. for libs in "" "-lcurses" "-ltermcap" "-lcurses -ltermcap" "-lncurses"; do
  781. if sh ./hasgot $libs tgetent tgetstr tgetnum tputs; then
  782. echo "termcap functions found (with libraries '$libs')"
  783. echo "#define HAS_TERMCAP" >> s.h
  784. curseslibs="${libs}"
  785. break
  786. fi
  787. done
  788. fi
  789. # Configuration for the libraries
  790. otherlibraries="unix str num dynlink bigarray"
  791. # For the Unix library
  792. has_sockets=no
  793. if sh ./hasgot socket socketpair bind listen accept connect; then
  794. echo "You have BSD sockets."
  795. echo "#define HAS_SOCKETS" >> s.h
  796. has_sockets=yes
  797. elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect; then
  798. echo "You have BSD sockets (with libraries '-lnsl -lsocket')"
  799. cclibs="$cclibs -lnsl -lsocket"
  800. echo "#define HAS_SOCKETS" >> s.h
  801. has_sockets=yes
  802. fi
  803. if sh ./hasgot -i sys/socket.h -t socklen_t; then
  804. echo "socklen_t is defined in <sys/socket.h>"
  805. echo "#define HAS_SOCKLEN_T" >> s.h
  806. fi
  807. if sh ./hasgot inet_aton; then
  808. echo "inet_aton() found."
  809. echo "#define HAS_INET_ATON" >> s.h
  810. fi
  811. if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \
  812. -t 'struct sockaddr_in6' \
  813. && sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then
  814. echo "IPv6 is supported."
  815. echo "#define HAS_IPV6" >> s.h
  816. fi
  817. if sh ./hasgot -i unistd.h; then
  818. echo "unistd.h found."
  819. echo "#define HAS_UNISTD" >> s.h
  820. fi
  821. if sh ./hasgot -i sys/types.h -t off_t; then
  822. echo "off_t is defined in <sys/types.h>"
  823. echo "#define HAS_OFF_T" >> s.h
  824. fi
  825. if sh ./hasgot -i sys/types.h -i dirent.h; then
  826. echo "dirent.h found."
  827. echo "#define HAS_DIRENT" >> s.h
  828. fi
  829. if sh ./hasgot rewinddir; then
  830. echo "rewinddir() found."
  831. echo "#define HAS_REWINDDIR" >> s.h
  832. fi
  833. if sh ./hasgot lockf; then
  834. echo "lockf() found."
  835. echo "#define HAS_LOCKF" >> s.h
  836. fi
  837. if sh ./hasgot mkfifo; then
  838. echo "mkfifo() found."
  839. echo "#define HAS_MKFIFO" >> s.h
  840. fi
  841. if sh ./hasgot getcwd; then
  842. echo "getcwd() found."
  843. echo "#define HAS_GETCWD" >> s.h
  844. fi
  845. if sh ./hasgot getwd; then
  846. echo "getwd() found."
  847. echo "#define HAS_GETWD" >> s.h
  848. fi
  849. if sh ./hasgot getpriority setpriority; then
  850. echo "getpriority() found."
  851. echo "#define HAS_GETPRIORITY" >> s.h
  852. fi
  853. if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then
  854. echo "utime() found."
  855. echo "#define HAS_UTIME" >> s.h
  856. fi
  857. if sh ./hasgot utimes; then
  858. echo "utimes() found."
  859. echo "#define HAS_UTIMES" >> s.h
  860. fi
  861. if sh ./hasgot dup2; then
  862. echo "dup2() found."
  863. echo "#define HAS_DUP2" >> s.h
  864. fi
  865. if sh ./hasgot fchmod fchown; then
  866. echo "fchmod() found."
  867. echo "#define HAS_FCHMOD" >> s.h
  868. fi
  869. if sh ./hasgot truncate ftruncate; then
  870. echo "truncate() found."
  871. echo "#define HAS_TRUNCATE" >> s.h
  872. fi
  873. select_include=''
  874. if sh ./hasgot -i sys/types.h -i sys/select.h; then
  875. echo "sys/select.h found."
  876. echo "#define HAS_SYS_SELECT_H" >> s.h
  877. select_include='-i sys/select.h'
  878. fi
  879. has_select=no
  880. if sh ./hasgot select && \
  881. sh ./hasgot -i sys/types.h $select_include -t fd_set ; then
  882. echo "select() found."
  883. echo "#define HAS_SELECT" >> s.h
  884. has_select=yes
  885. fi
  886. if sh ./hasgot symlink readlink lstat; then
  887. echo "symlink() found."
  888. echo "#define HAS_SYMLINK" >> s.h
  889. fi
  890. has_wait=no
  891. if sh ./hasgot waitpid; then
  892. echo "waitpid() found."
  893. echo "#define HAS_WAITPID" >> s.h
  894. has_wait=yes
  895. fi
  896. if sh ./hasgot wait4; then
  897. echo "wait4() found."
  898. echo "#define HAS_WAIT4" >> s.h
  899. has_wait=yes
  900. fi
  901. if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then
  902. echo "getgroups() found."
  903. echo "#define HAS_GETGROUPS" >> s.h
  904. fi
  905. if sh ./hasgot -i limits.h -i grp.h && sh ./runtest setgroups.c; then
  906. echo "setgroups() found."
  907. echo "#define HAS_SETGROUPS" >> s.h
  908. fi
  909. if sh ./hasgot -i limits.h -i grp.h && sh ./runtest initgroups.c; then
  910. echo "initgroups() found."
  911. echo "#define HAS_INITGROUPS" >> s.h
  912. fi
  913. if sh ./hasgot -i termios.h &&
  914. sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
  915. echo "POSIX termios found."
  916. echo "#define HAS_TERMIOS" >> s.h
  917. fi
  918. if sh ./runtest async_io.c; then
  919. echo "Asynchronous I/O are supported."
  920. echo "#define HAS_ASYNC_IO" >> s.h
  921. fi
  922. has_setitimer=no
  923. if sh ./hasgot setitimer; then
  924. echo "setitimer() found."
  925. echo "#define HAS_SETITIMER" >> s.h
  926. has_setitimer="yes"
  927. fi
  928. if sh ./hasgot gethostname; then
  929. echo "gethostname() found."
  930. echo "#define HAS_GETHOSTNAME" >> s.h
  931. fi
  932. if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then
  933. echo "uname() found."
  934. echo "#define HAS_UNAME" >> s.h
  935. fi
  936. has_gettimeofday=no
  937. if sh ./hasgot gettimeofday; then
  938. echo "gettimeofday() found."
  939. echo "#define HAS_GETTIMEOFDAY" >> s.h
  940. has_gettimeofday="yes"
  941. fi
  942. if sh ./hasgot mktime; then
  943. echo "mktime() found."
  944. echo "#define HAS_MKTIME" >> s.h
  945. fi
  946. case "$host" in
  947. *-*-cygwin*) ;; # setsid emulation under Cygwin breaks the debugger
  948. *) if sh ./hasgot setsid; then
  949. echo "setsid() found."
  950. echo "#define HAS_SETSID" >> s.h
  951. fi;;
  952. esac
  953. if sh ./hasgot putenv; then
  954. echo "putenv() found."
  955. echo "#define HAS_PUTENV" >> s.h
  956. fi
  957. if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then
  958. echo "setlocale() and <locale.h> found."
  959. echo "#define HAS_LOCALE" >> s.h
  960. fi
  961. if sh ./hasgot $dllib dlopen; then
  962. echo "dlopen() found."
  963. elif sh ./hasgot $dllib -ldl dlopen; then
  964. echo "dlopen() found in -ldl."
  965. dllib="$dllib -ldl"
  966. else
  967. shared_libraries_supported=false
  968. fi
  969. if $shared_libraries_supported; then
  970. echo "Dynamic loading of shared libraries is supported."
  971. echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h
  972. if $dl_needs_underscore; then
  973. echo '#define DL_NEEDS_UNDERSCORE' >>s.h
  974. fi
  975. fi
  976. if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then
  977. echo "mmap() found."
  978. echo "#define HAS_MMAP" >> s.h
  979. fi
  980. nargs=none
  981. for i in 5 6; do
  982. if sh ./trycompile -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi
  983. done
  984. if test $nargs != "none"; then
  985. echo "gethostbyname_r() found (with ${nargs} arguments)."
  986. echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h
  987. fi
  988. nargs=none
  989. for i in 7 8; do
  990. if sh ./trycompile -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi
  991. done
  992. if test $nargs != "none"; then
  993. echo "gethostbyaddr_r() found (with ${nargs} arguments)."
  994. echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h
  995. fi
  996. # Determine if the debugger is supported
  997. if test "$has_sockets" = "yes"; then
  998. echo "Replay debugger supported."
  999. debugger="ocamldebugger"
  1000. else
  1001. echo "No replay debugger (missing system calls)"
  1002. debugger=""
  1003. fi
  1004. # Determine if system stack overflows can be detected
  1005. case "$arch,$system" in
  1006. i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx|amd64,macosx)
  1007. echo "System stack overflow can be detected."
  1008. echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
  1009. *)
  1010. echo "Cannot detect system stack overflow.";;
  1011. esac
  1012. # Determine the target architecture for the "num" library
  1013. case "$arch" in
  1014. i386) bng_arch=ia32
  1015. if sh ./trycompile ia32sse2.c
  1016. then bng_asm_level=2
  1017. else bng_asm_level=1
  1018. fi;;
  1019. power) bng_arch=ppc; bng_asm_level=1;;
  1020. amd64) bng_arch=amd64; bng_asm_level=1;;
  1021. *) bng_arch=generic; bng_asm_level=0;;
  1022. esac
  1023. echo "BNG_ARCH=$bng_arch" >> Makefile
  1024. echo "BNG_ASM_LEVEL=$bng_asm_level" >> Makefile
  1025. # Determine if the POSIX threads library is supported
  1026. systhread_support=false
  1027. if test "$pthread_wanted" = "yes"; then
  1028. case "$host" in
  1029. *-*-solaris*) pthread_link="-lpthread -lposix4"
  1030. pthread_caml_link="-cclib -lpthread -cclib -lposix4";;
  1031. *-*-freebsd*) pthread_link="-pthread"
  1032. pthread_caml_link="-cclib -pthread";;
  1033. *-*-openbsd*) pthread_link="-pthread"
  1034. pthread_caml_link="-cclib -pthread";;
  1035. *) pthread_link="-lpthread"
  1036. pthread_caml_link="-cclib -lpthread";;
  1037. esac
  1038. if ./hasgot -i pthread.h $pthread_link pthread_self; then
  1039. echo "POSIX threads library supported."
  1040. systhread_support=true
  1041. otherlibraries="$otherlibraries systhreads"
  1042. bytecccompopts="$bytecccompopts -D_REENTRANT"
  1043. nativecccompopts="$nativecccompopts -D_REENTRANT"
  1044. case "$host" in
  1045. *-*-freebsd*)
  1046. bytecccompopts="$bytecccompopts -D_THREAD_SAFE"
  1047. nativecccompopts="$nativecccompopts -D_THREAD_SAFE";;
  1048. *-*-openbsd*)
  1049. bytecccompopts="$bytecccompopts -pthread"
  1050. asppflags="$asppflags -pthread"
  1051. nativecccompopts="$nativecccompopts -pthread";;
  1052. esac
  1053. echo "Options for linking with POSIX threads: $pthread_link"
  1054. if sh ./hasgot $pthread_link sigwait; then
  1055. echo "sigwait() found"
  1056. echo "#define HAS_SIGWAIT" >> s.h
  1057. fi
  1058. else
  1059. echo "POSIX threads not found."
  1060. pthread_link=""
  1061. fi
  1062. else
  1063. pthread_link=""
  1064. fi
  1065. echo "PTHREAD_LINK=$pthread_caml_link" >> Makefile
  1066. # Determine if the bytecode thread library is supported
  1067. if test "$has_select" = "yes" \
  1068. && test "$has_setitimer" = "yes" \
  1069. && test "$has_gettimeofday" = "yes" \
  1070. && test "$has_wait" = "yes"; then
  1071. echo "Bytecode threads library supported."
  1072. otherlibraries="$otherlibraries threads"
  1073. else
  1074. echo "Bytecode threads library not supported (missing system calls)"
  1075. fi
  1076. # Determine the location of X include files and libraries
  1077. # If the user specified -x11include and/or -x11lib, these settings
  1078. # are used. Otherwise, we check whether there is pkg-config, and take
  1079. # the flags from there. Otherwise, we search the location.
  1080. x11_include="not found"
  1081. x11_link="not found"
  1082. if test -z "$x11_include_dir" -a -z "$x11_lib_dir"; then
  1083. if pkg-config --exists x11 2>/dev/null; then
  1084. x11_include=`pkg-config --cflags x11`
  1085. x11_link=`pkg-config --libs x11`
  1086. fi
  1087. fi
  1088. if test "$x11_include" = "not found"; then
  1089. for dir in \
  1090. $x11_include_dir \
  1091. \
  1092. /usr/X11R7/include \
  1093. /usr/include/X11R7 \
  1094. /usr/local/X11R7/include \
  1095. /usr/local/include/X11R7 \
  1096. /opt/X11R7/include \
  1097. \
  1098. /usr/X11R6/include \
  1099. /usr/include/X11R6 \
  1100. /usr/local/X11R6/include \
  1101. /usr/local/include/X11R6 \
  1102. /opt/X11R6/include \
  1103. \
  1104. /usr/X11/include \
  1105. /usr/include/X11 \
  1106. /usr/local/X11/include \
  1107. /usr/local/include/X11 \
  1108. /opt/X11/include \
  1109. \
  1110. /usr/X11R5/include \
  1111. /usr/include/X11R5 \
  1112. /usr/local/X11R5/include \
  1113. /usr/local/include/X11R5 \
  1114. /usr/local/x11r5/include \
  1115. /opt/X11R5/include \
  1116. \
  1117. /usr/X11R4/include \
  1118. /usr/include/X11R4 \
  1119. /usr/local/X11R4/include \
  1120. /usr/local/include/X11R4 \
  1121. \
  1122. /usr/X386/include \
  1123. /usr/x386/include \
  1124. /usr/XFree86/include/X11 \
  1125. \
  1126. /usr/include \
  1127. /usr/local/include \
  1128. /usr/unsupported/include \
  1129. /usr/athena/include \
  1130. /usr/lpp/Xamples/include \
  1131. \
  1132. /usr/openwin/include \
  1133. /usr/openwin/share/include \
  1134. ; \
  1135. do
  1136. if test -f $dir/X11/X.h; then
  1137. x11_include_dir=$dir
  1138. x11_include="-I$dir"
  1139. break
  1140. fi
  1141. done
  1142. if test "$x11_include" = "not found"; then
  1143. x11_try_lib_dir=''
  1144. else
  1145. x11_try_lib_dir=`echo $x11_include_dir | sed -e 's|include|lib|'`
  1146. fi
  1147. for dir in \
  1148. $x11_lib_dir \
  1149. $x11_try_lib_dir \
  1150. \
  1151. /usr/X11R6/lib64 \
  1152. /usr/X11R6/lib \
  1153. /usr/lib/X11R6 \
  1154. /usr/local/X11R6/lib \
  1155. /usr/local/lib/X11R6 \
  1156. /opt/X11R6/lib \
  1157. \
  1158. /usr/X11/lib \
  1159. /usr/lib/X11 \
  1160. /usr/local/X11/lib \
  1161. /usr/local/lib/X11 \
  1162. /opt/X11/lib \
  1163. \
  1164. /usr/X11R5/lib \
  1165. /usr/lib/X11R5 \
  1166. /usr/local/X11R5/lib \
  1167. /usr/local/lib/X11R5 \
  1168. /usr/local/x11r5/lib \
  1169. /opt/X11R5/lib \
  1170. \
  1171. /usr/X11R4/lib \
  1172. /usr/lib/X11R4 \
  1173. /usr/local/X11R4/lib \
  1174. /usr/local/lib/X11R4 \
  1175. \
  1176. /usr/X386/lib \
  1177. /usr/x386/lib \
  1178. /usr/XFree86/lib/X11 \
  1179. \
  1180. /usr/lib64 \
  1181. /usr/lib \
  1182. /usr/local/lib \
  1183. /usr/unsupported/lib \
  1184. /usr/athena/lib \
  1185. /usr/lpp/Xamples/lib \
  1186. /lib/usr/lib/X11 \
  1187. \
  1188. /usr/openwin/lib \
  1189. /usr/openwin/share/lib \
  1190. ; \
  1191. do
  1192. if test -f $dir/libX11.a || \
  1193. test -f $dir/libX11.so || \
  1194. test -f $dir/libX11.dll.a || \
  1195. test -f $dir/libX11.dylib || \
  1196. test -f $dir/libX11.sa; then
  1197. if test $dir = /usr/lib; then
  1198. x11_link="-lX11"
  1199. else
  1200. x11_libs="-L$dir"
  1201. case "$host" in
  1202. *-kfreebsd*-gnu) x11_link="-L$dir -lX11";;
  1203. *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";;
  1204. *) x11_link="-L$dir -lX11";;
  1205. esac
  1206. fi
  1207. break
  1208. fi
  1209. done
  1210. fi
  1211. if test "x11_include" != "not found"; then
  1212. if test "$x11_include" = "-I/usr/include"; then
  1213. x11_include=""
  1214. fi
  1215. if ./hasgot $x11_include $x11_link -i X11/Xlib.h XrmInitialize; then
  1216. echo "X11 works"
  1217. else
  1218. echo "Cannot compile X11 program"
  1219. x11_include="not found"
  1220. fi
  1221. fi
  1222. if test "$x11_include" = "not found" || test "$x11_link" = "not found"
  1223. then
  1224. echo "X11 not found, the \"graph\" library will not be supported."
  1225. x11_include="n/a"
  1226. x11_link="n/a"
  1227. else
  1228. echo "Options for compiling for X11: $x11_include"
  1229. echo "Options for linking with X11: $x11_link"
  1230. otherlibraries="$otherlibraries graph"
  1231. fi
  1232. echo "X11_INCLUDES=$x11_include" >> Makefile
  1233. echo "X11_LINK=$x11_link" >> Makefile
  1234. # Look for tcl/tk
  1235. echo "Configuring LablTk..."
  1236. if test $tk_wanted = no; then
  1237. has_tk=false
  1238. elif test $tk_x11 = no; then
  1239. has_tk=true
  1240. elif test "$x11_include" = "not found" || test "$x11_link" = "not found"; then
  1241. echo "X11 not found."
  1242. has_tk=false
  1243. else
  1244. tk_x11_include="$x11_include"
  1245. tk_x11_libs="$x11_libs -lX11"
  1246. has_tk=true
  1247. fi
  1248. if test $has_tk = true; then
  1249. tcl_version=''
  1250. tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
  1251. for tk_incs in \
  1252. "-I/usr/local/include" \
  1253. "-I/usr/include" \
  1254. "-I/usr/local/include/tcl8.5 -I/usr/local/include/tk8.5" \
  1255. "-I/usr/include/tcl8.5 -I/usr/include/tk8.5" \
  1256. "-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4" \
  1257. "-I/usr/include/tcl8.4 -I/usr/include/tk8.4" \
  1258. "-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3" \
  1259. "-I/usr/include/tcl8.3 -I/usr/include/tk8.3" \
  1260. "-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2" \
  1261. "-I/usr/include/tcl8.2 -I/usr/include/tk8.2" \
  1262. "-I/sw/include" \
  1263. "-I/usr/pkg/include"
  1264. do if test -z "$tcl_version"; then
  1265. tk_defs="$tk_incs"
  1266. tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c`
  1267. fi; done
  1268. if test -n "$tcl_version" && test "x$tcl_version" != "xnone"; then
  1269. echo "tcl.h and tk.h version $tcl_version found with \"$tk_defs\"."
  1270. case $tcl_version in
  1271. 8.5) tclmaj=8 tclmin=5 tkmaj=8 tkmin=5 ;;
  1272. 8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;;
  1273. 8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;;
  1274. 8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;;
  1275. 8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;;
  1276. 8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;;
  1277. 7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;;
  1278. 7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;;
  1279. *) echo "This version is not known."; has_tk=false ;;
  1280. esac
  1281. else
  1282. echo "tcl.h and/or tk.h not found."
  1283. has_tk=false
  1284. fi
  1285. fi
  1286. tkauxlibs="$mathlib $dllib"
  1287. tcllib=''
  1288. tklib=''
  1289. if test $has_tk = true; then
  1290. if test -n "$tk_libs" && \
  1291. sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent
  1292. then tk_libs="$tk_libs $dllib"
  1293. elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
  1294. then
  1295. tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
  1296. elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
  1297. then
  1298. tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
  1299. elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \
  1300. sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent
  1301. then
  1302. tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
  1303. elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent
  1304. then
  1305. tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib"
  1306. elif sh ./hasgot -L/sw/lib $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs \
  1307. Tcl_DoOneEvent
  1308. then tk_libs="-L/sw/lib -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib"
  1309. elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs \
  1310. -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs \
  1311. Tcl_DoOneEvent
  1312. then
  1313. case "$host" in
  1314. *-*-*bsd*) tk_libs="-R/usr/pkg/lib -L/usr/pkg/lib $tk_libs $tk_x11_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs";;
  1315. *) tk_libs="-L/usr/pkg/lib $tk_libs $tk_x11_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin -lpthread $tkauxlibs";;
  1316. esac
  1317. else
  1318. echo "Tcl library not found."
  1319. has_tk=false
  1320. fi
  1321. fi
  1322. if test $has_tk = true; then
  1323. if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
  1324. echo "Tcl/Tk libraries found."
  1325. elif sh ./hasgot -L/sw/lib $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then
  1326. case "$host" in
  1327. *-*-*bsd*) tk_libs="-R/sw/lib -L/sw/lib $tk_libs";;
  1328. *) tk_libs="-L/sw/lib $tk_libs";;
  1329. esac
  1330. echo "Tcl/Tk libraries found."
  1331. elif sh ./hasgot -L/usr/pkg/lib $tk_libs $tk_x11_libs $tkauxlibs \
  1332. Tk_SetGrid; then
  1333. case "$host" in
  1334. *-*-*bsd*) tk_libs="-R/usr/pkg/lib -L/usr/pkg/lib $tk_libs";;
  1335. *) tk_libs="-L/usr/pkg/lib $tk_libs";;
  1336. esac
  1337. echo "Tcl/Tk libraries found."
  1338. else
  1339. echo "Tcl library found."
  1340. echo "Tk library not found."
  1341. has_tk=false
  1342. fi
  1343. fi
  1344. if test $has_tk = true; then
  1345. if test $tk_x11 = yes; then
  1346. echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile
  1347. echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile
  1348. else
  1349. echo "TK_DEFS=$tk_defs" >> Makefile
  1350. echo "TK_LINK=$tk_libs" >> Makefile
  1351. fi
  1352. otherlibraries="$otherlibraries labltk"
  1353. else
  1354. echo "Configuration failed, LablTk will not be built."
  1355. echo "TK_DEFS=" >> Makefile
  1356. echo "TK_LINK=" >> Makefile
  1357. fi
  1358. # Look for BFD library
  1359. if ./hasgot -i bfd.h && \
  1360. ./hasgot -lbfd -ldl -liberty -lz bfd_openr; then
  1361. echo "BFD library found."
  1362. echo "#define HAS_LIBBFD" >> s.h
  1363. echo "LIBBFD_LINK=-lbfd -ldl -liberty -lz" >> Makefile
  1364. else
  1365. echo "BFD library not found, 'objinfo' will be unable to display info on .cmxs files"
  1366. echo "LIBBFD_LINK=" >> Makefile
  1367. fi
  1368. # Final twiddling of compiler options to work around known bugs
  1369. nativeccprofopts="$nativecccompopts"
  1370. case "$buggycc" in
  1371. gcc.2.96)
  1372. bytecccompopts="$bytecccompopts -fomit-frame-pointer"
  1373. nativecccompopts="$nativecccompopts -fomit-frame-pointer";;
  1374. esac
  1375. # Finish generated files
  1376. cclibs="$cclibs $mathlib"
  1377. echo "BYTECC=$bytecc" >> Makefile
  1378. echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile
  1379. echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile
  1380. echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link" >> Makefile
  1381. echo "BYTECCRPATH=$byteccrpath" >> Makefile
  1382. echo "EXE=$exe" >> Makefile
  1383. echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile
  1384. echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile
  1385. echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile
  1386. echo "NATDYNLINKOPTS=$natdynlinkopts" >> Makefile
  1387. cat >> Makefile <<EOF
  1388. SYSLIB=-l\$(1)
  1389. #ml let syslib x = "-l"^x;;
  1390. ### How to build a static library
  1391. MKLIB=ar rc \$(1) \$(2); ranlib \$(1)
  1392. #ml let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
  1393. EOF
  1394. echo "ARCH=$arch" >> Makefile
  1395. echo "MODEL=$model" >> Makefile
  1396. echo "SYSTEM=$system" >> Makefile
  1397. echo "NATIVECC=$nativecc" >> Makefile
  1398. echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile
  1399. echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile
  1400. echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile
  1401. echo "NATIVECCRPATH=$nativeccrpath" >> Makefile
  1402. echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile
  1403. echo "ASM=$as" >> Makefile
  1404. echo "ASPP=$aspp" >> Makefile
  1405. echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile
  1406. echo "PROFILING=$profiling" >> Makefile
  1407. echo "DYNLINKOPTS=$dllib" >> Makefile
  1408. echo "OTHERLIBRARIES=$otherlibraries" >> Makefile
  1409. echo "DEBUGGER=$debugger" >> Makefile
  1410. echo "CC_PROFILE=$cc_profile" >> Makefile
  1411. echo "SYSTHREAD_SUPPORT=$systhread_support" >> Makefile
  1412. echo "PARTIALLD=$partialld" >> Makefile
  1413. echo "PACKLD=\$(PARTIALLD) \$(NATIVECCLINKOPTS) -o " \
  1414. | sed -e 's/ $/\\ /' >> Makefile
  1415. echo "DLLCCCOMPOPTS=$dllccompopts" >> Makefile
  1416. echo "IFLEXDIR=$iflexdir" >> Makefile
  1417. echo "O=o" >> Makefile
  1418. echo "A=a" >> Makefile
  1419. echo "SO=so" >> Makefile
  1420. echo "EXT_OBJ=.o" >> Makefile
  1421. echo "EXT_ASM=.s" >> Makefile
  1422. echo "EXT_LIB=.a" >> Makefile
  1423. echo "EXT_DLL=.so" >> Makefile
  1424. echo "EXTRALIBS=" >> Makefile
  1425. echo "CCOMPTYPE=cc" >> Makefile
  1426. echo "TOOLCHAIN=cc" >> Makefile
  1427. echo "NATDYNLINK=$natdynlink" >> Makefile
  1428. echo "CMXS=$cmxs" >> Makefile
  1429. echo "MKEXE=$mkexe" >> Makefile
  1430. echo "MKDLL=$mksharedlib" >> Makefile
  1431. echo "MKMAINDLL=$mkmaindll" >> Makefile
  1432. echo "RUNTIMED=${debugruntime}" >>Makefile
  1433. echo "CAMLP4=${withcamlp4}" >>Makefile
  1434. rm -f tst hasgot.c
  1435. rm -f ../m.h ../s.h ../Makefile
  1436. mv m.h s.h Makefile ..
  1437. # Print a summary
  1438. echo
  1439. echo "** Configuration summary **"
  1440. echo
  1441. echo "Directories where OCaml will be installed:"
  1442. echo " binaries.................. $bindir"
  1443. echo " standard library.......... $libdir"
  1444. echo " manual pages.............. $mandir (with extension .$manext)"
  1445. echo "Configuration for the bytecode compiler:"
  1446. echo " C compiler used........... $bytecc"
  1447. echo " options for compiling..... $bytecccompopts"
  1448. echo " options for linking....... $bytecclinkopts $cclibs $dllib $curseslibs $pthread_link"
  1449. if $shared_libraries_supported; then
  1450. echo " shared libraries are supported"
  1451. echo " options for compiling..... $sharedcccompopts $bytecccompopts"
  1452. echo " command for building...... $mksharedlib -o lib.so $mksharedlibrpath/a/path objs"
  1453. else
  1454. echo " shared libraries not supported"
  1455. fi
  1456. echo "Configuration for the native-code compiler:"
  1457. if test "$arch" = "none"; then
  1458. echo " (not supported on this platform)"
  1459. else
  1460. if test "$model" = "default"; then
  1461. echo " hardware architecture..... $arch"
  1462. else
  1463. echo " hardware architecture..... $arch ($model)"
  1464. fi
  1465. if test "$system"…

Large files files are truncated, but you can click here to view the full file