1 dnl Process this with autoconf to create configure
5 AC_INIT([libffi], [3.0.9rc1], [http://gcc.gnu.org/bugs.html])
6 AC_CONFIG_HEADERS([fficonfig.h])
9 target_alias=${target_alias-$host_alias}
11 . ${srcdir}/configure.host
15 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
16 # We must force CC to /not/ be precious variables; otherwise
17 # the wrong, non-multilib-adjusted value will be used in multilibs.
18 # As a side effect, we have to subst CFLAGS ourselves.
20 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
21 m4_define([_AC_ARG_VAR_PRECIOUS],[])
23 m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
33 AC_CHECK_HEADERS(sys/mman.h)
35 AC_FUNC_MMAP_BLACKLIST
37 dnl The -no-testsuite modules omit the test subdir.
38 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
43 TARGET=ALPHA; TARGETDIR=alpha;
44 # Support 128-bit long double, changable via command-line switch.
45 HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
49 TARGET=ARM; TARGETDIR=arm
53 TARGET=AVR32; TARGETDIR=avr32
57 TARGET=X86_64; TARGETDIR=x86
61 TARGET=X86_64; TARGETDIR=x86
65 TARGET=LIBFFI_CRIS; TARGETDIR=cris
69 TARGET=FRV; TARGETDIR=frv
72 hppa*-*-linux* | parisc*-*-linux*)
73 TARGET=PA_LINUX; TARGETDIR=pa
76 TARGET=PA64_HPUX; TARGETDIR=pa
79 TARGET=PA_HPUX; TARGETDIR=pa
82 i?86-*-freebsd* | i?86-*-openbsd*)
83 TARGET=X86_FREEBSD; TARGETDIR=x86
85 i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
86 TARGET=X86_WIN32; TARGETDIR=x86
89 TARGET=X86_DARWIN; TARGETDIR=x86
91 i?86-*-solaris2.1[[0-9]]*)
92 TARGET=X86_64; TARGETDIR=x86
95 TARGET=X86; TARGETDIR=x86
99 TARGET=IA64; TARGETDIR=ia64
103 TARGET=M32R; TARGETDIR=m32r
107 TARGET=M68K; TARGETDIR=m68k
110 mips-sgi-irix5.* | mips-sgi-irix6.*)
111 TARGET=MIPS; TARGETDIR=mips
114 TARGET=MIPS; TARGETDIR=mips
117 powerpc*-*-linux* | powerpc-*-sysv*)
118 TARGET=POWERPC; TARGETDIR=powerpc
121 TARGET=POWERPC; TARGETDIR=powerpc
124 TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
126 powerpc-*-aix* | rs6000-*-aix*)
127 TARGET=POWERPC_AIX; TARGETDIR=powerpc
130 TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
133 TARGET=POWERPC; TARGETDIR=powerpc
136 s390-*-* | s390x-*-*)
137 TARGET=S390; TARGETDIR=s390
140 sh-*-* | sh[[34]]*-*-*)
141 TARGET=SH; TARGETDIR=sh
144 TARGET=SH64; TARGETDIR=sh64
148 TARGET=SPARC; TARGETDIR=sparc
152 TARGET=X86_DARWIN; TARGETDIR=x86
155 x86_64-*-cygwin* | x86_64-*-mingw*)
156 TARGET=X86_WIN64; TARGETDIR=x86
160 TARGET=X86_64; TARGETDIR=x86
164 AC_SUBST(AM_RUNTESTFLAGS)
166 if test $TARGETDIR = unknown; then
167 AC_MSG_ERROR(["libffi has not been ported to $host."])
170 AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
171 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
172 AM_CONDITIONAL(X86, test x$TARGET = xX86)
173 AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
174 AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
175 AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
176 AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
177 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
178 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
179 AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
180 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
181 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
182 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
183 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
184 AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
185 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
186 AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
187 AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
188 AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
189 AM_CONDITIONAL(S390, test x$TARGET = xS390)
190 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
191 AM_CONDITIONAL(SH, test x$TARGET = xSH)
192 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
193 AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
194 AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
195 AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
198 AC_CHECK_FUNCS(memcpy)
201 AC_CHECK_SIZEOF(double)
202 AC_CHECK_SIZEOF(long double)
204 # Also AC_SUBST this variable for ffi.h.
205 if test -z "$HAVE_LONG_DOUBLE"; then
207 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
208 if test $ac_cv_sizeof_long_double != 0; then
210 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
214 AC_SUBST(HAVE_LONG_DOUBLE)
218 AC_CACHE_CHECK([assembler .cfi pseudo-op support],
219 libffi_cv_as_cfi_pseudo_op, [
220 libffi_cv_as_cfi_pseudo_op=unknown
221 AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
222 [libffi_cv_as_cfi_pseudo_op=yes],
223 [libffi_cv_as_cfi_pseudo_op=no])
225 if test "x$libffi_cv_as_cfi_pseudo_op" = xyes; then
226 AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
227 [Define if your assembler supports .cfi_* directives.])
230 if test x$TARGET = xSPARC; then
231 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
232 libffi_cv_as_sparc_ua_pcrel, [
233 save_CFLAGS="$CFLAGS"
234 save_LDFLAGS="$LDFLAGS"
235 CFLAGS="$CFLAGS -fpic"
236 LDFLAGS="$LDFLAGS -shared"
237 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
238 [libffi_cv_as_sparc_ua_pcrel=yes],
239 [libffi_cv_as_sparc_ua_pcrel=no])
240 CFLAGS="$save_CFLAGS"
241 LDFLAGS="$save_LDFLAGS"])
242 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
243 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
244 [Define if your assembler and linker support unaligned PC relative relocs.])
247 AC_CACHE_CHECK([assembler .register pseudo-op support],
248 libffi_cv_as_register_pseudo_op, [
249 libffi_cv_as_register_pseudo_op=unknown
250 # Check if we have .register
251 AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
252 [libffi_cv_as_register_pseudo_op=yes],
253 [libffi_cv_as_register_pseudo_op=no])
255 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
256 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
257 [Define if your assembler supports .register.])
261 if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
262 AC_CACHE_CHECK([assembler supports pc related relocs],
263 libffi_cv_as_x86_pcrel, [
264 libffi_cv_as_x86_pcrel=yes
265 echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
266 if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
267 libffi_cv_as_x86_pcrel=no
270 if test "x$libffi_cv_as_x86_pcrel" = xyes; then
271 AC_DEFINE(HAVE_AS_X86_PCREL, 1,
272 [Define if your assembler supports PC relative relocs.])
276 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
277 libffi_cv_ro_eh_frame, [
278 libffi_cv_ro_eh_frame=no
279 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
280 if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
281 if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
282 libffi_cv_ro_eh_frame=yes
283 elif grep '.section.*eh_frame.*#alloc' conftest.c \
284 | grep -v '#write' > /dev/null; then
285 libffi_cv_ro_eh_frame=yes
290 if test "x$libffi_cv_ro_eh_frame" = xyes; then
291 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
292 [Define if .eh_frame sections should be read-only.])
293 AC_DEFINE(EH_FRAME_FLAGS, "a",
294 [Define to the flags needed for the .section .eh_frame directive.])
296 AC_DEFINE(EH_FRAME_FLAGS, "aw",
297 [Define to the flags needed for the .section .eh_frame directive.])
300 AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
301 libffi_cv_hidden_visibility_attribute, [
302 echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c
303 libffi_cv_hidden_visibility_attribute=no
304 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
305 if grep '\.hidden.*foo' conftest.s >/dev/null; then
306 libffi_cv_hidden_visibility_attribute=yes
311 if test $libffi_cv_hidden_visibility_attribute = yes; then
312 AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
313 [Define if __attribute__((visibility("hidden"))) is supported.])
317 #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
319 #define FFI_HIDDEN(name) .hidden name
321 #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
325 #define FFI_HIDDEN(name)
338 [ --enable-debug debugging mode],
339 if test "$enable_debug" = "yes"; then
340 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
343 AC_ARG_ENABLE(structs,
344 [ --disable-structs omit code for struct support],
345 if test "$enable_structs" = "no"; then
346 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
349 AC_ARG_ENABLE(raw-api,
350 [ --disable-raw-api make the raw api unavailable],
351 if test "$enable_raw_api" = "no"; then
352 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
355 AC_ARG_ENABLE(purify-safety,
356 [ --enable-purify-safety purify-safe mode],
357 if test "$enable_purify_safety" = "yes"; then
358 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
361 if test -n "$with_cross_host" &&
362 test x"$with_cross_host" != x"no"; then
363 toolexecdir='$(exec_prefix)/$(target_alias)'
364 toolexeclibdir='$(toolexecdir)/lib'
366 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
367 toolexeclibdir='$(libdir)'
369 multi_os_directory=`$CC -print-multi-os-directory`
370 case $multi_os_directory in
371 .) ;; # Avoid trailing /.
372 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
374 AC_SUBST(toolexecdir)
375 AC_SUBST(toolexeclibdir)
377 if test "${multilib}" = "yes"; then
378 multilib_arg="--enable-multilib"
383 AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
384 AC_CONFIG_COMMANDS(src, [
385 test -d src || mkdir src
386 test -d src/$TARGETDIR || mkdir src/$TARGETDIR
387 ], [TARGETDIR="$TARGETDIR"])
389 AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
391 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)