hppa: Implement TARGET_ATOMIC_ASSIGN_EXPAND_FENV
[official-gcc.git] / libffi / configure.ac
blobc89b2460d7c293e8ce7a9444642eeb0bb8cfe409
1 dnl Process this with autoconf to create configure
3 AC_PREREQ(2.68)
5 AC_INIT([libffi], [3.4.2], [http://github.com/libffi/libffi/issues])
6 AC_CONFIG_HEADERS([fficonfig.h])
8 AM_ENABLE_MULTILIB(, ..)
10 AC_CANONICAL_SYSTEM
11 target_alias=${target_alias-$host_alias}
13 AM_INIT_AUTOMAKE([no-dist])
15 # We would like our source tree to be readonly. However when releases or
16 # pre-releases are generated, the flex/bison generated files as well as the
17 # various formats of manuals need to be included along with the rest of the
18 # sources.  Therefore we have --enable-generated-files-in-srcdir to do
19 # just that.
20 AC_MSG_CHECKING(generated-files-in-srcdir)
21 AC_ARG_ENABLE(generated-files-in-srcdir,
22 AS_HELP_STRING([--enable-generated-files-in-srcdir],
23  [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
24 [case "$enableval" in
25  yes) enable_generated_files_in_srcdir=yes ;;
26  no)  enable_generated_files_in_srcdir=no ;;
27  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
28  esac],
29 [enable_generated_files_in_srcdir=no])
30 AC_MSG_RESULT($enable_generated_files_in_srcdir)
31 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
33 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
34 # We must force CC to /not/ be precious variables; otherwise
35 # the wrong, non-multilib-adjusted value will be used in multilibs.
36 # As a side effect, we have to subst CFLAGS ourselves.
37 # Also save and restore CFLAGS, since AC_PROG_CC will come up with
38 # defaults of its own if none are provided.
40 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
41 m4_define([_AC_ARG_VAR_PRECIOUS],[])
42 save_CFLAGS=$CFLAGS
43 AC_PROG_CC
44 AC_PROG_CXX
45 CFLAGS=$save_CFLAGS
46 m4_undefine([_AC_ARG_VAR_PRECIOUS])
47 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
49 AC_SUBST(CFLAGS)
51 # Add CET specific flags if CET is enabled
52 GCC_CET_FLAGS(CET_FLAGS)
53 AC_SUBST(CET_FLAGS)
55 AM_PROG_AS
56 AM_PROG_CC_C_O
57 AC_PROG_LIBTOOL
58 AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
60 AC_CHECK_TOOL(READELF, readelf)
62 # Test for 64-bit build.
63 AC_CHECK_SIZEOF([size_t])
65 AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
67 cat > local.exp <<EOF
68 set SYSROOT_CFLAGS_FOR_TARGET "$SYSROOT_CFLAGS_FOR_TARGET"
69 set compiler_vendor "$ax_cv_c_compiler_vendor"
70 EOF
72 AM_MAINTAINER_MODE
74 AC_CHECK_HEADERS(sys/memfd.h)
75 AC_CHECK_FUNCS([memfd_create])
77 AC_CHECK_HEADERS(sys/mman.h)
78 AC_CHECK_FUNCS([mmap mkostemp mkstemp])
79 AC_FUNC_MMAP_BLACKLIST
81 dnl The -no-testsuite modules omit the test subdir.
82 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
84 TARGETDIR="unknown"
85 HAVE_LONG_DOUBLE_VARIANT=0
87 . ${srcdir}/configure.host
89 if test -n "${UNSUPPORTED}"; then
90   AC_MSG_ERROR(["libffi has not been ported to $host."])
93 AC_SUBST(AM_RUNTESTFLAGS)
94 AC_SUBST(AM_LTLDFLAGS)
96 AC_HEADER_STDC
97 AC_CHECK_FUNCS(memcpy)
98 AC_FUNC_ALLOCA
100 AC_CHECK_SIZEOF(double)
101 AC_CHECK_SIZEOF(long double)
103 # Also AC_SUBST this variable for ffi.h.
104 if test -z "$HAVE_LONG_DOUBLE"; then
105   HAVE_LONG_DOUBLE=0
106   if test $ac_cv_sizeof_long_double != 0; then
107     if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
108       AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
109       HAVE_LONG_DOUBLE=1
110     else
111       if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
112         HAVE_LONG_DOUBLE=1
113         AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
114       fi
115     fi
116   fi
118 AC_SUBST(HAVE_LONG_DOUBLE)
119 AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
121 AC_C_BIGENDIAN
123 GCC_AS_CFI_PSEUDO_OP
125 case "$TARGET" in
126   SPARC)
127     AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
128         libffi_cv_as_sparc_ua_pcrel, [
129         save_CFLAGS="$CFLAGS"
130         save_LDFLAGS="$LDFLAGS"
131         CFLAGS="$CFLAGS -fpic"
132         LDFLAGS="$LDFLAGS -shared"
133         AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
134                     [libffi_cv_as_sparc_ua_pcrel=yes],
135                     [libffi_cv_as_sparc_ua_pcrel=no])
136         CFLAGS="$save_CFLAGS"
137         LDFLAGS="$save_LDFLAGS"])
138     if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
139         AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
140                   [Define if your assembler and linker support unaligned PC relative relocs.])
141     fi
143     AC_CACHE_CHECK([assembler .register pseudo-op support],
144        libffi_cv_as_register_pseudo_op, [
145        libffi_cv_as_register_pseudo_op=unknown
146        # Check if we have .register
147        AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
148                        [libffi_cv_as_register_pseudo_op=yes],
149                        [libffi_cv_as_register_pseudo_op=no])
150     ])
151     if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
152        AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
153                [Define if your assembler supports .register.])
154     fi
155     ;;
157   X86*)
158     AC_CACHE_CHECK([assembler supports pc related relocs],
159         libffi_cv_as_x86_pcrel, [
160         libffi_cv_as_x86_pcrel=no
161         echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
162         if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
163             libffi_cv_as_x86_pcrel=yes
164         fi
165         ])
166     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
167         AC_DEFINE(HAVE_AS_X86_PCREL, 1,
168                   [Define if your assembler supports PC relative relocs.])
169     fi
170     ;;
172   S390)
173     AC_CACHE_CHECK([compiler uses zarch features],
174         libffi_cv_as_s390_zarch, [
175         libffi_cv_as_s390_zarch=no
176         echo 'void foo(void) { bar(); bar(); }' > conftest.c
177         if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
178             if grep -q brasl conftest.s; then
179                 libffi_cv_as_s390_zarch=yes
180             fi
181         fi
182         ])
183     if test "x$libffi_cv_as_s390_zarch" = xyes; then
184         AC_DEFINE(HAVE_AS_S390_ZARCH, 1,
185                   [Define if the compiler uses zarch features.])
186     fi
187     ;;
188 esac
190 AC_CACHE_CHECK([whether compiler supports pointer authentication],
191    libffi_cv_as_ptrauth, [
192    libffi_cv_as_ptrauth=unknown
193    AC_TRY_COMPILE(,[
194 #ifdef __clang__
195 # if __has_feature(ptrauth_calls)
196 #  define HAVE_PTRAUTH 1
197 # endif
198 #endif
200 #ifndef HAVE_PTRAUTH
201 # error Pointer authentication not supported
202 #endif
203                    ],
204                    [libffi_cv_as_ptrauth=yes],
205                    [libffi_cv_as_ptrauth=no])
207 if test "x$libffi_cv_as_ptrauth" = xyes; then
208     AC_DEFINE(HAVE_PTRAUTH, 1,
209               [Define if your compiler supports pointer authentication.])
212 # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
213 AC_ARG_ENABLE(pax_emutramp,
214   [  --enable-pax_emutramp       enable pax emulated trampolines, for we can't use PROT_EXEC],
215   if test "$enable_pax_emutramp" = "yes"; then
216     AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
217       [Define this if you want to enable pax emulated trampolines])
218   fi)
220 FFI_EXEC_TRAMPOLINE_TABLE=0
221 case "$target" in
222      *arm*-apple-* | aarch64-apple-*)
223        FFI_EXEC_TRAMPOLINE_TABLE=1
224        AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
225                  [Cannot use PROT_EXEC on this target, so, we revert to
226                    alternative means])
227      ;;
228      *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
229        AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
230                  [Cannot use malloc on this target, so, we revert to
231                    alternative means])
232      ;;
233 esac
234 AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
235 AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
237 if test x$TARGET = xX86_64; then
238     AC_CACHE_CHECK([toolchain supports unwind section type],
239         libffi_cv_as_x86_64_unwind_section_type, [
240         cat  > conftest1.s << EOF
241 .text
242 .globl foo
243 foo:
244 jmp bar
245 .section .eh_frame,"a",@unwind
246 bar:
249         cat > conftest2.c  << EOF
250 extern void foo();
251 int main(){foo();}
254         libffi_cv_as_x86_64_unwind_section_type=no
255         # we ensure that we can compile _and_ link an assembly file containing an @unwind section
256         # since the compiler can support it and not the linker (ie old binutils)
257         if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
258            $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
259             libffi_cv_as_x86_64_unwind_section_type=yes
260         fi
261         ])
262     if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
263         AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
264                   [Define if your assembler supports unwind section type.])
265     fi
268 if test "x$GCC" = "xyes"; then
269   AC_CACHE_CHECK([whether .eh_frame section should be read-only],
270       libffi_cv_ro_eh_frame, [
271         libffi_cv_ro_eh_frame=yes
272         echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
273         if $CC $CFLAGS -c -fpic -fexceptions -fno-lto -o conftest.o conftest.c > /dev/null 2>&1; then
274             if $READELF -WS conftest.o | grep -q -n 'eh_frame .* WA'; then
275                 libffi_cv_ro_eh_frame=no
276             fi
277         fi
278         rm -f conftest.*
279       ])
280   if test "x$libffi_cv_ro_eh_frame" = xyes; then
281       AC_DEFINE(HAVE_RO_EH_FRAME, 1,
282               [Define if .eh_frame sections should be read-only.])
283       AC_DEFINE(EH_FRAME_FLAGS, "a",
284               [Define to the flags needed for the .section .eh_frame directive.  ])
285   else
286       AC_DEFINE(EH_FRAME_FLAGS, "aw",
287               [Define to the flags needed for the .section .eh_frame directive.  ])
288   fi
290   AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
291       libffi_cv_hidden_visibility_attribute, [
292         echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1  ; }' > conftest.c
293         libffi_cv_hidden_visibility_attribute=no
294         if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
295             if egrep '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
296                 libffi_cv_hidden_visibility_attribute=yes
297             fi
298         fi
299         rm -f conftest.*
300       ])
301   if test $libffi_cv_hidden_visibility_attribute = yes; then
302       AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
303               [Define if __attribute__((visibility("hidden"))) is supported.])
304   fi
307 # See if makeinfo has been installed and is modern enough
308 # that we can use it.
309 ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
310                    [GNU texinfo.* \([0-9][0-9.]*\)],
311                    [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
312 AM_CONDITIONAL(BUILD_DOCS, test $gcc_cv_prog_makeinfo_modern = "yes")
314 AH_BOTTOM([
315 #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
316 #ifdef LIBFFI_ASM
317 #ifdef __APPLE__
318 #define FFI_HIDDEN(name) .private_extern name
319 #else
320 #define FFI_HIDDEN(name) .hidden name
321 #endif
322 #else
323 #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
324 #endif
325 #else
326 #ifdef LIBFFI_ASM
327 #define FFI_HIDDEN(name)
328 #else
329 #define FFI_HIDDEN
330 #endif
331 #endif
334 AC_SUBST(TARGET)
335 AC_SUBST(TARGETDIR)
337 changequote(<,>)
338 TARGET_OBJ=
339 for i in $SOURCES; do
340   TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'`
341 done
342 changequote([,])
343 AC_SUBST(TARGET_OBJ)
345 AC_SUBST(SHELL)
347 AC_ARG_ENABLE(debug,
348 [  --enable-debug          debugging mode],
349   if test "$enable_debug" = "yes"; then
350     AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
351   fi)
352 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
354 AC_ARG_ENABLE(structs,
355 [  --disable-structs       omit code for struct support],
356   if test "$enable_structs" = "no"; then
357     AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
358   fi)
359 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
361 AC_ARG_ENABLE(raw-api,
362 [  --disable-raw-api       make the raw api unavailable],
363   if test "$enable_raw_api" = "no"; then
364     AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
365   fi)
367 AC_ARG_ENABLE(exec-static-tramp,
368 [  --enable-exec-static-tramp  enable use of static exec trampolines])
370 if test "$enable_exec_static_tramp" = yes; then
371 case "$target" in
372      *-cygwin*)
373      ;;
374      *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-*)
375        AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
376                  [Define this if you want statically defined trampolines])
377      ;;
378 esac
381 AC_ARG_ENABLE(purify-safety,
382 [  --enable-purify-safety  purify-safe mode],
383   if test "$enable_purify_safety" = "yes"; then
384     AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
385   fi)
387 GCC_WITH_TOOLEXECLIBDIR
389 if test -n "$with_cross_host" &&
390    test x"$with_cross_host" != x"no"; then
391   toolexecdir='$(exec_prefix)/$(target_alias)'
392   case ${with_toolexeclibdir} in
393     no)
394       toolexeclibdir='$(toolexecdir)/lib'
395       ;;
396     *)
397       toolexeclibdir=${with_toolexeclibdir}
398       ;;
399   esac
400 else
401   toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
402   toolexeclibdir='$(libdir)'
404 multi_os_directory=`$CC -print-multi-os-directory`
405 case $multi_os_directory in
406   .) ;; # Avoid trailing /.
407   *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
408 esac
409 AC_SUBST(toolexecdir)
410 AC_SUBST(toolexeclibdir)
412 if test "${multilib}" = "yes"; then
413   multilib_arg="--enable-multilib"
414 else
415   multilib_arg=
418 # Check linker support.
419 LIBFFI_ENABLE_SYMVERS
421 # Determine what GCC version number to use in filesystem paths.
422 GCC_BASE_VER
424 AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
425 AC_CONFIG_COMMANDS(src, [
426 test -d src || mkdir src
427 test -d src/$TARGETDIR || mkdir src/$TARGETDIR
428 ], [TARGETDIR="$TARGETDIR"])
430 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
432 AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
434 AC_OUTPUT