1 dnl Process this with autoconf to create configure
5 AC_INIT([libffi], [3.0.11], [http://gcc.gnu.org/bugs.html])
6 AC_CONFIG_HEADERS([fficonfig.h])
8 AM_ENABLE_MULTILIB(, ..)
11 target_alias=${target_alias-$host_alias}
13 . ${srcdir}/configure.host
15 AM_INIT_AUTOMAKE([no-dist])
17 # See if makeinfo has been installed and is modern enough
19 ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
20 [GNU texinfo.* \([0-9][0-9.]*\)],
21 [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
22 AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
24 # We would like our source tree to be readonly. However when releases or
25 # pre-releases are generated, the flex/bison generated files as well as the
26 # various formats of manuals need to be included along with the rest of the
27 # sources. Therefore we have --enable-generated-files-in-srcdir to do
29 AC_MSG_CHECKING(generated-files-in-srcdir)
30 AC_ARG_ENABLE(generated-files-in-srcdir,
31 AS_HELP_STRING([--enable-generated-files-in-srcdir],
32 [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
34 yes) enable_generated_files_in_srcdir=yes ;;
35 no) enable_generated_files_in_srcdir=no ;;
36 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
38 [enable_generated_files_in_srcdir=no])
39 AC_MSG_RESULT($enable_generated_files_in_srcdir)
40 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
42 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
43 # We must force CC to /not/ be precious variables; otherwise
44 # the wrong, non-multilib-adjusted value will be used in multilibs.
45 # As a side effect, we have to subst CFLAGS ourselves.
47 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
48 m4_define([_AC_ARG_VAR_PRECIOUS],[])
50 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
60 AC_CHECK_HEADERS(sys/mman.h)
62 AC_FUNC_MMAP_BLACKLIST
64 dnl The -no-testsuite modules omit the test subdir.
65 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
68 HAVE_LONG_DOUBLE_VARIANT=0
71 TARGET=AARCH64; TARGETDIR=aarch64
75 TARGET=ALPHA; TARGETDIR=alpha;
76 # Support 128-bit long double, changeable via command-line switch.
77 HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
81 TARGET=ARM; TARGETDIR=arm
84 amd64-*-freebsd* | amd64-*-openbsd*)
85 TARGET=X86_64; TARGETDIR=x86
89 TARGET=X86_64; TARGETDIR=x86
93 TARGET=AVR32; TARGETDIR=avr32
97 TARGET=BFIN; TARGETDIR=bfin
101 TARGET=LIBFFI_CRIS; TARGETDIR=cris
105 TARGET=FRV; TARGETDIR=frv
108 hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
109 TARGET=PA_LINUX; TARGETDIR=pa
112 TARGET=PA64_HPUX; TARGETDIR=pa
115 TARGET=PA_HPUX; TARGETDIR=pa
118 i?86-*-freebsd* | i?86-*-openbsd*)
119 TARGET=X86_FREEBSD; TARGETDIR=x86
121 i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
122 TARGET=X86_WIN32; TARGETDIR=x86
123 # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
124 # We must also check with_cross_host to decide if this is a native
125 # or cross-build and select where to install dlls appropriately.
126 if test -n "$with_cross_host" &&
127 test x"$with_cross_host" != x"no"; then
128 AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
130 AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
134 TARGET=X86_DARWIN; TARGETDIR=x86
136 i?86-*-solaris2.1[[0-9]]*)
137 TARGET=X86_64; TARGETDIR=x86
140 TARGET=X86_64; TARGETDIR=x86
144 TARGET=IA64; TARGETDIR=ia64
148 TARGET=M32R; TARGETDIR=m32r
152 TARGET=M68K; TARGETDIR=m68k
155 mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
156 TARGET=MIPS; TARGETDIR=mips
158 mips*-*-linux* | mips*-*-openbsd*)
159 # Support 128-bit long double for NewABI.
160 HAVE_LONG_DOUBLE='defined(__mips64)'
161 TARGET=MIPS; TARGETDIR=mips
164 powerpc*-*-linux* | powerpc-*-sysv*)
165 TARGET=POWERPC; TARGETDIR=powerpc
166 HAVE_LONG_DOUBLE_VARIANT=1
169 TARGET=POWERPC; TARGETDIR=powerpc
172 TARGET=POWERPC; TARGETDIR=powerpc
174 powerpc-*-darwin* | powerpc64-*-darwin*)
175 TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
177 powerpc-*-aix* | rs6000-*-aix*)
178 TARGET=POWERPC_AIX; TARGETDIR=powerpc
180 powerpc-*-freebsd* | powerpc-*-openbsd*)
181 TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
182 HAVE_LONG_DOUBLE_VARIANT=1
184 powerpc64-*-freebsd*)
185 TARGET=POWERPC; TARGETDIR=powerpc
188 TARGET=POWERPC; TARGETDIR=powerpc
191 s390-*-* | s390x-*-*)
192 TARGET=S390; TARGETDIR=s390
195 sh-*-* | sh[[34]]*-*-*)
196 TARGET=SH; TARGETDIR=sh
199 TARGET=SH64; TARGETDIR=sh64
203 TARGET=SPARC; TARGETDIR=sparc
207 TARGET=TILE; TARGETDIR=tile
211 TARGET=X86_DARWIN; TARGETDIR=x86
214 x86_64-*-cygwin* | x86_64-*-mingw*)
215 TARGET=X86_WIN64; TARGETDIR=x86
216 # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
217 # We must also check with_cross_host to decide if this is a native
218 # or cross-build and select where to install dlls appropriately.
219 if test -n "$with_cross_host" &&
220 test x"$with_cross_host" != x"no"; then
221 AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
223 AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
228 TARGET=X86_64; TARGETDIR=x86
232 AC_SUBST(AM_RUNTESTFLAGS)
233 AC_SUBST(AM_LTLDFLAGS)
235 if test $TARGETDIR = unknown; then
236 AC_MSG_ERROR(["libffi has not been ported to $host."])
239 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
240 AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
241 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
242 AM_CONDITIONAL(X86, test x$TARGET = xX86)
243 AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
244 AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
245 AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
246 AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
247 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
248 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
249 AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
250 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
251 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
252 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
253 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
254 AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
255 AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
256 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
257 AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
258 AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
259 AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
260 AM_CONDITIONAL(S390, test x$TARGET = xS390)
261 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
262 AM_CONDITIONAL(SH, test x$TARGET = xSH)
263 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
264 AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
265 AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
266 AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
267 AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
270 AC_CHECK_FUNCS(memcpy)
273 AC_CHECK_SIZEOF(double)
274 AC_CHECK_SIZEOF(long double)
276 # Also AC_SUBST this variable for ffi.h.
277 if test -z "$HAVE_LONG_DOUBLE"; then
279 if test $ac_cv_sizeof_long_double != 0; then
280 if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
281 AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
284 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
286 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
291 AC_SUBST(HAVE_LONG_DOUBLE)
292 AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
298 AC_CACHE_CHECK([if compiler supports -Qunused-arguments],
299 [libffi_cv_c_unused_arguments],
301 CFLAGS="$CFLAGS -Qunused-arguments"
302 AC_COMPILE_IFELSE([[int i;]],
303 [libffi_cv_c_unused_arguments=yes],
304 [libffi_cv_c_unused_arguments=no])
305 CFLAGS=$CFLAGS_hold])
307 if test x$TARGET = xSPARC; then
308 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
309 libffi_cv_as_sparc_ua_pcrel, [
310 save_CFLAGS="$CFLAGS"
311 save_LDFLAGS="$LDFLAGS"
312 CFLAGS="$CFLAGS -fpic"
313 LDFLAGS="$LDFLAGS -shared"
314 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
315 [libffi_cv_as_sparc_ua_pcrel=yes],
316 [libffi_cv_as_sparc_ua_pcrel=no])
317 CFLAGS="$save_CFLAGS"
318 LDFLAGS="$save_LDFLAGS"])
319 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
320 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
321 [Define if your assembler and linker support unaligned PC relative relocs.])
324 AC_CACHE_CHECK([assembler .register pseudo-op support],
325 libffi_cv_as_register_pseudo_op, [
326 libffi_cv_as_register_pseudo_op=unknown
327 # Check if we have .register
328 AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
329 [libffi_cv_as_register_pseudo_op=yes],
330 [libffi_cv_as_register_pseudo_op=no])
332 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
333 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
334 [Define if your assembler supports .register.])
338 if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
339 AC_CACHE_CHECK([assembler supports pc related relocs],
340 libffi_cv_as_x86_pcrel, [
341 libffi_cv_as_x86_pcrel=yes
342 echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
344 if test "$libffi_cv_c_unused_arguments" = yes; then
345 CFLAGS="$CFLAGS -Qunused-arguments"
347 if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then
348 libffi_cv_as_x86_pcrel=no
352 if test "x$libffi_cv_as_x86_pcrel" = xyes; then
353 AC_DEFINE(HAVE_AS_X86_PCREL, 1,
354 [Define if your assembler supports PC relative relocs.])
357 AC_CACHE_CHECK([assembler .ascii pseudo-op support],
358 libffi_cv_as_ascii_pseudo_op, [
359 libffi_cv_as_ascii_pseudo_op=unknown
360 # Check if we have .ascii
361 AC_TRY_COMPILE([asm (".ascii \\"string\\"");],,
362 [libffi_cv_as_ascii_pseudo_op=yes],
363 [libffi_cv_as_ascii_pseudo_op=no])
365 if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
366 AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
367 [Define if your assembler supports .ascii.])
370 AC_CACHE_CHECK([assembler .string pseudo-op support],
371 libffi_cv_as_string_pseudo_op, [
372 libffi_cv_as_string_pseudo_op=unknown
373 # Check if we have .string
374 AC_TRY_COMPILE([asm (".string \\"string\\"");],,
375 [libffi_cv_as_string_pseudo_op=yes],
376 [libffi_cv_as_string_pseudo_op=no])
378 if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
379 AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
380 [Define if your assembler supports .string.])
384 # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
385 AC_ARG_ENABLE(pax_emutramp,
386 [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
387 if test "$enable_pax_emutramp" = "yes"; then
388 AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
389 [Define this if you want to enable pax emulated trampolines])
392 FFI_EXEC_TRAMPOLINE_TABLE=0
395 FFI_EXEC_TRAMPOLINE_TABLE=1
396 AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
397 [Cannot use PROT_EXEC on this target, so, we revert to
400 *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
401 AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
402 [Cannot use malloc on this target, so, we revert to
406 AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
407 AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
409 if test x$TARGET = xX86_64; then
410 AC_CACHE_CHECK([assembler supports unwind section type],
411 libffi_cv_as_x86_64_unwind_section_type, [
412 libffi_cv_as_x86_64_unwind_section_type=yes
413 echo '.section .eh_frame,"a",@unwind' > conftest.s
415 if test "$libffi_cv_c_unused_arguments" = yes; then
416 CFLAGS="$CFLAGS -Qunused-arguments"
418 if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
419 libffi_cv_as_x86_64_unwind_section_type=no
423 if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
424 AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
425 [Define if your assembler supports unwind section type.])
429 if test "x$GCC" = "xyes"; then
430 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
431 libffi_cv_ro_eh_frame, [
432 libffi_cv_ro_eh_frame=no
433 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
434 if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
435 if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
436 libffi_cv_ro_eh_frame=yes
437 elif grep '.section.*eh_frame.*#alloc' conftest.c \
438 | grep -v '#write' > /dev/null; then
439 libffi_cv_ro_eh_frame=yes
444 if test "x$libffi_cv_ro_eh_frame" = xyes; then
445 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
446 [Define if .eh_frame sections should be read-only.])
447 AC_DEFINE(EH_FRAME_FLAGS, "a",
448 [Define to the flags needed for the .section .eh_frame directive. ])
450 AC_DEFINE(EH_FRAME_FLAGS, "aw",
451 [Define to the flags needed for the .section .eh_frame directive. ])
454 AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
455 libffi_cv_hidden_visibility_attribute, [
456 echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
457 libffi_cv_hidden_visibility_attribute=no
458 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
459 if grep '\.hidden.*foo' conftest.s >/dev/null; then
460 libffi_cv_hidden_visibility_attribute=yes
465 if test $libffi_cv_hidden_visibility_attribute = yes; then
466 AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
467 [Define if __attribute__((visibility("hidden"))) is supported.])
472 #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
474 #define FFI_HIDDEN(name) .hidden name
476 #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
480 #define FFI_HIDDEN(name)
493 [ --enable-debug debugging mode],
494 if test "$enable_debug" = "yes"; then
495 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
497 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
499 AC_ARG_ENABLE(structs,
500 [ --disable-structs omit code for struct support],
501 if test "$enable_structs" = "no"; then
502 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
505 AC_ARG_ENABLE(raw-api,
506 [ --disable-raw-api make the raw api unavailable],
507 if test "$enable_raw_api" = "no"; then
508 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
511 AC_ARG_ENABLE(purify-safety,
512 [ --enable-purify-safety purify-safe mode],
513 if test "$enable_purify_safety" = "yes"; then
514 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
517 if test -n "$with_cross_host" &&
518 test x"$with_cross_host" != x"no"; then
519 toolexecdir='$(exec_prefix)/$(target_alias)'
520 toolexeclibdir='$(toolexecdir)/lib'
522 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
523 toolexeclibdir='$(libdir)'
525 multi_os_directory=`$CC -print-multi-os-directory`
526 case $multi_os_directory in
527 .) ;; # Avoid trailing /.
528 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
530 AC_SUBST(toolexecdir)
531 AC_SUBST(toolexeclibdir)
533 if test "${multilib}" = "yes"; then
534 multilib_arg="--enable-multilib"
539 AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
540 AC_CONFIG_COMMANDS(src, [
541 test -d src || mkdir src
542 test -d src/$TARGETDIR || mkdir src/$TARGETDIR
543 ], [TARGETDIR="$TARGETDIR"])
545 AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
547 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile)