]>
Commit | Line | Data |
---|---|---|
63e5e3e0 | 1 | dnl Process this with autoconf to create configure |
3ed8e5b6 | 2 | |
df58e648 | 3 | AC_PREREQ(2.64) |
3ed8e5b6 | 4 | |
b1760f7f | 5 | AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues]) |
3ed8e5b6 AT |
6 | AC_CONFIG_HEADERS([fficonfig.h]) |
7 | ||
8 | AM_ENABLE_MULTILIB(, ..) | |
3c18f2d1 | 9 | |
bbf3057b AT |
10 | AC_CANONICAL_SYSTEM |
11 | target_alias=${target_alias-$host_alias} | |
63e5e3e0 | 12 | |
f7468577 | 13 | AM_INIT_AUTOMAKE([no-dist]) |
63e5e3e0 | 14 | |
4e70f25f AS |
15 | # See if makeinfo has been installed and is modern enough |
16 | # that we can use it. | |
17 | ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version], | |
18 | [GNU texinfo.* \([0-9][0-9.]*\)], | |
19 | [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*]) | |
20 | AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes") | |
21 | ||
22 | # We would like our source tree to be readonly. However when releases or | |
23 | # pre-releases are generated, the flex/bison generated files as well as the | |
24 | # various formats of manuals need to be included along with the rest of the | |
25 | # sources. Therefore we have --enable-generated-files-in-srcdir to do | |
26 | # just that. | |
27 | AC_MSG_CHECKING(generated-files-in-srcdir) | |
28 | AC_ARG_ENABLE(generated-files-in-srcdir, | |
29 | AS_HELP_STRING([--enable-generated-files-in-srcdir], | |
30 | [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]), | |
31 | [case "$enableval" in | |
32 | yes) enable_generated_files_in_srcdir=yes ;; | |
33 | no) enable_generated_files_in_srcdir=no ;; | |
34 | *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; | |
35 | esac], | |
36 | [enable_generated_files_in_srcdir=no]) | |
37 | AC_MSG_RESULT($enable_generated_files_in_srcdir) | |
38 | AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) | |
39 | ||
3ed8e5b6 AT |
40 | # The same as in boehm-gc and libstdc++. Have to borrow it from there. |
41 | # We must force CC to /not/ be precious variables; otherwise | |
42 | # the wrong, non-multilib-adjusted value will be used in multilibs. | |
43 | # As a side effect, we have to subst CFLAGS ourselves. | |
b1760f7f RH |
44 | # Also save and restore CFLAGS, since AC_PROG_CC will come up with |
45 | # defaults of its own if none are provided. | |
63e5e3e0 | 46 | |
3ed8e5b6 AT |
47 | m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) |
48 | m4_define([_AC_ARG_VAR_PRECIOUS],[]) | |
b1760f7f | 49 | save_CFLAGS=$CFLAGS |
63e5e3e0 | 50 | AC_PROG_CC |
b1760f7f RH |
51 | AC_PROG_CXX |
52 | CFLAGS=$save_CFLAGS | |
53 | m4_undefine([_AC_ARG_VAR_PRECIOUS]) | |
1b3b24c2 | 54 | m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) |
bbf3057b | 55 | |
3ed8e5b6 AT |
56 | AC_SUBST(CFLAGS) |
57 | ||
58 | AM_PROG_AS | |
59 | AM_PROG_CC_C_O | |
63e5e3e0 AG |
60 | AC_PROG_LIBTOOL |
61 | ||
b1760f7f RH |
62 | # Test for 64-bit build. |
63 | AC_CHECK_SIZEOF([size_t]) | |
64 | ||
3ed8e5b6 AT |
65 | AM_MAINTAINER_MODE |
66 | ||
c9b93377 | 67 | AC_CHECK_HEADERS(sys/mman.h) |
b1760f7f | 68 | AC_CHECK_FUNCS([mmap mkostemp]) |
5196736e AJ |
69 | AC_FUNC_MMAP_BLACKLIST |
70 | ||
bbf3057b AT |
71 | dnl The -no-testsuite modules omit the test subdir. |
72 | AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) | |
73 | ||
63e5e3e0 | 74 | TARGETDIR="unknown" |
e73d2479 | 75 | HAVE_LONG_DOUBLE_VARIANT=0 |
63e5e3e0 | 76 | |
b1760f7f | 77 | . ${srcdir}/configure.host |
bbf3057b | 78 | |
b1760f7f | 79 | if test -n "${UNSUPPORTED}"; then |
3ed8e5b6 | 80 | AC_MSG_ERROR(["libffi has not been ported to $host."]) |
63e5e3e0 AG |
81 | fi |
82 | ||
b1760f7f RH |
83 | AC_SUBST(AM_RUNTESTFLAGS) |
84 | AC_SUBST(AM_LTLDFLAGS) | |
63e5e3e0 AG |
85 | |
86 | AC_HEADER_STDC | |
87 | AC_CHECK_FUNCS(memcpy) | |
88 | AC_FUNC_ALLOCA | |
89 | ||
a097ef55 KC |
90 | AC_CHECK_SIZEOF(double) |
91 | AC_CHECK_SIZEOF(long double) | |
e2f2e70a | 92 | |
1450eb7a | 93 | # Also AC_SUBST this variable for ffi.h. |
bf8da5fc RH |
94 | if test -z "$HAVE_LONG_DOUBLE"; then |
95 | HAVE_LONG_DOUBLE=0 | |
e73d2479 AM |
96 | if test $ac_cv_sizeof_long_double != 0; then |
97 | if test $HAVE_LONG_DOUBLE_VARIANT != 0; then | |
98 | AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type]) | |
bf8da5fc | 99 | HAVE_LONG_DOUBLE=1 |
e73d2479 AM |
100 | else |
101 | if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then | |
102 | HAVE_LONG_DOUBLE=1 | |
103 | AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double]) | |
104 | fi | |
bf8da5fc | 105 | fi |
1450eb7a AT |
106 | fi |
107 | fi | |
108 | AC_SUBST(HAVE_LONG_DOUBLE) | |
e73d2479 | 109 | AC_SUBST(HAVE_LONG_DOUBLE_VARIANT) |
1450eb7a | 110 | |
a097ef55 | 111 | AC_C_BIGENDIAN |
63e5e3e0 | 112 | |
8b01bdb0 | 113 | GCC_AS_CFI_PSEUDO_OP |
e6fbf387 | 114 | |
189ab118 | 115 | if test x$TARGET = xSPARC; then |
5d84cf0b JJ |
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 | |
bd19c9f4 JS |
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 | |
b1760f7f | 136 | AC_TRY_COMPILE(,[asm (".register %g2, #scratch");], |
3ed8e5b6 AT |
137 | [libffi_cv_as_register_pseudo_op=yes], |
138 | [libffi_cv_as_register_pseudo_op=no]) | |
bd19c9f4 JS |
139 | ]) |
140 | if test "x$libffi_cv_as_register_pseudo_op" = xyes; then | |
141 | AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1, | |
3ed8e5b6 | 142 | [Define if your assembler supports .register.]) |
bd19c9f4 | 143 | fi |
5d84cf0b JJ |
144 | fi |
145 | ||
8353cd27 | 146 | if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then |
4d3d4078 RO |
147 | AC_CACHE_CHECK([assembler supports pc related relocs], |
148 | libffi_cv_as_x86_pcrel, [ | |
b1760f7f | 149 | libffi_cv_as_x86_pcrel=no |
4d3d4078 | 150 | echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s |
b1760f7f RH |
151 | if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then |
152 | libffi_cv_as_x86_pcrel=yes | |
4d3d4078 RO |
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 | |
d416abb4 RO |
159 | |
160 | AC_CACHE_CHECK([assembler .ascii pseudo-op support], | |
161 | libffi_cv_as_ascii_pseudo_op, [ | |
162 | libffi_cv_as_ascii_pseudo_op=unknown | |
163 | # Check if we have .ascii | |
b1760f7f | 164 | AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");], |
d416abb4 RO |
165 | [libffi_cv_as_ascii_pseudo_op=yes], |
166 | [libffi_cv_as_ascii_pseudo_op=no]) | |
167 | ]) | |
168 | if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then | |
169 | AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1, | |
170 | [Define if your assembler supports .ascii.]) | |
171 | fi | |
172 | ||
173 | AC_CACHE_CHECK([assembler .string pseudo-op support], | |
174 | libffi_cv_as_string_pseudo_op, [ | |
175 | libffi_cv_as_string_pseudo_op=unknown | |
176 | # Check if we have .string | |
b1760f7f | 177 | AC_TRY_COMPILE(,[asm (".string \\"string\\"");], |
d416abb4 RO |
178 | [libffi_cv_as_string_pseudo_op=yes], |
179 | [libffi_cv_as_string_pseudo_op=no]) | |
180 | ]) | |
181 | if test "x$libffi_cv_as_string_pseudo_op" = xyes; then | |
182 | AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1, | |
183 | [Define if your assembler supports .string.]) | |
184 | fi | |
4d3d4078 RO |
185 | fi |
186 | ||
b1760f7f RH |
187 | if test x$TARGET = xS390; then |
188 | AC_CACHE_CHECK([compiler uses zarch features], | |
189 | libffi_cv_as_s390_zarch, [ | |
190 | libffi_cv_as_s390_zarch=no | |
191 | echo 'void foo(void) { bar(); bar(); }' > conftest.c | |
192 | if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then | |
193 | if grep -q brasl conftest.s; then | |
194 | libffi_cv_as_s390_zarch=yes | |
195 | fi | |
196 | fi | |
197 | ]) | |
198 | if test "x$libffi_cv_as_s390_zarch" = xyes; then | |
199 | AC_DEFINE(HAVE_AS_S390_ZARCH, 1, | |
200 | [Define if the compiler uses zarch features.]) | |
201 | fi | |
202 | fi | |
203 | ||
b4b575ce AG |
204 | # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. |
205 | AC_ARG_ENABLE(pax_emutramp, | |
206 | [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], | |
207 | if test "$enable_pax_emutramp" = "yes"; then | |
208 | AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1, | |
209 | [Define this if you want to enable pax emulated trampolines]) | |
210 | fi) | |
211 | ||
212 | FFI_EXEC_TRAMPOLINE_TABLE=0 | |
99fba2c4 | 213 | case "$target" in |
b4b575ce AG |
214 | *arm*-apple-darwin*) |
215 | FFI_EXEC_TRAMPOLINE_TABLE=1 | |
216 | AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1, | |
217 | [Cannot use PROT_EXEC on this target, so, we revert to | |
218 | alternative means]) | |
219 | ;; | |
220 | *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) | |
99fba2c4 AT |
221 | AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, |
222 | [Cannot use malloc on this target, so, we revert to | |
223 | alternative means]) | |
224 | ;; | |
225 | esac | |
b4b575ce AG |
226 | AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) |
227 | AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) | |
99fba2c4 | 228 | |
f4b130bb | 229 | if test x$TARGET = xX86_64; then |
b1760f7f | 230 | AC_CACHE_CHECK([toolchain supports unwind section type], |
f4b130bb | 231 | libffi_cv_as_x86_64_unwind_section_type, [ |
b1760f7f RH |
232 | cat > conftest1.s << EOF |
233 | .text | |
234 | .globl foo | |
235 | foo: | |
236 | jmp bar | |
237 | .section .eh_frame,"a",@unwind | |
238 | bar: | |
239 | EOF | |
240 | ||
241 | cat > conftest2.c << EOF | |
242 | extern void foo(); | |
243 | int main(){foo();} | |
244 | EOF | |
245 | ||
246 | libffi_cv_as_x86_64_unwind_section_type=no | |
247 | # we ensure that we can compile _and_ link an assembly file containing an @unwind section | |
248 | # since the compiler can support it and not the linker (ie old binutils) | |
249 | if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \ | |
250 | $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then | |
251 | libffi_cv_as_x86_64_unwind_section_type=yes | |
f4b130bb RO |
252 | fi |
253 | ]) | |
254 | if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then | |
255 | AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1, | |
256 | [Define if your assembler supports unwind section type.]) | |
257 | fi | |
258 | fi | |
259 | ||
b4b575ce AG |
260 | if test "x$GCC" = "xyes"; then |
261 | AC_CACHE_CHECK([whether .eh_frame section should be read-only], | |
262 | libffi_cv_ro_eh_frame, [ | |
263 | libffi_cv_ro_eh_frame=no | |
264 | echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c | |
b1760f7f RH |
265 | if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then |
266 | objdump -h conftest.o > conftest.dump 2>&1 | |
267 | libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` | |
268 | if test "x$libffi_eh_frame_line" != "x"; then | |
269 | libffi_test_line=`expr $libffi_eh_frame_line + 1`p | |
270 | sed -n $libffi_test_line conftest.dump > conftest.line | |
271 | if grep READONLY conftest.line > /dev/null; then | |
272 | libffi_cv_ro_eh_frame=yes | |
273 | fi | |
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 | |
293 | if grep '\.hidden.*foo' conftest.s >/dev/null; then | |
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 |
303 | fi |
304 | ||
305 | AH_BOTTOM([ | |
306 | #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE | |
307 | #ifdef LIBFFI_ASM | |
308 | #define FFI_HIDDEN(name) .hidden name | |
309 | #else | |
310 | #define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) | |
311 | #endif | |
312 | #else | |
313 | #ifdef LIBFFI_ASM | |
314 | #define FFI_HIDDEN(name) | |
315 | #else | |
316 | #define FFI_HIDDEN | |
317 | #endif | |
318 | #endif | |
319 | ]) | |
320 | ||
63e5e3e0 AG |
321 | AC_SUBST(TARGET) |
322 | AC_SUBST(TARGETDIR) | |
323 | ||
b1760f7f RH |
324 | changequote(<,>) |
325 | TARGET_OBJ= | |
326 | for i in $SOURCES; do | |
327 | TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'` | |
328 | done | |
329 | changequote([,]) | |
330 | AC_SUBST(TARGET_OBJ) | |
331 | ||
63e5e3e0 AG |
332 | AC_SUBST(SHELL) |
333 | ||
7d45b968 JS |
334 | AC_ARG_ENABLE(debug, |
335 | [ --enable-debug debugging mode], | |
336 | if test "$enable_debug" = "yes"; then | |
1450eb7a | 337 | AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.]) |
7d45b968 | 338 | fi) |
b4b575ce | 339 | AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") |
7d45b968 JS |
340 | |
341 | AC_ARG_ENABLE(structs, | |
342 | [ --disable-structs omit code for struct support], | |
343 | if test "$enable_structs" = "no"; then | |
b1760f7f | 344 | AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.]) |
7d45b968 | 345 | fi) |
b1760f7f | 346 | AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") |
7d45b968 JS |
347 | |
348 | AC_ARG_ENABLE(raw-api, | |
349 | [ --disable-raw-api make the raw api unavailable], | |
350 | if test "$enable_raw_api" = "no"; then | |
b1760f7f | 351 | AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) |
7d45b968 | 352 | fi) |
63e5e3e0 AG |
353 | |
354 | AC_ARG_ENABLE(purify-safety, | |
7d45b968 JS |
355 | [ --enable-purify-safety purify-safe mode], |
356 | if test "$enable_purify_safety" = "yes"; then | |
1450eb7a | 357 | AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) |
7d45b968 | 358 | fi) |
0721f64e | 359 | |
0e292c01 AO |
360 | if test -n "$with_cross_host" && |
361 | test x"$with_cross_host" != x"no"; then | |
362 | toolexecdir='$(exec_prefix)/$(target_alias)' | |
363 | toolexeclibdir='$(toolexecdir)/lib' | |
364 | else | |
365 | toolexecdir='$(libdir)/gcc-lib/$(target_alias)' | |
366 | toolexeclibdir='$(libdir)' | |
367 | fi | |
ff8b9ca8 AS |
368 | multi_os_directory=`$CC -print-multi-os-directory` |
369 | case $multi_os_directory in | |
370 | .) ;; # Avoid trailing /. | |
371 | *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; | |
372 | esac | |
0e292c01 AO |
373 | AC_SUBST(toolexecdir) |
374 | AC_SUBST(toolexeclibdir) | |
63e5e3e0 | 375 | |
3c18f2d1 TT |
376 | if test "${multilib}" = "yes"; then |
377 | multilib_arg="--enable-multilib" | |
378 | else | |
379 | multilib_arg= | |
380 | fi | |
381 | ||
3ed8e5b6 AT |
382 | AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) |
383 | AC_CONFIG_COMMANDS(src, [ | |
3b905056 | 384 | test -d src || mkdir src |
3ed8e5b6 AT |
385 | test -d src/$TARGETDIR || mkdir src/$TARGETDIR |
386 | ], [TARGETDIR="$TARGETDIR"]) | |
387 | ||
388 | AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) | |
389 | ||
b1760f7f | 390 | AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) |
1450eb7a | 391 | |
3ed8e5b6 | 392 | AC_OUTPUT |