testsuite: Add -Wno-psabi option for ipa-sra-19.c on AIX.
[official-gcc.git] / libffi / configure.ac
blob0bf4af410d3eea0ca0bbf2e9c2785f1de0141a6a
1 dnl Process this with autoconf to create configure
4 AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues])
5 AC_CONFIG_HEADERS([fficonfig.h])
7 AM_ENABLE_MULTILIB(, ..)
9 AC_CANONICAL_SYSTEM
10 target_alias=${target_alias-$host_alias}
12 AM_INIT_AUTOMAKE([no-dist])
14 # See if makeinfo has been installed and is modern enough
15 # that we can use it.
16 ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
17                    [GNU texinfo.* \([0-9][0-9.]*\)],
18                    [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
19 AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
21 # We would like our source tree to be readonly. However when releases or
22 # pre-releases are generated, the flex/bison generated files as well as the
23 # various formats of manuals need to be included along with the rest of the
24 # sources.  Therefore we have --enable-generated-files-in-srcdir to do
25 # just that.
26 AC_MSG_CHECKING(generated-files-in-srcdir)
27 AC_ARG_ENABLE(generated-files-in-srcdir,
28 AS_HELP_STRING([--enable-generated-files-in-srcdir],
29  [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
30 [case "$enableval" in
31  yes) enable_generated_files_in_srcdir=yes ;;
32  no)  enable_generated_files_in_srcdir=no ;;
33  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
34  esac],
35 [enable_generated_files_in_srcdir=no])
36 AC_MSG_RESULT($enable_generated_files_in_srcdir)
37 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
39 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
40 # We must force CC to /not/ be precious variables; otherwise
41 # the wrong, non-multilib-adjusted value will be used in multilibs.
42 # As a side effect, we have to subst CFLAGS ourselves.
43 # Also save and restore CFLAGS, since AC_PROG_CC will come up with
44 # defaults of its own if none are provided.
46 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
47 m4_define([_AC_ARG_VAR_PRECIOUS],[])
48 save_CFLAGS=$CFLAGS
49 AC_PROG_CC
50 AC_PROG_CXX
51 CFLAGS=$save_CFLAGS
52 m4_undefine([_AC_ARG_VAR_PRECIOUS])
53 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
55 AC_SUBST(CFLAGS)
57 AM_PROG_AS
58 AM_PROG_CC_C_O
59 AC_PROG_LIBTOOL
61 # Test for 64-bit build.
62 AC_CHECK_SIZEOF([size_t])
64 cat > local.exp <<EOF
65 set CC_FOR_TARGET "$CC"
66 set CXX_FOR_TARGET "$CXX"
67 EOF
69 AM_MAINTAINER_MODE
71 AC_CHECK_HEADERS(sys/mman.h)
72 AC_CHECK_FUNCS([mmap mkostemp])
73 AC_FUNC_MMAP_BLACKLIST
75 dnl The -no-testsuite modules omit the test subdir.
76 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
78 TARGETDIR="unknown"
79 HAVE_LONG_DOUBLE_VARIANT=0
81 . ${srcdir}/configure.host
83 if test -n "${UNSUPPORTED}"; then
84   AC_MSG_ERROR(["libffi has not been ported to $host."])
87 AC_SUBST(AM_RUNTESTFLAGS)
88 AC_SUBST(AM_LTLDFLAGS)
90 AC_HEADER_STDC
91 AC_CHECK_FUNCS(memcpy)
92 AC_FUNC_ALLOCA
94 AC_CHECK_SIZEOF(double)
95 AC_CHECK_SIZEOF(long double)
97 # Also AC_SUBST this variable for ffi.h.
98 if test -z "$HAVE_LONG_DOUBLE"; then
99   HAVE_LONG_DOUBLE=0
100   if test $ac_cv_sizeof_long_double != 0; then
101     if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
102       AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
103       HAVE_LONG_DOUBLE=1
104     else
105       if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
106         HAVE_LONG_DOUBLE=1
107         AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
108       fi
109     fi
110   fi
112 AC_SUBST(HAVE_LONG_DOUBLE)
113 AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
115 AC_C_BIGENDIAN
117 GCC_AS_CFI_PSEUDO_OP
119 case "$TARGET" in
120   SPARC)
121     AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
122         libffi_cv_as_sparc_ua_pcrel, [
123         save_CFLAGS="$CFLAGS"
124         save_LDFLAGS="$LDFLAGS"
125         CFLAGS="$CFLAGS -fpic"
126         LDFLAGS="$LDFLAGS -shared"
127         AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
128                     [libffi_cv_as_sparc_ua_pcrel=yes],
129                     [libffi_cv_as_sparc_ua_pcrel=no])
130         CFLAGS="$save_CFLAGS"
131         LDFLAGS="$save_LDFLAGS"])
132     if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
133         AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
134                   [Define if your assembler and linker support unaligned PC relative relocs.])
135     fi
137     AC_CACHE_CHECK([assembler .register pseudo-op support],
138        libffi_cv_as_register_pseudo_op, [
139        libffi_cv_as_register_pseudo_op=unknown
140        # Check if we have .register
141        AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
142                        [libffi_cv_as_register_pseudo_op=yes],
143                        [libffi_cv_as_register_pseudo_op=no])
144     ])
145     if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
146        AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
147                [Define if your assembler supports .register.])
148     fi
149     ;;
151   X86*)
152     AC_CACHE_CHECK([assembler supports pc related relocs],
153         libffi_cv_as_x86_pcrel, [
154         libffi_cv_as_x86_pcrel=no
155         echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
156         if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
157             libffi_cv_as_x86_pcrel=yes
158         fi
159         ])
160     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
161         AC_DEFINE(HAVE_AS_X86_PCREL, 1,
162                   [Define if your assembler supports PC relative relocs.])
163     fi
164     ;;
166   S390)
167     AC_CACHE_CHECK([compiler uses zarch features],
168         libffi_cv_as_s390_zarch, [
169         libffi_cv_as_s390_zarch=no
170         echo 'void foo(void) { bar(); bar(); }' > conftest.c
171         if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
172             if grep -q brasl conftest.s; then
173                 libffi_cv_as_s390_zarch=yes
174             fi
175         fi
176         ])
177     if test "x$libffi_cv_as_s390_zarch" = xyes; then
178         AC_DEFINE(HAVE_AS_S390_ZARCH, 1,
179                   [Define if the compiler uses zarch features.])
180     fi
181     ;;
182 esac
184 # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
185 AC_ARG_ENABLE(pax_emutramp,
186   [  --enable-pax_emutramp       enable pax emulated trampolines, for we can't use PROT_EXEC],
187   if test "$enable_pax_emutramp" = "yes"; then
188     AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
189       [Define this if you want to enable pax emulated trampolines])
190   fi)
192 FFI_EXEC_TRAMPOLINE_TABLE=0
193 case "$target" in
194      *arm*-apple-darwin* | aarch64-apple-darwin*)
195        FFI_EXEC_TRAMPOLINE_TABLE=1
196        AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
197                  [Cannot use PROT_EXEC on this target, so, we revert to
198                    alternative means])
199      ;;
200      *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
201        AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
202                  [Cannot use malloc on this target, so, we revert to
203                    alternative means])
204      ;;
205 esac
206 AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
207 AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
209 if test x$TARGET = xX86_64; then
210     AC_CACHE_CHECK([toolchain supports unwind section type],
211         libffi_cv_as_x86_64_unwind_section_type, [
212         cat  > conftest1.s << EOF
213 .text
214 .globl foo
215 foo:
216 jmp bar
217 .section .eh_frame,"a",@unwind
218 bar:
221         cat > conftest2.c  << EOF
222 extern void foo();
223 int main(){foo();}
226         libffi_cv_as_x86_64_unwind_section_type=no
227         # we ensure that we can compile _and_ link an assembly file containing an @unwind section
228         # since the compiler can support it and not the linker (ie old binutils)
229         if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
230            $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
231             libffi_cv_as_x86_64_unwind_section_type=yes
232         fi
233         ])
234     if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
235         AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
236                   [Define if your assembler supports unwind section type.])
237     fi
240 if test "x$GCC" = "xyes"; then
241   AC_CACHE_CHECK([whether .eh_frame section should be read-only],
242       libffi_cv_ro_eh_frame, [
243         libffi_cv_ro_eh_frame=no
244         echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
245         if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
246             objdump -h conftest.o > conftest.dump 2>&1
247             libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
248             if test "x$libffi_eh_frame_line" != "x"; then
249                 libffi_test_line=`expr $libffi_eh_frame_line + 1`p
250                 sed -n $libffi_test_line conftest.dump > conftest.line
251                 if grep READONLY conftest.line > /dev/null; then
252                     libffi_cv_ro_eh_frame=yes
253                 fi
254             fi
255         fi
256         rm -f conftest.*
257       ])
258   if test "x$libffi_cv_ro_eh_frame" = xyes; then
259       AC_DEFINE(HAVE_RO_EH_FRAME, 1,
260               [Define if .eh_frame sections should be read-only.])
261       AC_DEFINE(EH_FRAME_FLAGS, "a",
262               [Define to the flags needed for the .section .eh_frame directive.  ])
263   else
264       AC_DEFINE(EH_FRAME_FLAGS, "aw",
265               [Define to the flags needed for the .section .eh_frame directive.  ])
266   fi
268   AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
269       libffi_cv_hidden_visibility_attribute, [
270         echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1  ; }' > conftest.c
271         libffi_cv_hidden_visibility_attribute=no
272         if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
273             if grep '\.hidden.*foo' conftest.s >/dev/null; then
274                 libffi_cv_hidden_visibility_attribute=yes
275             fi
276         fi
277         rm -f conftest.*
278       ])
279   if test $libffi_cv_hidden_visibility_attribute = yes; then
280       AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
281               [Define if __attribute__((visibility("hidden"))) is supported.])
282   fi
285 AH_BOTTOM([
286 #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
287 #ifdef LIBFFI_ASM
288 #define FFI_HIDDEN(name) .hidden name
289 #else
290 #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
291 #endif
292 #else
293 #ifdef LIBFFI_ASM
294 #define FFI_HIDDEN(name)
295 #else
296 #define FFI_HIDDEN
297 #endif
298 #endif
301 AC_SUBST(TARGET)
302 AC_SUBST(TARGETDIR)
304 changequote(<,>)
305 TARGET_OBJ=
306 for i in $SOURCES; do
307   TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'`
308 done
309 changequote([,])
310 AC_SUBST(TARGET_OBJ)
312 AC_SUBST(SHELL)
314 AC_ARG_ENABLE(debug,
315 [  --enable-debug          debugging mode],
316   if test "$enable_debug" = "yes"; then
317     AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
318   fi)
319 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
321 AC_ARG_ENABLE(structs,
322 [  --disable-structs       omit code for struct support],
323   if test "$enable_structs" = "no"; then
324     AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
325   fi)
326 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
328 AC_ARG_ENABLE(raw-api,
329 [  --disable-raw-api       make the raw api unavailable],
330   if test "$enable_raw_api" = "no"; then
331     AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
332   fi)
334 AC_ARG_ENABLE(purify-safety,
335 [  --enable-purify-safety  purify-safe mode],
336   if test "$enable_purify_safety" = "yes"; then
337     AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
338   fi)
340 GCC_WITH_TOOLEXECLIBDIR
342 if test -n "$with_cross_host" &&
343    test x"$with_cross_host" != x"no"; then
344   toolexecdir='$(exec_prefix)/$(target_alias)'
345   case ${with_toolexeclibdir} in
346     no)
347       toolexeclibdir='$(toolexecdir)/lib'
348       ;;
349     *)
350       toolexeclibdir=${with_toolexeclibdir}
351       ;;
352   esac
353 else
354   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
355   toolexeclibdir='$(libdir)'
357 multi_os_directory=`$CC -print-multi-os-directory`
358 case $multi_os_directory in
359   .) ;; # Avoid trailing /.
360   *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
361 esac
362 AC_SUBST(toolexecdir)
363 AC_SUBST(toolexeclibdir)
365 if test "${multilib}" = "yes"; then
366   multilib_arg="--enable-multilib"
367 else
368   multilib_arg=
371 # Check linker support.
372 LIBAT_ENABLE_SYMVERS
374 # Determine what GCC version number to use in filesystem paths.
375 GCC_BASE_VER
377 AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
378 AC_CONFIG_COMMANDS(src, [
379 test -d src || mkdir src
380 test -d src/$TARGETDIR || mkdir src/$TARGETDIR
381 ], [TARGETDIR="$TARGETDIR"])
383 AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
385 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
387 AC_OUTPUT