]> git.ipfire.org Git - thirdparty/gcc.git/blame - libffi/configure.ac
Fix tests for std::variant to match original intention
[thirdparty/gcc.git] / libffi / configure.ac
CommitLineData
47c5fab6 1dnl Process this with autoconf to create configure
b375837d 2
b375837d 3
89d8a412 4AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues])
b375837d 5AC_CONFIG_HEADERS([fficonfig.h])
6
7AM_ENABLE_MULTILIB(, ..)
3b43a26e 8
3743c332 9AC_CANONICAL_SYSTEM
10target_alias=${target_alias-$host_alias}
47c5fab6 11
2b536a17 12AM_INIT_AUTOMAKE([no-dist])
47c5fab6 13
8cd092c9 14# See if makeinfo has been installed and is modern enough
15# that we can use it.
16ACX_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]*])
19AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
20
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.
26AC_MSG_CHECKING(generated-files-in-srcdir)
27AC_ARG_ENABLE(generated-files-in-srcdir,
28AS_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])
36AC_MSG_RESULT($enable_generated_files_in_srcdir)
37AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
38
b375837d 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.
89d8a412 43# Also save and restore CFLAGS, since AC_PROG_CC will come up with
44# defaults of its own if none are provided.
47c5fab6 45
b375837d 46m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
47m4_define([_AC_ARG_VAR_PRECIOUS],[])
89d8a412 48save_CFLAGS=$CFLAGS
47c5fab6 49AC_PROG_CC
89d8a412 50AC_PROG_CXX
51CFLAGS=$save_CFLAGS
52m4_undefine([_AC_ARG_VAR_PRECIOUS])
9abe4a66 53m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
3743c332 54
b375837d 55AC_SUBST(CFLAGS)
56
57AM_PROG_AS
58AM_PROG_CC_C_O
47c5fab6 59AC_PROG_LIBTOOL
60
89d8a412 61# Test for 64-bit build.
62AC_CHECK_SIZEOF([size_t])
63
b375837d 64AM_MAINTAINER_MODE
65
2be99030 66AC_CHECK_HEADERS(sys/mman.h)
89d8a412 67AC_CHECK_FUNCS([mmap mkostemp])
e7f352cc 68AC_FUNC_MMAP_BLACKLIST
69
3743c332 70dnl The -no-testsuite modules omit the test subdir.
71AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
72
47c5fab6 73TARGETDIR="unknown"
f7d6f268 74HAVE_LONG_DOUBLE_VARIANT=0
47c5fab6 75
89d8a412 76. ${srcdir}/configure.host
3743c332 77
89d8a412 78if test -n "${UNSUPPORTED}"; then
b375837d 79 AC_MSG_ERROR(["libffi has not been ported to $host."])
47c5fab6 80fi
81
89d8a412 82AC_SUBST(AM_RUNTESTFLAGS)
83AC_SUBST(AM_LTLDFLAGS)
47c5fab6 84
85AC_HEADER_STDC
86AC_CHECK_FUNCS(memcpy)
87AC_FUNC_ALLOCA
88
69738b31 89AC_CHECK_SIZEOF(double)
90AC_CHECK_SIZEOF(long double)
ed35b400 91
3d37e05c 92# Also AC_SUBST this variable for ffi.h.
ea4d299a 93if test -z "$HAVE_LONG_DOUBLE"; then
94 HAVE_LONG_DOUBLE=0
f7d6f268 95 if test $ac_cv_sizeof_long_double != 0; then
96 if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
97 AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
ea4d299a 98 HAVE_LONG_DOUBLE=1
f7d6f268 99 else
100 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
101 HAVE_LONG_DOUBLE=1
102 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
103 fi
ea4d299a 104 fi
3d37e05c 105 fi
106fi
107AC_SUBST(HAVE_LONG_DOUBLE)
f7d6f268 108AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
3d37e05c 109
69738b31 110AC_C_BIGENDIAN
47c5fab6 111
022a1701 112GCC_AS_CFI_PSEUDO_OP
a53add80 113
14c010b9 114case "$TARGET" in
115 SPARC)
b40c762b 116 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
117 libffi_cv_as_sparc_ua_pcrel, [
118 save_CFLAGS="$CFLAGS"
119 save_LDFLAGS="$LDFLAGS"
120 CFLAGS="$CFLAGS -fpic"
121 LDFLAGS="$LDFLAGS -shared"
122 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
123 [libffi_cv_as_sparc_ua_pcrel=yes],
124 [libffi_cv_as_sparc_ua_pcrel=no])
125 CFLAGS="$save_CFLAGS"
126 LDFLAGS="$save_LDFLAGS"])
127 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
128 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
129 [Define if your assembler and linker support unaligned PC relative relocs.])
130 fi
f3bd7a2c 131
132 AC_CACHE_CHECK([assembler .register pseudo-op support],
133 libffi_cv_as_register_pseudo_op, [
134 libffi_cv_as_register_pseudo_op=unknown
135 # Check if we have .register
89d8a412 136 AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
b375837d 137 [libffi_cv_as_register_pseudo_op=yes],
138 [libffi_cv_as_register_pseudo_op=no])
f3bd7a2c 139 ])
140 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
141 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
b375837d 142 [Define if your assembler supports .register.])
f3bd7a2c 143 fi
14c010b9 144 ;;
b40c762b 145
14c010b9 146 X86*)
95ff4d7d 147 AC_CACHE_CHECK([assembler supports pc related relocs],
148 libffi_cv_as_x86_pcrel, [
89d8a412 149 libffi_cv_as_x86_pcrel=no
95ff4d7d 150 echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
89d8a412 151 if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
152 libffi_cv_as_x86_pcrel=yes
95ff4d7d 153 fi
154 ])
155 if test "x$libffi_cv_as_x86_pcrel" = xyes; then
156 AC_DEFINE(HAVE_AS_X86_PCREL, 1,
157 [Define if your assembler supports PC relative relocs.])
158 fi
14c010b9 159 ;;
40ae1f19 160
14c010b9 161 S390)
89d8a412 162 AC_CACHE_CHECK([compiler uses zarch features],
163 libffi_cv_as_s390_zarch, [
164 libffi_cv_as_s390_zarch=no
165 echo 'void foo(void) { bar(); bar(); }' > conftest.c
166 if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
167 if grep -q brasl conftest.s; then
168 libffi_cv_as_s390_zarch=yes
169 fi
170 fi
171 ])
172 if test "x$libffi_cv_as_s390_zarch" = xyes; then
173 AC_DEFINE(HAVE_AS_S390_ZARCH, 1,
174 [Define if the compiler uses zarch features.])
175 fi
14c010b9 176 ;;
177esac
89d8a412 178
a65f362a 179# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
180AC_ARG_ENABLE(pax_emutramp,
181 [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
182 if test "$enable_pax_emutramp" = "yes"; then
183 AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
184 [Define this if you want to enable pax emulated trampolines])
185 fi)
186
187FFI_EXEC_TRAMPOLINE_TABLE=0
3531d81f 188case "$target" in
14c010b9 189 *arm*-apple-darwin* | aarch64-apple-darwin*)
a65f362a 190 FFI_EXEC_TRAMPOLINE_TABLE=1
191 AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
192 [Cannot use PROT_EXEC on this target, so, we revert to
193 alternative means])
194 ;;
195 *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
3531d81f 196 AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
197 [Cannot use malloc on this target, so, we revert to
198 alternative means])
199 ;;
200esac
a65f362a 201AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
202AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
3531d81f 203
5ed988d2 204if test x$TARGET = xX86_64; then
89d8a412 205 AC_CACHE_CHECK([toolchain supports unwind section type],
5ed988d2 206 libffi_cv_as_x86_64_unwind_section_type, [
89d8a412 207 cat > conftest1.s << EOF
208.text
209.globl foo
210foo:
211jmp bar
212.section .eh_frame,"a",@unwind
213bar:
214EOF
215
216 cat > conftest2.c << EOF
217extern void foo();
218int main(){foo();}
219EOF
220
221 libffi_cv_as_x86_64_unwind_section_type=no
222 # we ensure that we can compile _and_ link an assembly file containing an @unwind section
223 # since the compiler can support it and not the linker (ie old binutils)
224 if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
225 $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
226 libffi_cv_as_x86_64_unwind_section_type=yes
5ed988d2 227 fi
228 ])
229 if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
230 AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
231 [Define if your assembler supports unwind section type.])
232 fi
233fi
234
a65f362a 235if test "x$GCC" = "xyes"; then
236 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
237 libffi_cv_ro_eh_frame, [
238 libffi_cv_ro_eh_frame=no
239 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
89d8a412 240 if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
241 objdump -h conftest.o > conftest.dump 2>&1
242 libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
243 if test "x$libffi_eh_frame_line" != "x"; then
244 libffi_test_line=`expr $libffi_eh_frame_line + 1`p
245 sed -n $libffi_test_line conftest.dump > conftest.line
246 if grep READONLY conftest.line > /dev/null; then
247 libffi_cv_ro_eh_frame=yes
248 fi
249 fi
a65f362a 250 fi
251 rm -f conftest.*
252 ])
253 if test "x$libffi_cv_ro_eh_frame" = xyes; then
254 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
255 [Define if .eh_frame sections should be read-only.])
256 AC_DEFINE(EH_FRAME_FLAGS, "a",
257 [Define to the flags needed for the .section .eh_frame directive. ])
258 else
259 AC_DEFINE(EH_FRAME_FLAGS, "aw",
260 [Define to the flags needed for the .section .eh_frame directive. ])
261 fi
1da888ec 262
a65f362a 263 AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
264 libffi_cv_hidden_visibility_attribute, [
265 echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
266 libffi_cv_hidden_visibility_attribute=no
267 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
268 if grep '\.hidden.*foo' conftest.s >/dev/null; then
269 libffi_cv_hidden_visibility_attribute=yes
270 fi
271 fi
272 rm -f conftest.*
273 ])
274 if test $libffi_cv_hidden_visibility_attribute = yes; then
275 AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
276 [Define if __attribute__((visibility("hidden"))) is supported.])
277 fi
33b4ca90 278fi
279
280AH_BOTTOM([
281#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
282#ifdef LIBFFI_ASM
283#define FFI_HIDDEN(name) .hidden name
284#else
285#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
286#endif
287#else
288#ifdef LIBFFI_ASM
289#define FFI_HIDDEN(name)
290#else
291#define FFI_HIDDEN
292#endif
293#endif
294])
295
47c5fab6 296AC_SUBST(TARGET)
297AC_SUBST(TARGETDIR)
298
89d8a412 299changequote(<,>)
300TARGET_OBJ=
301for i in $SOURCES; do
302 TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'`
303done
304changequote([,])
305AC_SUBST(TARGET_OBJ)
306
47c5fab6 307AC_SUBST(SHELL)
308
070883fe 309AC_ARG_ENABLE(debug,
310[ --enable-debug debugging mode],
311 if test "$enable_debug" = "yes"; then
3d37e05c 312 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
070883fe 313 fi)
a65f362a 314AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
070883fe 315
316AC_ARG_ENABLE(structs,
317[ --disable-structs omit code for struct support],
318 if test "$enable_structs" = "no"; then
89d8a412 319 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
070883fe 320 fi)
89d8a412 321AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
070883fe 322
323AC_ARG_ENABLE(raw-api,
324[ --disable-raw-api make the raw api unavailable],
325 if test "$enable_raw_api" = "no"; then
89d8a412 326 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
070883fe 327 fi)
47c5fab6 328
329AC_ARG_ENABLE(purify-safety,
070883fe 330[ --enable-purify-safety purify-safe mode],
331 if test "$enable_purify_safety" = "yes"; then
3d37e05c 332 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
070883fe 333 fi)
9573c665 334
c8d4fa8c 335if test -n "$with_cross_host" &&
336 test x"$with_cross_host" != x"no"; then
337 toolexecdir='$(exec_prefix)/$(target_alias)'
338 toolexeclibdir='$(toolexecdir)/lib'
339else
340 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
341 toolexeclibdir='$(libdir)'
342fi
777bb3dc 343multi_os_directory=`$CC -print-multi-os-directory`
344case $multi_os_directory in
345 .) ;; # Avoid trailing /.
346 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
347esac
c8d4fa8c 348AC_SUBST(toolexecdir)
349AC_SUBST(toolexeclibdir)
47c5fab6 350
3b43a26e 351if test "${multilib}" = "yes"; then
352 multilib_arg="--enable-multilib"
353else
354 multilib_arg=
355fi
356
86d5c70d 357# Check linker support.
358LIBAT_ENABLE_SYMVERS
359
602de845 360# Determine what GCC version number to use in filesystem paths.
361GCC_BASE_VER
362
b375837d 363AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
364AC_CONFIG_COMMANDS(src, [
9461b350 365test -d src || mkdir src
b375837d 366test -d src/$TARGETDIR || mkdir src/$TARGETDIR
367], [TARGETDIR="$TARGETDIR"])
368
369AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
370
89d8a412 371AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
3d37e05c 372
b375837d 373AC_OUTPUT