/Modules/_ctypes/libffi/configure.ac

http://unladen-swallow.googlecode.com/ · m4 · 375 lines · 297 code · 55 blank · 23 comment · 0 complexity · c70f2fb31f42567c26937ba07d9341df MD5 · raw file

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