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