Ensure the linker supports @unwind sections in libffi.
[platform/upstream/libffi.git] / configure.ac
1 dnl Process this with autoconf to create configure
2
3 AC_PREREQ(2.68)
4
5 AC_INIT([libffi], [3.0.14-rc0], [http://github.com/atgreen/libffi/issues])
6 AC_CONFIG_HEADERS([fficonfig.h])
7
8 AC_CANONICAL_SYSTEM
9 target_alias=${target_alias-$host_alias}
10
11 . ${srcdir}/configure.host
12
13 AX_ENABLE_BUILDDIR
14
15 AM_INIT_AUTOMAKE
16
17 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
18 # We must force CC to /not/ be precious variables; otherwise
19 # the wrong, non-multilib-adjusted value will be used in multilibs.
20 # As a side effect, we have to subst CFLAGS ourselves.
21 # Also save and restore CFLAGS, since AC_PROG_CC will come up with
22 # defaults of its own if none are provided.
23
24 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
25 m4_define([_AC_ARG_VAR_PRECIOUS],[])
26 save_CFLAGS=$CFLAGS
27 AC_PROG_CC
28 CFLAGS=$save_CFLAGS
29 m4_undefine([_AC_ARG_VAR_PRECIOUS])
30 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
31
32 AC_SUBST(CFLAGS)
33
34 AM_PROG_AS
35 AM_PROG_CC_C_O
36 AC_PROG_LIBTOOL
37 AC_CONFIG_MACRO_DIR([m4])
38
39 # Test for 64-bit build.
40 AC_CHECK_SIZEOF([size_t])
41
42 AX_COMPILER_VENDOR
43 AX_CC_MAXOPT
44 # The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
45 # compiler.
46 if test "$ax_cv_c_compiler_vendor" != "sun"; then
47   AX_CFLAGS_WARN_ALL
48 fi
49
50 if test "x$GCC" = "xyes"; then
51   CFLAGS="$CFLAGS -fexceptions"
52   touch local.exp
53 else
54   cat > local.exp <<EOF
55 set CC_FOR_TARGET "$CC"
56 EOF
57 fi
58
59 AM_MAINTAINER_MODE
60
61 AC_CHECK_HEADERS(sys/mman.h)
62 AC_CHECK_FUNCS(mmap)
63 AC_FUNC_MMAP_BLACKLIST
64
65 dnl The -no-testsuite modules omit the test subdir.
66 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
67
68 TARGETDIR="unknown"
69 HAVE_LONG_DOUBLE_VARIANT=0
70 case "$host" in
71   aarch64*-*-*)
72         TARGET=AARCH64; TARGETDIR=aarch64
73         ;;
74
75   alpha*-*-*)
76         TARGET=ALPHA; TARGETDIR=alpha;
77         # Support 128-bit long double, changeable via command-line switch.
78         HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
79         ;;
80
81   arc*-*-*)
82         TARGET=ARC; TARGETDIR=arc
83         ;;
84
85   arm*-*-*)
86         TARGET=ARM; TARGETDIR=arm
87         ;;
88
89   amd64-*-freebsd* | amd64-*-openbsd*)
90         TARGET=X86_64; TARGETDIR=x86
91         ;;
92
93   amd64-*-freebsd*)
94         TARGET=X86_64; TARGETDIR=x86
95         ;;
96
97   amd64-*-freebsd*)
98         TARGET=X86_64; TARGETDIR=x86
99         ;;
100
101   avr32*-*-*)
102         TARGET=AVR32; TARGETDIR=avr32
103         ;;
104
105   bfin*)
106         TARGET=BFIN; TARGETDIR=bfin
107         ;;
108
109   cris-*-*)
110         TARGET=LIBFFI_CRIS; TARGETDIR=cris
111         ;;
112
113   frv-*-*)
114         TARGET=FRV; TARGETDIR=frv
115         ;;
116
117   hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
118         TARGET=PA_LINUX; TARGETDIR=pa
119         ;;
120   hppa*64-*-hpux*)
121         TARGET=PA64_HPUX; TARGETDIR=pa
122         ;;
123   hppa*-*-hpux*)
124         TARGET=PA_HPUX; TARGETDIR=pa
125         ;;
126
127   i?86-*-freebsd* | i?86-*-openbsd*)
128         TARGET=X86_FREEBSD; TARGETDIR=x86
129         ;;
130   i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
131         TARGET=X86_WIN32; TARGETDIR=x86
132         # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
133         # We must also check with_cross_host to decide if this is a native
134         # or cross-build and select where to install dlls appropriately.
135         if test -n "$with_cross_host" &&
136            test x"$with_cross_host" != x"no"; then
137           AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
138         else
139           AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
140         fi
141         ;;
142   i?86-*-darwin*)
143         TARGET=X86_DARWIN; TARGETDIR=x86
144         ;;
145   i?86-*-solaris2.1[[0-9]]*)
146         TARGETDIR=x86
147         if test $ac_cv_sizeof_size_t = 4; then
148           TARGET=X86; 
149         else
150           TARGET=X86_64; 
151         fi        
152         ;;
153
154   x86_64-*-darwin*)
155         TARGET=X86_DARWIN; TARGETDIR=x86
156         ;;
157
158   x86_64-*-cygwin* | x86_64-*-mingw*)
159         TARGET=X86_WIN64; TARGETDIR=x86
160         # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
161         # We must also check with_cross_host to decide if this is a native
162         # or cross-build and select where to install dlls appropriately.
163         if test -n "$with_cross_host" &&
164            test x"$with_cross_host" != x"no"; then
165           AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
166         else
167           AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
168         fi
169         ;;
170
171   i?86-*-* | x86_64-*-*)
172         TARGETDIR=x86
173         if test $ac_cv_sizeof_size_t = 4; then
174           case "$host" in
175             *-gnux32)
176               TARGET=X86_64
177               ;;
178             *)
179               TARGET=X86
180               ;;
181           esac  
182         else
183           TARGET=X86_64; 
184         fi        
185         ;;
186
187   ia64*-*-*)
188         TARGET=IA64; TARGETDIR=ia64
189         ;;
190
191   m32r*-*-*)
192         TARGET=M32R; TARGETDIR=m32r
193         ;;
194
195   m68k-*-*)
196         TARGET=M68K; TARGETDIR=m68k
197         ;;
198
199   m88k-*-*)
200         TARGET=M88K; TARGETDIR=m88k
201         ;;
202
203   microblaze*-*-*)
204         TARGET=MICROBLAZE; TARGETDIR=microblaze
205         ;;
206
207   moxie-*-*)
208         TARGET=MOXIE; TARGETDIR=moxie
209         ;;
210
211   metag-*-*)
212         TARGET=METAG; TARGETDIR=metag
213         ;;
214
215   mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
216         TARGET=MIPS; TARGETDIR=mips
217         ;;
218   mips*-*linux* | mips*-*-openbsd*)
219         # Support 128-bit long double for NewABI.
220         HAVE_LONG_DOUBLE='defined(__mips64)'
221         TARGET=MIPS; TARGETDIR=mips
222         ;;
223
224   nios2*-linux*)
225         TARGET=NIOS2; TARGETDIR=nios2
226         ;;
227
228   powerpc*-*-linux* | powerpc-*-sysv*)
229         TARGET=POWERPC; TARGETDIR=powerpc
230         HAVE_LONG_DOUBLE_VARIANT=1
231         ;;
232   powerpc-*-amigaos*)
233         TARGET=POWERPC; TARGETDIR=powerpc
234         ;;
235   powerpc-*-beos*)
236         TARGET=POWERPC; TARGETDIR=powerpc
237         ;;
238   powerpc-*-darwin* | powerpc64-*-darwin*)
239         TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
240         ;;
241   powerpc-*-aix* | rs6000-*-aix*)
242         TARGET=POWERPC_AIX; TARGETDIR=powerpc
243         ;;
244   powerpc-*-freebsd* | powerpc-*-openbsd*)
245         TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
246         HAVE_LONG_DOUBLE_VARIANT=1
247         ;;
248   powerpc64-*-freebsd*)
249         TARGET=POWERPC; TARGETDIR=powerpc
250         ;;
251   powerpc*-*-rtems*)
252         TARGET=POWERPC; TARGETDIR=powerpc
253         ;;
254
255   s390-*-* | s390x-*-*)
256         TARGET=S390; TARGETDIR=s390
257         ;;
258
259   sh-*-* | sh[[34]]*-*-*)
260         TARGET=SH; TARGETDIR=sh
261         ;;
262   sh64-*-* | sh5*-*-*)
263         TARGET=SH64; TARGETDIR=sh64
264         ;;
265
266   sparc*-*-*)
267         TARGET=SPARC; TARGETDIR=sparc
268         ;;
269
270   tile*-*)
271         TARGET=TILE; TARGETDIR=tile
272         ;;
273
274   vax-*-*)
275         TARGET=VAX; TARGETDIR=vax
276         ;;
277
278   xtensa*-*)
279         TARGET=XTENSA; TARGETDIR=xtensa
280         ;;
281
282 esac
283
284 AC_SUBST(AM_RUNTESTFLAGS)
285 AC_SUBST(AM_LTLDFLAGS)
286
287 if test $TARGETDIR = unknown; then
288   AC_MSG_ERROR(["libffi has not been ported to $host."])
289 fi
290
291 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
292 AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
293 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
294 AM_CONDITIONAL(X86, test x$TARGET = xX86)
295 AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
296 AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
297 AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
298 AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
299 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
300 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
301 AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
302 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
303 AM_CONDITIONAL(M88K, test x$TARGET = xM88K)
304 AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE)
305 AM_CONDITIONAL(METAG, test x$TARGET = xMETAG)
306 AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
307 AM_CONDITIONAL(NIOS2, test x$TARGET = xNIOS2)
308 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
309 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
310 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
311 AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
312 AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
313 AM_CONDITIONAL(ARC, test x$TARGET = xARC)
314 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
315 AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
316 AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
317 AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
318 AM_CONDITIONAL(S390, test x$TARGET = xS390)
319 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
320 AM_CONDITIONAL(SH, test x$TARGET = xSH)
321 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
322 AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
323 AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
324 AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
325 AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
326 AM_CONDITIONAL(VAX, test x$TARGET = xVAX)
327 AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA)
328
329 AC_HEADER_STDC
330 AC_CHECK_FUNCS(memcpy)
331 AC_FUNC_ALLOCA
332
333 AC_CHECK_SIZEOF(double)
334 AC_CHECK_SIZEOF(long double)
335
336 # Also AC_SUBST this variable for ffi.h.
337 if test -z "$HAVE_LONG_DOUBLE"; then
338   HAVE_LONG_DOUBLE=0
339   if test $ac_cv_sizeof_long_double != 0; then
340     if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
341       AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
342       HAVE_LONG_DOUBLE=1
343     else
344       if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
345         HAVE_LONG_DOUBLE=1
346         AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
347       fi
348     fi
349   fi
350 fi
351 AC_SUBST(HAVE_LONG_DOUBLE)
352 AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
353
354 AC_C_BIGENDIAN
355
356 GCC_AS_CFI_PSEUDO_OP
357
358 if test x$TARGET = xSPARC; then
359     AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
360         libffi_cv_as_sparc_ua_pcrel, [
361         save_CFLAGS="$CFLAGS"
362         save_LDFLAGS="$LDFLAGS"
363         CFLAGS="$CFLAGS -fpic"
364         LDFLAGS="$LDFLAGS -shared"
365         AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
366                     [libffi_cv_as_sparc_ua_pcrel=yes],
367                     [libffi_cv_as_sparc_ua_pcrel=no])
368         CFLAGS="$save_CFLAGS"
369         LDFLAGS="$save_LDFLAGS"])
370     if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
371         AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
372                   [Define if your assembler and linker support unaligned PC relative relocs.])
373     fi
374
375     AC_CACHE_CHECK([assembler .register pseudo-op support],
376        libffi_cv_as_register_pseudo_op, [
377        libffi_cv_as_register_pseudo_op=unknown
378        # Check if we have .register
379        AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
380                        [libffi_cv_as_register_pseudo_op=yes],
381                        [libffi_cv_as_register_pseudo_op=no])
382     ])
383     if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
384        AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
385                [Define if your assembler supports .register.])
386     fi
387 fi
388
389 if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
390     AC_CACHE_CHECK([assembler supports pc related relocs],
391         libffi_cv_as_x86_pcrel, [
392         libffi_cv_as_x86_pcrel=no
393         echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
394         if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
395             libffi_cv_as_x86_pcrel=yes
396         fi
397         ])
398     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
399         AC_DEFINE(HAVE_AS_X86_PCREL, 1,
400                   [Define if your assembler supports PC relative relocs.])
401     fi
402
403     AC_CACHE_CHECK([assembler .ascii pseudo-op support],
404        libffi_cv_as_ascii_pseudo_op, [
405        libffi_cv_as_ascii_pseudo_op=unknown
406        # Check if we have .ascii
407        AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");],
408                        [libffi_cv_as_ascii_pseudo_op=yes],
409                        [libffi_cv_as_ascii_pseudo_op=no])
410     ])
411     if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
412        AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
413                [Define if your assembler supports .ascii.])
414     fi
415
416     AC_CACHE_CHECK([assembler .string pseudo-op support],
417        libffi_cv_as_string_pseudo_op, [
418        libffi_cv_as_string_pseudo_op=unknown
419        # Check if we have .string
420        AC_TRY_COMPILE(,[asm (".string \\"string\\"");],
421                        [libffi_cv_as_string_pseudo_op=yes],
422                        [libffi_cv_as_string_pseudo_op=no])
423     ])
424     if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
425        AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
426                [Define if your assembler supports .string.])
427     fi
428 fi
429
430 # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
431 AC_ARG_ENABLE(pax_emutramp,
432   [  --enable-pax_emutramp       enable pax emulated trampolines, for we can't use PROT_EXEC],
433   if test "$enable_pax_emutramp" = "yes"; then
434     AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
435       [Define this if you want to enable pax emulated trampolines])
436   fi)
437
438 if test x$TARGET = xX86_WIN64; then
439     LT_SYS_SYMBOL_USCORE
440     if test "x$sys_symbol_underscore" = xyes; then
441         AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
442     fi
443 fi
444
445 FFI_EXEC_TRAMPOLINE_TABLE=0
446 case "$target" in
447      *arm*-apple-darwin*)
448        FFI_EXEC_TRAMPOLINE_TABLE=1
449        AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
450                  [Cannot use PROT_EXEC on this target, so, we revert to
451                    alternative means])
452      ;;
453      *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
454        AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
455                  [Cannot use malloc on this target, so, we revert to
456                    alternative means])
457      ;;
458 esac
459 AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
460 AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
461
462 if test x$TARGET = xX86_64; then
463     AC_CACHE_CHECK([toolchain supports unwind section type],
464         libffi_cv_as_x86_64_unwind_section_type, [
465         cat  > conftest1.s << EOF
466 .text
467 .globl foo
468 foo:
469 jmp bar
470 .section .eh_frame,"a",@unwind
471 bar:
472 EOF
473
474         cat > conftest2.c  << EOF
475 extern void foo();
476 int main(){foo();}
477 EOF
478
479         libffi_cv_as_x86_64_unwind_section_type=no
480         # we ensure that we can compile _and_ link an assembly file containing an @unwind section
481         # since the compiler can support it and not the linker (ie old binutils)
482         if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
483            $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
484             libffi_cv_as_x86_64_unwind_section_type=yes
485         fi
486         ])
487     if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
488         AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
489                   [Define if your assembler supports unwind section type.])
490     fi
491 fi
492
493 if test "x$GCC" = "xyes"; then
494   AC_CACHE_CHECK([whether .eh_frame section should be read-only],
495       libffi_cv_ro_eh_frame, [
496         libffi_cv_ro_eh_frame=no
497         echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
498         if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
499             objdump -h conftest.o > conftest.dump 2>&1
500             libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
501             libffi_test_line=`expr $libffi_eh_frame_line + 1`p
502             sed -n $libffi_test_line conftest.dump > conftest.line
503             if grep READONLY conftest.line > /dev/null; then
504                 libffi_cv_ro_eh_frame=yes
505             fi
506         fi
507         rm -f conftest.*
508       ])
509   if test "x$libffi_cv_ro_eh_frame" = xyes; then
510       AC_DEFINE(HAVE_RO_EH_FRAME, 1,
511               [Define if .eh_frame sections should be read-only.])
512       AC_DEFINE(EH_FRAME_FLAGS, "a",
513               [Define to the flags needed for the .section .eh_frame directive.  ])
514   else
515       AC_DEFINE(EH_FRAME_FLAGS, "aw",
516               [Define to the flags needed for the .section .eh_frame directive.  ])
517   fi
518
519   AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
520       libffi_cv_hidden_visibility_attribute, [
521         echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1  ; }' > conftest.c
522         libffi_cv_hidden_visibility_attribute=no
523         if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
524             if grep '\.hidden.*foo' conftest.s >/dev/null; then
525                 libffi_cv_hidden_visibility_attribute=yes
526             fi
527         fi
528         rm -f conftest.*
529       ])
530   if test $libffi_cv_hidden_visibility_attribute = yes; then
531       AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
532               [Define if __attribute__((visibility("hidden"))) is supported.])
533   fi
534 fi
535
536 AH_BOTTOM([
537 #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
538 #ifdef LIBFFI_ASM
539 #define FFI_HIDDEN(name) .hidden name
540 #else
541 #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
542 #endif
543 #else
544 #ifdef LIBFFI_ASM
545 #define FFI_HIDDEN(name)
546 #else
547 #define FFI_HIDDEN
548 #endif
549 #endif
550 ])
551
552 AC_SUBST(TARGET)
553 AC_SUBST(TARGETDIR)
554
555 AC_SUBST(SHELL)
556
557 AC_ARG_ENABLE(debug,
558 [  --enable-debug          debugging mode],
559   if test "$enable_debug" = "yes"; then
560     AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
561   fi)
562 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
563
564 AC_ARG_ENABLE(structs,
565 [  --disable-structs       omit code for struct support],
566   if test "$enable_structs" = "no"; then
567     AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
568   fi)
569 AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
570
571 AC_ARG_ENABLE(raw-api,
572 [  --disable-raw-api       make the raw api unavailable],
573   if test "$enable_raw_api" = "no"; then
574     AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
575   fi)
576
577 AC_ARG_ENABLE(purify-safety,
578 [  --enable-purify-safety  purify-safe mode],
579   if test "$enable_purify_safety" = "yes"; then
580     AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
581   fi)
582
583 # These variables are only ever used when we cross-build to X86_WIN32.
584 # And we only support this with GCC, so...
585 if test "x$GCC" = "xyes"; then
586   if test -n "$with_cross_host" &&
587      test x"$with_cross_host" != x"no"; then
588     toolexecdir='$(exec_prefix)/$(target_alias)'
589     toolexeclibdir='$(toolexecdir)/lib'
590   else
591     toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
592     toolexeclibdir='$(libdir)'
593   fi
594   multi_os_directory=`$CC -print-multi-os-directory`
595   case $multi_os_directory in
596     .) ;; # Avoid trailing /.
597     ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
598   esac
599   AC_SUBST(toolexecdir)
600 else
601   toolexeclibdir='$(libdir)'
602 fi
603 AC_SUBST(toolexeclibdir)
604
605 AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
606 AC_CONFIG_COMMANDS(src, [
607 test -d src || mkdir src
608 test -d src/$TARGETDIR || mkdir src/$TARGETDIR
609 ], [TARGETDIR="$TARGETDIR"])
610
611 AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
612
613 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
614
615 AC_OUTPUT