/js/src/ctypes/libffi/configure.ac

http://github.com/zpao/v8monkey · m4 · 467 lines · 376 code · 64 blank · 27 comment · 0 complexity · 182eebb68e055d996c05f83cf627da3a MD5 · raw file

  1. dnl Process this with autoconf to create configure
  2. AC_PREREQ(2.63)
  3. AC_INIT([libffi], [3.0.10rc0], [http://gcc.gnu.org/bugs.html])
  4. AC_CONFIG_HEADERS([fficonfig.h])
  5. AC_CANONICAL_SYSTEM
  6. target_alias=${target_alias-$host_alias}
  7. . ${srcdir}/configure.host
  8. AM_INIT_AUTOMAKE
  9. # The same as in boehm-gc and libstdc++. Have to borrow it from there.
  10. # We must force CC to /not/ be precious variables; otherwise
  11. # the wrong, non-multilib-adjusted value will be used in multilibs.
  12. # As a side effect, we have to subst CFLAGS ourselves.
  13. # Also save and restore CFLAGS, since AC_PROG_CC will come up with
  14. # defaults of its own if none are provided.
  15. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
  16. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  17. save_CFLAGS=$CFLAGS
  18. AC_PROG_CC
  19. CFLAGS=$save_CFLAGS
  20. m4_undefine([_AC_ARG_VAR_PRECIOUS])
  21. m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  22. AC_SUBST(CFLAGS)
  23. AM_PROG_AS
  24. AM_PROG_CC_C_O
  25. AC_PROG_LIBTOOL
  26. AC_CONFIG_MACRO_DIR([m4])
  27. AM_MAINTAINER_MODE
  28. AC_CHECK_HEADERS(sys/mman.h)
  29. AC_CHECK_FUNCS(mmap)
  30. AC_FUNC_MMAP_BLACKLIST
  31. dnl The -no-testsuite modules omit the test subdir.
  32. AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
  33. TARGETDIR="unknown"
  34. case "$host" in
  35. alpha*-*-*)
  36. TARGET=ALPHA; TARGETDIR=alpha;
  37. # Support 128-bit long double, changeable via command-line switch.
  38. HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
  39. ;;
  40. arm*-*-*)
  41. TARGET=ARM; TARGETDIR=arm
  42. ;;
  43. amd64-*-freebsd* | amd64-*-openbsd*)
  44. TARGET=X86_64; TARGETDIR=x86
  45. ;;
  46. amd64-*-freebsd*)
  47. TARGET=X86_64; TARGETDIR=x86
  48. ;;
  49. avr32*-*-*)
  50. TARGET=AVR32; TARGETDIR=avr32
  51. ;;
  52. cris-*-*)
  53. TARGET=LIBFFI_CRIS; TARGETDIR=cris
  54. ;;
  55. frv-*-*)
  56. TARGET=FRV; TARGETDIR=frv
  57. ;;
  58. hppa*-*-linux* | parisc*-*-linux*)
  59. TARGET=PA_LINUX; TARGETDIR=pa
  60. ;;
  61. hppa*64-*-hpux*)
  62. TARGET=PA64_HPUX; TARGETDIR=pa
  63. ;;
  64. hppa*-*-hpux*)
  65. TARGET=PA_HPUX; TARGETDIR=pa
  66. ;;
  67. i?86-*-freebsd* | i?86-*-openbsd*)
  68. TARGET=X86_FREEBSD; TARGETDIR=x86
  69. ;;
  70. i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
  71. TARGET=X86_WIN32; TARGETDIR=x86
  72. # All mingw/cygwin/win32 builds require this for sharedlib
  73. AM_LTLDFLAGS="-no-undefined"
  74. ;;
  75. i?86-*-darwin*)
  76. TARGET=X86_DARWIN; TARGETDIR=x86
  77. ;;
  78. i?86-*-solaris2.1[[0-9]]*)
  79. TARGET=X86_64; TARGETDIR=x86
  80. ;;
  81. i?86-*-*)
  82. TARGET=X86; TARGETDIR=x86
  83. ;;
  84. ia64*-*-*)
  85. TARGET=IA64; TARGETDIR=ia64
  86. ;;
  87. m32r*-*-*)
  88. TARGET=M32R; TARGETDIR=m32r
  89. ;;
  90. m68k-*-*)
  91. TARGET=M68K; TARGETDIR=m68k
  92. ;;
  93. mips-sgi-irix5.* | mips-sgi-irix6.*)
  94. TARGET=MIPS; TARGETDIR=mips
  95. ;;
  96. mips*-*-linux*)
  97. # Support 128-bit long double for NewABI.
  98. HAVE_LONG_DOUBLE='defined(__mips64)'
  99. TARGET=MIPS; TARGETDIR=mips
  100. ;;
  101. moxie-*-*)
  102. TARGET=MOXIE; TARGETDIR=moxie
  103. ;;
  104. powerpc*-*-linux* | powerpc-*-sysv*)
  105. TARGET=POWERPC; TARGETDIR=powerpc
  106. ;;
  107. powerpc-*-beos*)
  108. TARGET=POWERPC; TARGETDIR=powerpc
  109. ;;
  110. powerpc-*-darwin*)
  111. TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
  112. ;;
  113. powerpc-*-aix* | rs6000-*-aix*)
  114. TARGET=POWERPC_AIX; TARGETDIR=powerpc
  115. ;;
  116. powerpc-*-freebsd*)
  117. TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
  118. ;;
  119. powerpc*-*-rtems*)
  120. TARGET=POWERPC; TARGETDIR=powerpc
  121. ;;
  122. s390-*-* | s390x-*-*)
  123. TARGET=S390; TARGETDIR=s390
  124. ;;
  125. sh-*-* | sh[[34]]*-*-*)
  126. TARGET=SH; TARGETDIR=sh
  127. ;;
  128. sh64-*-* | sh5*-*-*)
  129. TARGET=SH64; TARGETDIR=sh64
  130. ;;
  131. sparc*-*-*)
  132. TARGET=SPARC; TARGETDIR=sparc
  133. ;;
  134. x86_64-*-darwin*)
  135. TARGET=X86_DARWIN; TARGETDIR=x86
  136. ;;
  137. x86_64-*-cygwin* | x86_64-*-mingw*)
  138. TARGET=X86_WIN64; TARGETDIR=x86
  139. ;;
  140. x86_64-*-*)
  141. TARGET=X86_64; TARGETDIR=x86
  142. ;;
  143. esac
  144. AC_SUBST(AM_RUNTESTFLAGS)
  145. AC_SUBST(AM_LTLDFLAGS)
  146. if test $TARGETDIR = unknown; then
  147. AC_MSG_ERROR(["libffi has not been ported to $host."])
  148. fi
  149. AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
  150. AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
  151. AM_CONDITIONAL(X86, test x$TARGET = xX86)
  152. AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
  153. AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
  154. AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
  155. AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
  156. AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
  157. AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
  158. AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
  159. AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
  160. AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
  161. AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
  162. AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
  163. AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
  164. AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
  165. AM_CONDITIONAL(ARM, test x$TARGET = xARM)
  166. AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
  167. AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
  168. AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
  169. AM_CONDITIONAL(S390, test x$TARGET = xS390)
  170. AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
  171. AM_CONDITIONAL(SH, test x$TARGET = xSH)
  172. AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
  173. AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
  174. AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
  175. AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
  176. AC_HEADER_STDC
  177. AC_CHECK_FUNCS(memcpy)
  178. AC_FUNC_ALLOCA
  179. AC_CHECK_SIZEOF(double)
  180. AC_CHECK_SIZEOF(long double)
  181. # Also AC_SUBST this variable for ffi.h.
  182. if test -z "$HAVE_LONG_DOUBLE"; then
  183. HAVE_LONG_DOUBLE=0
  184. if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
  185. if test $ac_cv_sizeof_long_double != 0; then
  186. HAVE_LONG_DOUBLE=1
  187. AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
  188. fi
  189. fi
  190. fi
  191. AC_SUBST(HAVE_LONG_DOUBLE)
  192. AC_C_BIGENDIAN
  193. AC_CACHE_CHECK([assembler .cfi pseudo-op support],
  194. libffi_cv_as_cfi_pseudo_op, [
  195. libffi_cv_as_cfi_pseudo_op=unknown
  196. AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
  197. [libffi_cv_as_cfi_pseudo_op=yes],
  198. [libffi_cv_as_cfi_pseudo_op=no])
  199. ])
  200. if test "x$libffi_cv_as_cfi_pseudo_op" = xyes; then
  201. AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
  202. [Define if your assembler supports .cfi_* directives.])
  203. fi
  204. if test x$TARGET = xSPARC; then
  205. AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
  206. libffi_cv_as_sparc_ua_pcrel, [
  207. save_CFLAGS="$CFLAGS"
  208. save_LDFLAGS="$LDFLAGS"
  209. CFLAGS="$CFLAGS -fpic"
  210. LDFLAGS="$LDFLAGS -shared"
  211. AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
  212. [libffi_cv_as_sparc_ua_pcrel=yes],
  213. [libffi_cv_as_sparc_ua_pcrel=no])
  214. CFLAGS="$save_CFLAGS"
  215. LDFLAGS="$save_LDFLAGS"])
  216. if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
  217. AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
  218. [Define if your assembler and linker support unaligned PC relative relocs.])
  219. fi
  220. AC_CACHE_CHECK([assembler .register pseudo-op support],
  221. libffi_cv_as_register_pseudo_op, [
  222. libffi_cv_as_register_pseudo_op=unknown
  223. # Check if we have .register
  224. AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
  225. [libffi_cv_as_register_pseudo_op=yes],
  226. [libffi_cv_as_register_pseudo_op=no])
  227. ])
  228. if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
  229. AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
  230. [Define if your assembler supports .register.])
  231. fi
  232. fi
  233. if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
  234. AC_CACHE_CHECK([assembler supports pc related relocs],
  235. libffi_cv_as_x86_pcrel, [
  236. libffi_cv_as_x86_pcrel=no
  237. echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
  238. if $CC $CFLAGS -c conftest.s > /dev/null; then
  239. libffi_cv_as_x86_pcrel=yes
  240. fi
  241. ])
  242. if test "x$libffi_cv_as_x86_pcrel" = xyes; then
  243. AC_DEFINE(HAVE_AS_X86_PCREL, 1,
  244. [Define if your assembler supports PC relative relocs.])
  245. fi
  246. AC_CACHE_CHECK([assembler .ascii pseudo-op support],
  247. libffi_cv_as_ascii_pseudo_op, [
  248. libffi_cv_as_ascii_pseudo_op=unknown
  249. # Check if we have .ascii
  250. AC_TRY_COMPILE([asm (".ascii \"string\"");],,
  251. [libffi_cv_as_ascii_pseudo_op=yes],
  252. [libffi_cv_as_ascii_pseudo_op=no])
  253. ])
  254. if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
  255. AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
  256. [Define if your assembler supports .ascii.])
  257. fi
  258. AC_CACHE_CHECK([assembler .string pseudo-op support],
  259. libffi_cv_as_string_pseudo_op, [
  260. libffi_cv_as_string_pseudo_op=unknown
  261. # Check if we have .string
  262. AC_TRY_COMPILE([asm (".string \"string\"");],,
  263. [libffi_cv_as_string_pseudo_op=yes],
  264. [libffi_cv_as_string_pseudo_op=no])
  265. ])
  266. if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
  267. AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
  268. [Define if your assembler supports .string.])
  269. fi
  270. fi
  271. if test x$TARGET = xX86_WIN64; then
  272. LT_SYS_SYMBOL_USCORE
  273. if test "x$sys_symbol_underscore" = xyes; then
  274. AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
  275. fi
  276. fi
  277. case "$target" in
  278. # Darwin 10 (OSX 10.6) and beyond allocate non-executable pages
  279. *-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
  280. AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
  281. [Cannot use malloc on this target, so, we revert to
  282. alternative means])
  283. ;;
  284. esac
  285. if test x$TARGET = xX86_64; then
  286. AC_CACHE_CHECK([assembler supports unwind section type],
  287. libffi_cv_as_x86_64_unwind_section_type, [
  288. libffi_cv_as_x86_64_unwind_section_type=yes
  289. echo '.section .eh_frame,"a",@unwind' > conftest.s
  290. if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
  291. libffi_cv_as_x86_64_unwind_section_type=no
  292. fi
  293. ])
  294. if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
  295. AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
  296. [Define if your assembler supports unwind section type.])
  297. fi
  298. fi
  299. AC_CACHE_CHECK([whether .eh_frame section should be read-only],
  300. libffi_cv_ro_eh_frame, [
  301. libffi_cv_ro_eh_frame=no
  302. echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
  303. if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
  304. if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
  305. libffi_cv_ro_eh_frame=yes
  306. elif grep '.section.*eh_frame.*#alloc' conftest.c \
  307. | grep -v '#write' > /dev/null; then
  308. libffi_cv_ro_eh_frame=yes
  309. fi
  310. fi
  311. rm -f conftest.*
  312. ])
  313. if test "x$libffi_cv_ro_eh_frame" = xyes; then
  314. AC_DEFINE(HAVE_RO_EH_FRAME, 1,
  315. [Define if .eh_frame sections should be read-only.])
  316. AC_DEFINE(EH_FRAME_FLAGS, "a",
  317. [Define to the flags needed for the .section .eh_frame directive.])
  318. else
  319. AC_DEFINE(EH_FRAME_FLAGS, "aw",
  320. [Define to the flags needed for the .section .eh_frame directive.])
  321. fi
  322. AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
  323. libffi_cv_hidden_visibility_attribute, [
  324. echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c
  325. libffi_cv_hidden_visibility_attribute=no
  326. if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
  327. if grep '\.hidden.*foo' conftest.s >/dev/null; then
  328. libffi_cv_hidden_visibility_attribute=yes
  329. fi
  330. fi
  331. rm -f conftest.*
  332. ])
  333. if test $libffi_cv_hidden_visibility_attribute = yes; then
  334. AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
  335. [Define if __attribute__((visibility("hidden"))) is supported.])
  336. fi
  337. AH_BOTTOM([
  338. #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
  339. #ifdef LIBFFI_ASM
  340. #define FFI_HIDDEN(name) .hidden name
  341. #else
  342. #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
  343. #endif
  344. #else
  345. #ifdef LIBFFI_ASM
  346. #define FFI_HIDDEN(name)
  347. #else
  348. #define FFI_HIDDEN
  349. #endif
  350. #endif
  351. ])
  352. AC_SUBST(TARGET)
  353. AC_SUBST(TARGETDIR)
  354. AC_SUBST(SHELL)
  355. AC_ARG_ENABLE(debug,
  356. [ --enable-debug debugging mode],
  357. if test "$enable_debug" = "yes"; then
  358. AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
  359. fi)
  360. AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
  361. AC_ARG_ENABLE(structs,
  362. [ --disable-structs omit code for struct support],
  363. if test "$enable_structs" = "no"; then
  364. AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
  365. fi)
  366. AC_ARG_ENABLE(raw-api,
  367. [ --disable-raw-api make the raw api unavailable],
  368. if test "$enable_raw_api" = "no"; then
  369. AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
  370. fi)
  371. AC_ARG_ENABLE(purify-safety,
  372. [ --enable-purify-safety purify-safe mode],
  373. if test "$enable_purify_safety" = "yes"; then
  374. AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
  375. fi)
  376. if test -n "$with_cross_host" &&
  377. test x"$with_cross_host" != x"no"; then
  378. toolexecdir='$(exec_prefix)/$(target_alias)'
  379. toolexeclibdir='$(toolexecdir)/lib'
  380. else
  381. toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
  382. toolexeclibdir='$(libdir)'
  383. fi
  384. multi_os_directory=`$CC -print-multi-os-directory`
  385. case $multi_os_directory in
  386. .) ;; # Avoid trailing /.
  387. *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  388. esac
  389. AC_SUBST(toolexecdir)
  390. AC_SUBST(toolexeclibdir)
  391. if test "${multilib}" = "yes"; then
  392. multilib_arg="--enable-multilib"
  393. else
  394. multilib_arg=
  395. fi
  396. AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
  397. AC_CONFIG_COMMANDS(src, [
  398. test -d src || mkdir src
  399. test -d src/$TARGETDIR || mkdir src/$TARGETDIR
  400. ], [TARGETDIR="$TARGETDIR"])
  401. AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
  402. AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
  403. AC_OUTPUT