1dnl Process this with autoconf to create configure 2 3AC_PREREQ(2.64) 4 5AC_INIT([libffi], [3.99999], [http://github.com/atgreen/libffi/issues]) 6AC_CONFIG_HEADERS([fficonfig.h]) 7 8AM_ENABLE_MULTILIB(, ..) 9 10AC_CANONICAL_SYSTEM 11target_alias=${target_alias-$host_alias} 12 13AM_INIT_AUTOMAKE([no-dist]) 14 15# See if makeinfo has been installed and is modern enough 16# that we can use it. 17ACX_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]*]) 20AM_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. 27AC_MSG_CHECKING(generated-files-in-srcdir) 28AC_ARG_ENABLE(generated-files-in-srcdir, 29AS_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]) 37AC_MSG_RESULT($enable_generated_files_in_srcdir) 38AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes) 39 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. 44# Also save and restore CFLAGS, since AC_PROG_CC will come up with 45# defaults of its own if none are provided. 46 47m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) 48m4_define([_AC_ARG_VAR_PRECIOUS],[]) 49save_CFLAGS=$CFLAGS 50AC_PROG_CC 51AC_PROG_CXX 52CFLAGS=$save_CFLAGS 53m4_undefine([_AC_ARG_VAR_PRECIOUS]) 54m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) 55 56AC_SUBST(CFLAGS) 57 58AM_PROG_AS 59AM_PROG_CC_C_O 60AC_PROG_LIBTOOL 61 62# Test for 64-bit build. 63AC_CHECK_SIZEOF([size_t]) 64 65AM_MAINTAINER_MODE 66 67AC_CHECK_HEADERS(sys/mman.h) 68AC_CHECK_FUNCS([mmap mkostemp]) 69AC_FUNC_MMAP_BLACKLIST 70 71dnl The -no-testsuite modules omit the test subdir. 72AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) 73 74TARGETDIR="unknown" 75HAVE_LONG_DOUBLE_VARIANT=0 76 77. ${srcdir}/configure.host 78 79if test -n "${UNSUPPORTED}"; then 80 AC_MSG_ERROR(["libffi has not been ported to $host."]) 81fi 82 83AC_SUBST(AM_RUNTESTFLAGS) 84AC_SUBST(AM_LTLDFLAGS) 85 86AC_HEADER_STDC 87AC_CHECK_FUNCS(memcpy) 88AC_FUNC_ALLOCA 89 90AC_CHECK_SIZEOF(double) 91AC_CHECK_SIZEOF(long double) 92 93# Also AC_SUBST this variable for ffi.h. 94if test -z "$HAVE_LONG_DOUBLE"; then 95 HAVE_LONG_DOUBLE=0 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]) 99 HAVE_LONG_DOUBLE=1 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 105 fi 106 fi 107fi 108AC_SUBST(HAVE_LONG_DOUBLE) 109AC_SUBST(HAVE_LONG_DOUBLE_VARIANT) 110 111AC_C_BIGENDIAN 112 113GCC_AS_CFI_PSEUDO_OP 114 115case "$TARGET" in 116 SPARC) 117 AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs], 118 libffi_cv_as_sparc_ua_pcrel, [ 119 save_CFLAGS="$CFLAGS" 120 save_LDFLAGS="$LDFLAGS" 121 CFLAGS="$CFLAGS -fpic" 122 LDFLAGS="$LDFLAGS -shared" 123 AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],, 124 [libffi_cv_as_sparc_ua_pcrel=yes], 125 [libffi_cv_as_sparc_ua_pcrel=no]) 126 CFLAGS="$save_CFLAGS" 127 LDFLAGS="$save_LDFLAGS"]) 128 if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then 129 AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1, 130 [Define if your assembler and linker support unaligned PC relative relocs.]) 131 fi 132 133 AC_CACHE_CHECK([assembler .register pseudo-op support], 134 libffi_cv_as_register_pseudo_op, [ 135 libffi_cv_as_register_pseudo_op=unknown 136 # Check if we have .register 137 AC_TRY_COMPILE(,[asm (".register %g2, #scratch");], 138 [libffi_cv_as_register_pseudo_op=yes], 139 [libffi_cv_as_register_pseudo_op=no]) 140 ]) 141 if test "x$libffi_cv_as_register_pseudo_op" = xyes; then 142 AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1, 143 [Define if your assembler supports .register.]) 144 fi 145 ;; 146 147 X86*) 148 AC_CACHE_CHECK([assembler supports pc related relocs], 149 libffi_cv_as_x86_pcrel, [ 150 libffi_cv_as_x86_pcrel=no 151 echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s 152 if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then 153 libffi_cv_as_x86_pcrel=yes 154 fi 155 ]) 156 if test "x$libffi_cv_as_x86_pcrel" = xyes; then 157 AC_DEFINE(HAVE_AS_X86_PCREL, 1, 158 [Define if your assembler supports PC relative relocs.]) 159 fi 160 ;; 161 162 S390) 163 AC_CACHE_CHECK([compiler uses zarch features], 164 libffi_cv_as_s390_zarch, [ 165 libffi_cv_as_s390_zarch=no 166 echo 'void foo(void) { bar(); bar(); }' > conftest.c 167 if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then 168 if grep -q brasl conftest.s; then 169 libffi_cv_as_s390_zarch=yes 170 fi 171 fi 172 ]) 173 if test "x$libffi_cv_as_s390_zarch" = xyes; then 174 AC_DEFINE(HAVE_AS_S390_ZARCH, 1, 175 [Define if the compiler uses zarch features.]) 176 fi 177 ;; 178esac 179 180# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. 181AC_ARG_ENABLE(pax_emutramp, 182 [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], 183 if test "$enable_pax_emutramp" = "yes"; then 184 AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1, 185 [Define this if you want to enable pax emulated trampolines]) 186 fi) 187 188FFI_EXEC_TRAMPOLINE_TABLE=0 189case "$target" in 190 *arm*-apple-darwin* | aarch64-apple-darwin*) 191 FFI_EXEC_TRAMPOLINE_TABLE=1 192 AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1, 193 [Cannot use PROT_EXEC on this target, so, we revert to 194 alternative means]) 195 ;; 196 *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) 197 AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, 198 [Cannot use malloc on this target, so, we revert to 199 alternative means]) 200 ;; 201esac 202AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) 203AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) 204 205if test x$TARGET = xX86_64; then 206 AC_CACHE_CHECK([toolchain supports unwind section type], 207 libffi_cv_as_x86_64_unwind_section_type, [ 208 cat > conftest1.s << EOF 209.text 210.globl foo 211foo: 212jmp bar 213.section .eh_frame,"a",@unwind 214bar: 215EOF 216 217 cat > conftest2.c << EOF 218extern void foo(); 219int main(){foo();} 220EOF 221 222 libffi_cv_as_x86_64_unwind_section_type=no 223 # we ensure that we can compile _and_ link an assembly file containing an @unwind section 224 # since the compiler can support it and not the linker (ie old binutils) 225 if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \ 226 $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then 227 libffi_cv_as_x86_64_unwind_section_type=yes 228 fi 229 ]) 230 if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then 231 AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1, 232 [Define if your assembler supports unwind section type.]) 233 fi 234fi 235 236if test "x$GCC" = "xyes"; then 237 AC_CACHE_CHECK([whether .eh_frame section should be read-only], 238 libffi_cv_ro_eh_frame, [ 239 libffi_cv_ro_eh_frame=no 240 echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c 241 if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then 242 objdump -h conftest.o > conftest.dump 2>&1 243 libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` 244 if test "x$libffi_eh_frame_line" != "x"; then 245 libffi_test_line=`expr $libffi_eh_frame_line + 1`p 246 sed -n $libffi_test_line conftest.dump > conftest.line 247 if grep READONLY conftest.line > /dev/null; then 248 libffi_cv_ro_eh_frame=yes 249 fi 250 fi 251 fi 252 rm -f conftest.* 253 ]) 254 if test "x$libffi_cv_ro_eh_frame" = xyes; then 255 AC_DEFINE(HAVE_RO_EH_FRAME, 1, 256 [Define if .eh_frame sections should be read-only.]) 257 AC_DEFINE(EH_FRAME_FLAGS, "a", 258 [Define to the flags needed for the .section .eh_frame directive. ]) 259 else 260 AC_DEFINE(EH_FRAME_FLAGS, "aw", 261 [Define to the flags needed for the .section .eh_frame directive. ]) 262 fi 263 264 AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], 265 libffi_cv_hidden_visibility_attribute, [ 266 echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c 267 libffi_cv_hidden_visibility_attribute=no 268 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then 269 if grep '\.hidden.*foo' conftest.s >/dev/null; then 270 libffi_cv_hidden_visibility_attribute=yes 271 fi 272 fi 273 rm -f conftest.* 274 ]) 275 if test $libffi_cv_hidden_visibility_attribute = yes; then 276 AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, 277 [Define if __attribute__((visibility("hidden"))) is supported.]) 278 fi 279fi 280 281AH_BOTTOM([ 282#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 283#ifdef LIBFFI_ASM 284#define FFI_HIDDEN(name) .hidden name 285#else 286#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) 287#endif 288#else 289#ifdef LIBFFI_ASM 290#define FFI_HIDDEN(name) 291#else 292#define FFI_HIDDEN 293#endif 294#endif 295]) 296 297AC_SUBST(TARGET) 298AC_SUBST(TARGETDIR) 299 300changequote(<,>) 301TARGET_OBJ= 302for i in $SOURCES; do 303 TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'` 304done 305changequote([,]) 306AC_SUBST(TARGET_OBJ) 307 308AC_SUBST(SHELL) 309 310AC_ARG_ENABLE(debug, 311[ --enable-debug debugging mode], 312 if test "$enable_debug" = "yes"; then 313 AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.]) 314 fi) 315AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") 316 317AC_ARG_ENABLE(structs, 318[ --disable-structs omit code for struct support], 319 if test "$enable_structs" = "no"; then 320 AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.]) 321 fi) 322AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") 323 324AC_ARG_ENABLE(raw-api, 325[ --disable-raw-api make the raw api unavailable], 326 if test "$enable_raw_api" = "no"; then 327 AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) 328 fi) 329 330AC_ARG_ENABLE(purify-safety, 331[ --enable-purify-safety purify-safe mode], 332 if test "$enable_purify_safety" = "yes"; then 333 AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) 334 fi) 335 336if test -n "$with_cross_host" && 337 test x"$with_cross_host" != x"no"; then 338 toolexecdir='$(exec_prefix)/$(target_alias)' 339 toolexeclibdir='$(toolexecdir)/lib' 340else 341 toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 342 toolexeclibdir='$(libdir)' 343fi 344multi_os_directory=`$CC -print-multi-os-directory` 345case $multi_os_directory in 346 .) ;; # Avoid trailing /. 347 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 348esac 349AC_SUBST(toolexecdir) 350AC_SUBST(toolexeclibdir) 351 352if test "${multilib}" = "yes"; then 353 multilib_arg="--enable-multilib" 354else 355 multilib_arg= 356fi 357 358# Check linker support. 359LIBAT_ENABLE_SYMVERS 360 361# Determine what GCC version number to use in filesystem paths. 362GCC_BASE_VER 363 364AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) 365AC_CONFIG_COMMANDS(src, [ 366test -d src || mkdir src 367test -d src/$TARGETDIR || mkdir src/$TARGETDIR 368], [TARGETDIR="$TARGETDIR"]) 369 370AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) 371 372AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) 373 374AC_OUTPUT 375