1 dnl Process this with autoconf to create configure
2 AC_INIT(fficonfig.h.in)
3 AM_CONFIG_HEADER(fficonfig.h)
5 # This works around the fact that libtool configuration may change LD
6 # for this particular configuration, but some shells, instead of
7 # keeping the changes in LD private, export them just because LD is
9 ORIGINAL_LD_FOR_MULTILIBS=$LD
11 dnl Default to --enable-multilib
12 AC_ARG_ENABLE(multilib,
13 [ --enable-multilib build many library versions (default)],
14 [case "${enableval}" in
17 *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
18 esac], [multilib=yes])dnl
20 dnl We may get other options which we don't document:
21 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
23 if test "${srcdir}" = "."; then
24 if test "${with_target_subdir}" != "."; then
25 libffi_basedir="${with_multisrctop}../"
27 libffi_basedir="${with_multisrctop}"
32 AC_SUBST(libffi_basedir)
33 AC_CONFIG_AUX_DIR(${libffi_basedir}..)
36 target_alias=${target_alias-$host_alias}
40 AM_INIT_AUTOMAKE(libffi,2.00-beta,no-define)
49 dnl The -no-testsuite modules omit the test subdir.
50 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
55 i*86-*-linux*) TARGET=X86; TARGETDIR=x86;;
56 i*86-*-solaris*) TARGET=X86; TARGETDIR=x86;;
57 i*86-*-beos*) TARGET=X86; TARGETDIR=x86;;
58 i*86-*-freebsd*) TARGET=X86; TARGETDIR=x86;;
59 i*86-*-netbsdelf*) TARGET=X86; TARGETDIR=x86;;
60 i*86-*-win32*) TARGET=X86_WIN32; TARGETDIR=x86;;
61 i*86-*-cygwin*) TARGET=X86_WIN32; TARGETDIR=x86;;
62 i*86-*-mingw*) TARGET=X86_WIN32; TARGETDIR=x86;;
63 sparc-sun-4*) TARGET=SPARC; TARGETDIR=sparc;;
64 sparc*-sun-*) TARGET=SPARC; TARGETDIR=sparc;;
65 sparc-*-linux* | sparc-*-netbsdelf*) TARGET=SPARC; TARGETDIR=sparc;;
66 sparc64-*-linux* | sparc64-*-netbsd*) TARGET=SPARC; TARGETDIR=sparc;;
67 alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd* | alpha*-*-netbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
68 ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
69 m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
71 mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS_IRIX; TARGETDIR=mips;;
72 mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
73 powerpc*-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
74 powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
75 powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
76 powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
77 rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
78 arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;;
79 arm*-*-netbsdelf*) TARGET=ARM; TARGETDIR=arm;;
80 s390-*-linux-*) TARGET=S390; TARGETDIR=s390;;
81 s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
82 x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
83 sh-*-linux* | sh[[34]]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
84 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
87 AC_SUBST(AM_RUNTESTFLAGS)
89 if test $TARGETDIR = unknown; then
90 AC_ERROR("libffi has not been ported to $host.")
93 AM_CONDITIONAL(MIPS_IRIX, test x$TARGET = xMIPS_IRIX)
94 AM_CONDITIONAL(MIPS_LINUX, test x$TARGET = xMIPS_LINUX)
95 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
96 AM_CONDITIONAL(X86, test x$TARGET = xX86)
97 AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
98 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
99 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
100 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
101 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
102 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
103 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
104 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
105 AM_CONDITIONAL(S390, test x$TARGET = xS390)
106 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
107 AM_CONDITIONAL(SH, test x$TARGET = xSH)
108 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
111 xMIPS*) TARGET=MIPS ;;
116 AC_CHECK_FUNCS(memcpy)
119 AC_COMPILE_CHECK_SIZEOF(double)
120 AC_COMPILE_CHECK_SIZEOF(long double)
122 # Also AC_SUBST this variable for ffi.h.
124 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
125 if test $ac_cv_sizeof_long_double != 0; then
127 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
130 AC_SUBST(HAVE_LONG_DOUBLE)
134 if test x$TARGET = xSPARC; then
135 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
136 libffi_cv_as_sparc_ua_pcrel, [
137 save_CFLAGS="$CFLAGS"
138 save_LDFLAGS="$LDFLAGS"
139 CFLAGS="$CFLAGS -fpic"
140 LDFLAGS="$LDFLAGS -shared"
141 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
142 [libffi_cv_as_sparc_ua_pcrel=yes],
143 [libffi_cv_as_sparc_ua_pcrel=no])
144 CFLAGS="$save_CFLAGS"
145 LDFLAGS="$save_LDFLAGS"])
146 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
147 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
148 [Define if your assembler and linker support unaligned PC relative relocs.])
151 AC_CACHE_CHECK([assembler .register pseudo-op support],
152 libffi_cv_as_register_pseudo_op, [
153 libffi_cv_as_register_pseudo_op=unknown
154 # Check if we have .register
155 AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
156 [libffi_cv_as_register_pseudo_op=yes],
157 [libffi_cv_as_register_pseudo_op=no])
159 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
160 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
161 [Define if your assembler supports .register.])
165 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
166 libffi_cv_ro_eh_frame, [
167 libffi_cv_ro_eh_frame=no
168 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
169 if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
170 if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
171 libffi_cv_ro_eh_frame=yes
172 elif grep '.section.*eh_frame.*#alloc' conftest.c \
173 | grep -v '#write' > /dev/null; then
174 libffi_cv_ro_eh_frame=yes
179 if test "x$libffi_cv_ro_eh_frame" = xyes; then
180 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
181 [Define if .eh_frame sections should be read-only.])
182 AC_DEFINE(EH_FRAME_FLAGS, "a",
183 [Define to the flags needed for the .section .eh_frame directive.])
185 AC_DEFINE(EH_FRAME_FLAGS, "aw",
186 [Define to the flags needed for the .section .eh_frame directive.])
195 [ --enable-debug debugging mode],
196 if test "$enable_debug" = "yes"; then
197 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
200 AC_ARG_ENABLE(structs,
201 [ --disable-structs omit code for struct support],
202 if test "$enable_structs" = "no"; then
203 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
206 AC_ARG_ENABLE(raw-api,
207 [ --disable-raw-api make the raw api unavailable],
208 if test "$enable_raw_api" = "no"; then
209 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
212 AC_ARG_ENABLE(purify-safety,
213 [ --enable-purify-safety purify-safe mode],
214 if test "$enable_purify_safety" = "yes"; then
215 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
218 if test -n "$with_cross_host" &&
219 test x"$with_cross_host" != x"no"; then
220 toolexecdir='$(exec_prefix)/$(target_alias)'
221 toolexeclibdir='$(toolexecdir)/lib'
223 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
224 toolexeclibdir='$(libdir)'
226 multi_os_directory=`$CC -print-multi-os-directory`
227 case $multi_os_directory in
228 .) ;; # Avoid trailing /.
229 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
231 AC_SUBST(toolexecdir)
232 AC_SUBST(toolexeclibdir)
234 if test "${multilib}" = "yes"; then
235 multilib_arg="--enable-multilib"
240 AC_OUTPUT(include/Makefile testsuite/Makefile include/ffi.h Makefile,
242 if test -n "$CONFIG_FILES"; then
243 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
244 ac_file=Makefile . ${srcdir}/${libffi_basedir}../config-ml.in
250 with_multisubdir=${with_multisubdir}
251 ac_configure_args="${multilib_arg} ${ac_configure_args}"
252 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
253 libffi_basedir=${libffi_basedir}
256 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
258 # Make target subdirectories if required.
259 test -d src || mkdir src
260 test -d src/${TARGETDIR} || mkdir src/${TARGETDIR}
261 test -d include || mkdir include
263 AC_LINK_FILES(src/$TARGETDIR/ffitarget.h, include/ffitarget.h)