]> git.ipfire.org Git - thirdparty/gcc.git/blame - libffi/configure.ac
libffi: Update LOCAL_PATCHES
[thirdparty/gcc.git] / libffi / configure.ac
CommitLineData
63e5e3e0 1dnl Process this with autoconf to create configure
3ed8e5b6 2
92456a4e 3AC_PREREQ(2.68)
3ed8e5b6 4
92456a4e 5AC_INIT([libffi], [3.4.2], [http://github.com/libffi/libffi/issues])
3ed8e5b6
AT
6AC_CONFIG_HEADERS([fficonfig.h])
7
5be7b669
L
8AM_ENABLE_MULTILIB(, ..)
9
bbf3057b
AT
10AC_CANONICAL_SYSTEM
11target_alias=${target_alias-$host_alias}
63e5e3e0 12
5be7b669
L
13AM_INIT_AUTOMAKE([no-dist])
14
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.
20AC_MSG_CHECKING(generated-files-in-srcdir)
21AC_ARG_ENABLE(generated-files-in-srcdir,
22AS_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])
30AC_MSG_RESULT($enable_generated_files_in_srcdir)
31AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
4e70f25f 32
3ed8e5b6
AT
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.
b1760f7f
RH
37# Also save and restore CFLAGS, since AC_PROG_CC will come up with
38# defaults of its own if none are provided.
63e5e3e0 39
3ed8e5b6
AT
40m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
41m4_define([_AC_ARG_VAR_PRECIOUS],[])
b1760f7f 42save_CFLAGS=$CFLAGS
63e5e3e0 43AC_PROG_CC
b1760f7f
RH
44AC_PROG_CXX
45CFLAGS=$save_CFLAGS
46m4_undefine([_AC_ARG_VAR_PRECIOUS])
1b3b24c2 47m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
bbf3057b 48
3ed8e5b6
AT
49AC_SUBST(CFLAGS)
50
333efaea
L
51# Add CET specific flags if CET is enabled
52GCC_CET_FLAGS(CET_FLAGS)
53AC_SUBST(CET_FLAGS)
54
3ed8e5b6
AT
55AM_PROG_AS
56AM_PROG_CC_C_O
63e5e3e0 57AC_PROG_LIBTOOL
92456a4e
L
58
59AC_CHECK_TOOL(READELF, readelf)
63e5e3e0 60
b1760f7f
RH
61# Test for 64-bit build.
62AC_CHECK_SIZEOF([size_t])
63
a0b48358
MR
64cat > local.exp <<EOF
65set CC_FOR_TARGET "$CC"
66set CXX_FOR_TARGET "$CXX"
92456a4e 67set compiler_vendor "$ax_cv_c_compiler_vendor"
a0b48358
MR
68EOF
69
3ed8e5b6
AT
70AM_MAINTAINER_MODE
71
92456a4e
L
72AC_CHECK_HEADERS(sys/memfd.h)
73AC_CHECK_FUNCS([memfd_create])
74
c9b93377 75AC_CHECK_HEADERS(sys/mman.h)
92456a4e 76AC_CHECK_FUNCS([mmap mkostemp mkstemp])
5196736e
AJ
77AC_FUNC_MMAP_BLACKLIST
78
bbf3057b
AT
79dnl The -no-testsuite modules omit the test subdir.
80AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
81
63e5e3e0 82TARGETDIR="unknown"
e73d2479 83HAVE_LONG_DOUBLE_VARIANT=0
63e5e3e0 84
b1760f7f 85. ${srcdir}/configure.host
bbf3057b 86
b1760f7f 87if test -n "${UNSUPPORTED}"; then
3ed8e5b6 88 AC_MSG_ERROR(["libffi has not been ported to $host."])
63e5e3e0
AG
89fi
90
b1760f7f
RH
91AC_SUBST(AM_RUNTESTFLAGS)
92AC_SUBST(AM_LTLDFLAGS)
63e5e3e0
AG
93
94AC_HEADER_STDC
95AC_CHECK_FUNCS(memcpy)
96AC_FUNC_ALLOCA
97
a097ef55
KC
98AC_CHECK_SIZEOF(double)
99AC_CHECK_SIZEOF(long double)
e2f2e70a 100
1450eb7a 101# Also AC_SUBST this variable for ffi.h.
bf8da5fc
RH
102if test -z "$HAVE_LONG_DOUBLE"; then
103 HAVE_LONG_DOUBLE=0
e73d2479
AM
104 if test $ac_cv_sizeof_long_double != 0; then
105 if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
106 AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
bf8da5fc 107 HAVE_LONG_DOUBLE=1
e73d2479
AM
108 else
109 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
110 HAVE_LONG_DOUBLE=1
111 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
112 fi
bf8da5fc 113 fi
1450eb7a
AT
114 fi
115fi
116AC_SUBST(HAVE_LONG_DOUBLE)
e73d2479 117AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
1450eb7a 118
a097ef55 119AC_C_BIGENDIAN
63e5e3e0 120
8b01bdb0 121GCC_AS_CFI_PSEUDO_OP
e6fbf387 122
ed4bf691
RH
123case "$TARGET" in
124 SPARC)
5d84cf0b
JJ
125 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
126 libffi_cv_as_sparc_ua_pcrel, [
127 save_CFLAGS="$CFLAGS"
128 save_LDFLAGS="$LDFLAGS"
129 CFLAGS="$CFLAGS -fpic"
130 LDFLAGS="$LDFLAGS -shared"
131 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
132 [libffi_cv_as_sparc_ua_pcrel=yes],
133 [libffi_cv_as_sparc_ua_pcrel=no])
134 CFLAGS="$save_CFLAGS"
135 LDFLAGS="$save_LDFLAGS"])
136 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
137 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
138 [Define if your assembler and linker support unaligned PC relative relocs.])
139 fi
bd19c9f4
JS
140
141 AC_CACHE_CHECK([assembler .register pseudo-op support],
142 libffi_cv_as_register_pseudo_op, [
143 libffi_cv_as_register_pseudo_op=unknown
144 # Check if we have .register
b1760f7f 145 AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
3ed8e5b6
AT
146 [libffi_cv_as_register_pseudo_op=yes],
147 [libffi_cv_as_register_pseudo_op=no])
bd19c9f4
JS
148 ])
149 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
150 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
3ed8e5b6 151 [Define if your assembler supports .register.])
bd19c9f4 152 fi
ed4bf691 153 ;;
5d84cf0b 154
ed4bf691 155 X86*)
4d3d4078
RO
156 AC_CACHE_CHECK([assembler supports pc related relocs],
157 libffi_cv_as_x86_pcrel, [
b1760f7f 158 libffi_cv_as_x86_pcrel=no
4d3d4078 159 echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
b1760f7f
RH
160 if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
161 libffi_cv_as_x86_pcrel=yes
4d3d4078
RO
162 fi
163 ])
164 if test "x$libffi_cv_as_x86_pcrel" = xyes; then
165 AC_DEFINE(HAVE_AS_X86_PCREL, 1,
166 [Define if your assembler supports PC relative relocs.])
167 fi
ed4bf691 168 ;;
d416abb4 169
ed4bf691 170 S390)
b1760f7f
RH
171 AC_CACHE_CHECK([compiler uses zarch features],
172 libffi_cv_as_s390_zarch, [
173 libffi_cv_as_s390_zarch=no
174 echo 'void foo(void) { bar(); bar(); }' > conftest.c
175 if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
176 if grep -q brasl conftest.s; then
177 libffi_cv_as_s390_zarch=yes
178 fi
179 fi
180 ])
181 if test "x$libffi_cv_as_s390_zarch" = xyes; then
182 AC_DEFINE(HAVE_AS_S390_ZARCH, 1,
183 [Define if the compiler uses zarch features.])
184 fi
ed4bf691
RH
185 ;;
186esac
b1760f7f 187
92456a4e
L
188AC_CACHE_CHECK([whether compiler supports pointer authentication],
189 libffi_cv_as_ptrauth, [
190 libffi_cv_as_ptrauth=unknown
191 AC_TRY_COMPILE(,[
192#ifdef __clang__
193# if __has_feature(ptrauth_calls)
194# define HAVE_PTRAUTH 1
195# endif
196#endif
197
198#ifndef HAVE_PTRAUTH
199# error Pointer authentication not supported
200#endif
201 ],
202 [libffi_cv_as_ptrauth=yes],
203 [libffi_cv_as_ptrauth=no])
204])
205if test "x$libffi_cv_as_ptrauth" = xyes; then
206 AC_DEFINE(HAVE_PTRAUTH, 1,
207 [Define if your compiler supports pointer authentication.])
208fi
209
b4b575ce
AG
210# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
211AC_ARG_ENABLE(pax_emutramp,
212 [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
213 if test "$enable_pax_emutramp" = "yes"; then
214 AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
215 [Define this if you want to enable pax emulated trampolines])
216 fi)
217
218FFI_EXEC_TRAMPOLINE_TABLE=0
99fba2c4 219case "$target" in
92456a4e 220 *arm*-apple-* | aarch64-apple-*)
b4b575ce
AG
221 FFI_EXEC_TRAMPOLINE_TABLE=1
222 AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
223 [Cannot use PROT_EXEC on this target, so, we revert to
224 alternative means])
225 ;;
92456a4e 226 *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
99fba2c4
AT
227 AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
228 [Cannot use malloc on this target, so, we revert to
229 alternative means])
230 ;;
231esac
b4b575ce
AG
232AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
233AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
99fba2c4 234
f4b130bb 235if test x$TARGET = xX86_64; then
b1760f7f 236 AC_CACHE_CHECK([toolchain supports unwind section type],
f4b130bb 237 libffi_cv_as_x86_64_unwind_section_type, [
b1760f7f
RH
238 cat > conftest1.s << EOF
239.text
240.globl foo
241foo:
242jmp bar
243.section .eh_frame,"a",@unwind
244bar:
245EOF
246
247 cat > conftest2.c << EOF
248extern void foo();
249int main(){foo();}
250EOF
251
252 libffi_cv_as_x86_64_unwind_section_type=no
253 # we ensure that we can compile _and_ link an assembly file containing an @unwind section
254 # since the compiler can support it and not the linker (ie old binutils)
255 if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
256 $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
257 libffi_cv_as_x86_64_unwind_section_type=yes
f4b130bb
RO
258 fi
259 ])
260 if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
261 AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
262 [Define if your assembler supports unwind section type.])
263 fi
264fi
265
b4b575ce
AG
266if test "x$GCC" = "xyes"; then
267 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
268 libffi_cv_ro_eh_frame, [
92456a4e 269 libffi_cv_ro_eh_frame=yes
b4b575ce 270 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
5be7b669 271 if $CC $CFLAGS -c -fpic -fexceptions -fno-lto -o conftest.o conftest.c > /dev/null 2>&1; then
92456a4e
L
272 if $READELF -WS conftest.o | grep -q -n 'eh_frame .* WA'; then
273 libffi_cv_ro_eh_frame=no
b1760f7f 274 fi
b4b575ce
AG
275 fi
276 rm -f conftest.*
277 ])
278 if test "x$libffi_cv_ro_eh_frame" = xyes; then
279 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
280 [Define if .eh_frame sections should be read-only.])
281 AC_DEFINE(EH_FRAME_FLAGS, "a",
282 [Define to the flags needed for the .section .eh_frame directive. ])
283 else
284 AC_DEFINE(EH_FRAME_FLAGS, "aw",
285 [Define to the flags needed for the .section .eh_frame directive. ])
286 fi
a733b15e 287
b4b575ce
AG
288 AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
289 libffi_cv_hidden_visibility_attribute, [
290 echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
291 libffi_cv_hidden_visibility_attribute=no
292 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
92456a4e 293 if egrep '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
b4b575ce
AG
294 libffi_cv_hidden_visibility_attribute=yes
295 fi
296 fi
297 rm -f conftest.*
298 ])
299 if test $libffi_cv_hidden_visibility_attribute = yes; then
300 AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
301 [Define if __attribute__((visibility("hidden"))) is supported.])
302 fi
8a42356f
JJ
303fi
304
5be7b669
L
305# See if makeinfo has been installed and is modern enough
306# that we can use it.
307ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
308 [GNU texinfo.* \([0-9][0-9.]*\)],
309 [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
310AM_CONDITIONAL(BUILD_DOCS, test $gcc_cv_prog_makeinfo_modern = "yes")
92456a4e 311
8a42356f
JJ
312AH_BOTTOM([
313#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
314#ifdef LIBFFI_ASM
92456a4e
L
315#ifdef __APPLE__
316#define FFI_HIDDEN(name) .private_extern name
317#else
8a42356f 318#define FFI_HIDDEN(name) .hidden name
92456a4e 319#endif
8a42356f
JJ
320#else
321#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
322#endif
323#else
324#ifdef LIBFFI_ASM
325#define FFI_HIDDEN(name)
326#else
327#define FFI_HIDDEN
328#endif
329#endif
330])
331
63e5e3e0
AG
332AC_SUBST(TARGET)
333AC_SUBST(TARGETDIR)
334
b1760f7f
RH
335changequote(<,>)
336TARGET_OBJ=
337for i in $SOURCES; do
338 TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'`
339done
340changequote([,])
341AC_SUBST(TARGET_OBJ)
342
63e5e3e0
AG
343AC_SUBST(SHELL)
344
7d45b968
JS
345AC_ARG_ENABLE(debug,
346[ --enable-debug debugging mode],
347 if test "$enable_debug" = "yes"; then
1450eb7a 348 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
7d45b968 349 fi)
b4b575ce 350AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
7d45b968
JS
351
352AC_ARG_ENABLE(structs,
353[ --disable-structs omit code for struct support],
354 if test "$enable_structs" = "no"; then
b1760f7f 355 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
7d45b968 356 fi)
b1760f7f 357AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
7d45b968
JS
358
359AC_ARG_ENABLE(raw-api,
360[ --disable-raw-api make the raw api unavailable],
361 if test "$enable_raw_api" = "no"; then
b1760f7f 362 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
7d45b968 363 fi)
63e5e3e0 364
92456a4e 365AC_ARG_ENABLE(exec-static-tramp,
5be7b669 366[ --enable-exec-static-tramp enable use of static exec trampolines])
92456a4e 367
5be7b669 368if test "$enable_exec_static_tramp" = yes; then
92456a4e
L
369case "$target" in
370 *-cygwin*)
371 ;;
372 *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-*)
373 AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
374 [Define this if you want statically defined trampolines])
375 ;;
376esac
377fi
378
63e5e3e0 379AC_ARG_ENABLE(purify-safety,
7d45b968
JS
380[ --enable-purify-safety purify-safe mode],
381 if test "$enable_purify_safety" = "yes"; then
1450eb7a 382 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
7d45b968 383 fi)
0721f64e 384
5be7b669
L
385GCC_WITH_TOOLEXECLIBDIR
386
387if test -n "$with_cross_host" &&
388 test x"$with_cross_host" != x"no"; then
389 toolexecdir='$(exec_prefix)/$(target_alias)'
390 case ${with_toolexeclibdir} in
391 no)
392 toolexeclibdir='$(toolexecdir)/lib'
393 ;;
394 *)
395 toolexeclibdir=${with_toolexeclibdir}
396 ;;
397 esac
0e292c01 398else
5be7b669
L
399 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
400 toolexeclibdir='$(libdir)'
0e292c01 401fi
5be7b669
L
402multi_os_directory=`$CC -print-multi-os-directory`
403case $multi_os_directory in
404 .) ;; # Avoid trailing /.
405 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
406esac
407AC_SUBST(toolexecdir)
0e292c01 408AC_SUBST(toolexeclibdir)
63e5e3e0 409
5be7b669
L
410if test "${multilib}" = "yes"; then
411 multilib_arg="--enable-multilib"
412else
413 multilib_arg=
414fi
415
2c055256 416# Check linker support.
92456a4e 417LIBFFI_ENABLE_SYMVERS
73aa401e 418
5be7b669
L
419# Determine what GCC version number to use in filesystem paths.
420GCC_BASE_VER
421
3ed8e5b6
AT
422AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
423AC_CONFIG_COMMANDS(src, [
3b905056 424test -d src || mkdir src
3ed8e5b6
AT
425test -d src/$TARGETDIR || mkdir src/$TARGETDIR
426], [TARGETDIR="$TARGETDIR"])
427
5be7b669 428AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
1450eb7a 429
5be7b669 430AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
92456a4e 431
5be7b669 432AC_OUTPUT