1 dnl Process this with autoconf to create configure
3 AC_INIT(fficonfig.h.in)
4 AM_CONFIG_HEADER(fficonfig.h)
6 # This works around the fact that libtool configuration may change LD
7 # for this particular configuration, but some shells, instead of
8 # keeping the changes in LD private, export them just because LD is
10 ORIGINAL_LD_FOR_MULTILIBS=$LD
12 dnl Default to --enable-multilib
13 AC_ARG_ENABLE(multilib,
14 [ --enable-multilib build many library versions (default)],
15 [case "${enableval}" in
18 *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
19 esac], [multilib=yes])dnl
21 dnl We may get other options which we don't document:
22 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
24 if test "${srcdir}" = "."; then
25 if test "${with_target_subdir}" != "."; then
26 libffi_basedir="${with_multisrctop}../"
28 libffi_basedir="${with_multisrctop}"
33 AC_SUBST(libffi_basedir)
34 AC_CONFIG_AUX_DIR(${libffi_basedir}..)
37 target_alias=${target_alias-$host_alias}
41 AM_INIT_AUTOMAKE(libffi,2.00-beta,no-define)
50 AC_FUNC_MMAP_BLACKLIST
52 dnl The -no-testsuite modules omit the test subdir.
53 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
58 i*86-*-linux*) TARGET=X86; TARGETDIR=x86;;
59 i*86-*-solaris*) TARGET=X86; TARGETDIR=x86;;
60 i*86-*-beos*) TARGET=X86; TARGETDIR=x86;;
61 i*86-*-freebsd*) TARGET=X86; TARGETDIR=x86;;
62 i*86-*-netbsdelf*) TARGET=X86; TARGETDIR=x86;;
63 i*86-*-win32*) TARGET=X86_WIN32; TARGETDIR=x86;;
64 i*86-*-cygwin*) TARGET=X86_WIN32; TARGETDIR=x86;;
65 i*86-*-mingw*) TARGET=X86_WIN32; TARGETDIR=x86;;
66 sparc-sun-4*) TARGET=SPARC; TARGETDIR=sparc;;
67 sparc*-sun-*) TARGET=SPARC; TARGETDIR=sparc;;
68 sparc-*-linux* | sparc-*-netbsdelf*) TARGET=SPARC; TARGETDIR=sparc;;
69 sparc64-*-linux* | sparc64-*-netbsd*) TARGET=SPARC; TARGETDIR=sparc;;
70 alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd* | alpha*-*-netbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
71 ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
72 m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
74 mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS_IRIX; TARGETDIR=mips;;
75 mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
76 powerpc*-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
77 powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
78 powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
79 powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
80 rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
81 arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;;
82 arm*-*-netbsdelf*) TARGET=ARM; TARGETDIR=arm;;
83 s390-*-linux-*) TARGET=S390; TARGETDIR=s390;;
84 s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
85 x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
86 sh-*-linux* | sh[[34]]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
87 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
90 AC_SUBST(AM_RUNTESTFLAGS)
92 if test $TARGETDIR = unknown; then
93 AC_ERROR("libffi has not been ported to $host.")
96 AM_CONDITIONAL(MIPS_IRIX, test x$TARGET = xMIPS_IRIX)
97 AM_CONDITIONAL(MIPS_LINUX, test x$TARGET = xMIPS_LINUX)
98 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
99 AM_CONDITIONAL(X86, test x$TARGET = xX86)
100 AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
101 AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
102 AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
103 AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
104 AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
105 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
106 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
107 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
108 AM_CONDITIONAL(S390, test x$TARGET = xS390)
109 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
110 AM_CONDITIONAL(SH, test x$TARGET = xSH)
111 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
114 xMIPS*) TARGET=MIPS ;;
119 AC_CHECK_FUNCS(memcpy)
122 AC_COMPILE_CHECK_SIZEOF(double)
123 AC_COMPILE_CHECK_SIZEOF(long double)
125 # Also AC_SUBST this variable for ffi.h.
127 if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
128 if test $ac_cv_sizeof_long_double != 0; then
130 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
133 AC_SUBST(HAVE_LONG_DOUBLE)
137 if test x$TARGET = xSPARC; then
138 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
139 libffi_cv_as_sparc_ua_pcrel, [
140 save_CFLAGS="$CFLAGS"
141 save_LDFLAGS="$LDFLAGS"
142 CFLAGS="$CFLAGS -fpic"
143 LDFLAGS="$LDFLAGS -shared"
144 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
145 [libffi_cv_as_sparc_ua_pcrel=yes],
146 [libffi_cv_as_sparc_ua_pcrel=no])
147 CFLAGS="$save_CFLAGS"
148 LDFLAGS="$save_LDFLAGS"])
149 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
150 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
151 [Define if your assembler and linker support unaligned PC relative relocs.])
154 AC_CACHE_CHECK([assembler .register pseudo-op support],
155 libffi_cv_as_register_pseudo_op, [
156 libffi_cv_as_register_pseudo_op=unknown
157 # Check if we have .register
158 AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
159 [libffi_cv_as_register_pseudo_op=yes],
160 [libffi_cv_as_register_pseudo_op=no])
162 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
163 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
164 [Define if your assembler supports .register.])
168 AC_CACHE_CHECK([whether .eh_frame section should be read-only],
169 libffi_cv_ro_eh_frame, [
170 libffi_cv_ro_eh_frame=no
171 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
172 if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
173 if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
174 libffi_cv_ro_eh_frame=yes
175 elif grep '.section.*eh_frame.*#alloc' conftest.c \
176 | grep -v '#write' > /dev/null; then
177 libffi_cv_ro_eh_frame=yes
182 if test "x$libffi_cv_ro_eh_frame" = xyes; then
183 AC_DEFINE(HAVE_RO_EH_FRAME, 1,
184 [Define if .eh_frame sections should be read-only.])
185 AC_DEFINE(EH_FRAME_FLAGS, "a",
186 [Define to the flags needed for the .section .eh_frame directive.])
188 AC_DEFINE(EH_FRAME_FLAGS, "aw",
189 [Define to the flags needed for the .section .eh_frame directive.])
198 [ --enable-debug debugging mode],
199 if test "$enable_debug" = "yes"; then
200 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
203 AC_ARG_ENABLE(structs,
204 [ --disable-structs omit code for struct support],
205 if test "$enable_structs" = "no"; then
206 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
209 AC_ARG_ENABLE(raw-api,
210 [ --disable-raw-api make the raw api unavailable],
211 if test "$enable_raw_api" = "no"; then
212 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
215 AC_ARG_ENABLE(purify-safety,
216 [ --enable-purify-safety purify-safe mode],
217 if test "$enable_purify_safety" = "yes"; then
218 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
221 if test -n "$with_cross_host" &&
222 test x"$with_cross_host" != x"no"; then
223 toolexecdir='$(exec_prefix)/$(target_alias)'
224 toolexeclibdir='$(toolexecdir)/lib'
226 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
227 toolexeclibdir='$(libdir)'
229 multi_os_directory=`$CC -print-multi-os-directory`
230 case $multi_os_directory in
231 .) ;; # Avoid trailing /.
232 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
234 AC_SUBST(toolexecdir)
235 AC_SUBST(toolexeclibdir)
237 #Figure out where generated headers like ffitarget.h get installed.
239 gcc_version_trigger=${srcdir}/../gcc/version.c
240 gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
241 gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
242 tool_include_dir='$(libdir)/gcc/$(target_alias)/'${gcc_version}/include
244 AC_SUBST(tool_include_dir)
245 AC_SUBST(gcc_version)
248 if test "${multilib}" = "yes"; then
249 multilib_arg="--enable-multilib"
254 AC_OUTPUT(include/Makefile testsuite/Makefile include/ffi.h Makefile,
256 if test -n "$CONFIG_FILES"; then
257 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
258 ac_file=Makefile . ${srcdir}/${libffi_basedir}../config-ml.in
264 with_multisubdir=${with_multisubdir}
265 ac_configure_args="${multilib_arg} ${ac_configure_args}"
266 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
267 libffi_basedir=${libffi_basedir}
270 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
272 # Make target subdirectories if required.
273 test -d src || mkdir src
274 test -d src/${TARGETDIR} || mkdir src/${TARGETDIR}
275 test -d include || mkdir include
277 AC_LINK_FILES(src/$TARGETDIR/ffitarget.h, include/ffitarget.h)