summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m4159
1 files changed, 156 insertions, 3 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index aaddfbfa3..32c80266e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -820,6 +820,160 @@ fi
])
+dnl GMP_LIBDIR
+dnl ----------
+dnl Establish $gmp_libdir, an expanded value of $libdir.
+dnl
+dnl The default for $libdir is "${exec_prefix}/lib" and the user may well
+dnl give something similar, perhaps using ${prefix}. In either case this
+dnl is normally expanded when "make" runs, allowing the prefix to be
+dnl specified during "make", per the GNU standards.
+dnl
+dnl $prefix and $exec_prefix can be NONE if not specified by the user with
+dnl --prefix and --exec_prefix. Autoconf leaves it until the end of
+dnl configure to default $prefix to $ac_default_prefix, and $exec_prefix in
+dnl turn to $prefix.
+
+AC_DEFUN(GMP_LIBDIR,
+[gmp_save_prefix=$prefix
+gmp_save_exec_prefix=$exec_prefix
+if test "$prefix" = NONE; then
+ prefix=$ac_default_prefix
+fi
+if test "$exec_prefix" = NONE; then
+ exec_prefix=$prefix
+fi
+eval gmp_libdir=$libdir
+prefix=$gmp_save_prefix
+exec_prefix=$gmp_save_exec_prefix
+])
+
+
+dnl GMP_LDFLAGS_SYMBOLIC
+dnl --------------------
+dnl Try to find a "symbolic" option for shared libraries, to resolve
+dnl intra-library function calls directly to their targets, rather than
+dnl going through the PLT or whatever.
+dnl
+dnl Suitable libtool --mode=link options are setup in AC_SUBST's of
+dnl LDFLAGS_CC_SYMBOLIC and LDFLAGS_CXX_SYMBOLIC.
+dnl
+dnl An effect of this is that an application cannot replace a GMP function
+dnl and get calls from within libgmp.so to reach that replacement. There
+dnl seems no good reason for an application to do this, and avoiding the
+dnl PLT is smaller and faster.
+dnl
+dnl The only downside to this option is that tune/tuneup.c probably won't
+dnl work in a shared-only build. We recommend it static anyway to avoid
+dnl PIC overheads, so this is no great loss.
+dnl
+dnl "gcc -symbolic"
+dnl This option is only available on some systems. When not available
+dnl a message "unrecognized option `-symbolic'" is printed, but the
+dnl exit code is still 0, hence the grep for that below.
+dnl
+dnl This option is checked before "ld -Bsymbolic", since on some
+dnl systems it does more than just that.
+dnl
+dnl "ld -Bsymbolic"
+dnl This is the usual SVR4/ELF way, supported and by vendor tools like
+dnl Solaris and by GNU binutils. It might be thought "gcc -symbolic"
+dnl would be available on all systems with this, but that's no so, in
+dnl particular it's not on GNU/Linux, so try this directly.
+dnl
+dnl If libtool is using "ld" to link, then a compiler -Wc option will be
+dnl silently ignored, and hence appear to succeed. We grep the libtool
+dnl command echos to ensure our option appears.
+dnl
+dnl Separate tests are run for C and C++, in case the two vary in what
+dnl works or what method libtool uses (cc or ld).
+dnl
+dnl Running the whole libtool lets us avoid getting too involved in how
+dnl shared libraries are created. And if an option we try works in a
+dnl compile and link like this, then there should be no risk of it later
+dnl failing with the real libgmp etc.
+
+AC_DEFUN(GMP_LDFLAGS_SYMBOLIC,
+[AC_REQUIRE([AC_PROG_LIBTOOL])
+if test "$enable_shared" = yes; then
+ GMP_LDFLAGS_CC_SYMBOLIC
+ if test "$want_cxx" = yes; then
+ GMP_LDFLAGS_CXX_SYMBOLIC
+ fi
+fi
+])
+
+AC_DEFUN(GMP_LDFLAGS_CC_SYMBOLIC,
+[AC_REQUIRE([AC_PROG_LIBTOOL])
+AC_REQUIRE([GMP_LIBDIR])
+AC_CACHE_CHECK([for C shared library -symbolic option],
+ gmp_cv_ldflags_cc_symbolic,
+[gmp_cv_ldflags_cc_symbolic=
+cat >conftest.c <<EOF
+int foo () { return 123; }
+EOF
+gmp_compile="$SHELL ./libtool --mode=compile $CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC 2>&AC_FD_CC"
+if AC_TRY_EVAL(gmp_compile); then
+ for i in "-Wc,-symbolic" "-Wl,-Bsymbolic"; do
+ gmp_link="$SHELL ./libtool --mode=link $CC $CFLAGS $LDFLAGS $GMP_LDFLAGS $i -rpath $gmp_libdir conftest.lo -o libconftest.la >conftest.out 2>&1"
+ if AC_TRY_EVAL(gmp_link); then
+ cat conftest.out >&AC_FD_CC
+ gmp_opt=`echo "$i" | sed 's/-W.,//'`
+ if grep -e "$gmp_opt" conftest.out >/dev/null; then
+ # must have our option appear in libtool's echos
+ if grep "unrecognized option \`$gmp_opt'" conftest.out >/dev/null; then
+ :
+ else
+ gmp_cv_ldflags_cc_symbolic=$i
+ break
+ fi
+ fi
+ else
+ cat conftest.out >&AC_FD_CC
+ fi
+ done
+fi
+rm -f conftest* $lt_cv_objdir/conftest* libconftest* $lt_cv_objdir/libconftest*
+])
+AC_SUBST(LDFLAGS_CC_SYMBOLIC,$gmp_cv_ldflags_cc_symbolic)
+])
+
+AC_DEFUN(GMP_LDFLAGS_CXX_SYMBOLIC,
+[AC_REQUIRE([AC_PROG_LIBTOOL])
+AC_REQUIRE([GMP_LIBDIR])
+AC_CACHE_CHECK([for C++ shared library -symbolic option],
+ gmp_cv_ldflags_cxx_symbolic,
+[gmp_cv_ldflags_cxx_symbolic=
+cat >conftest.cc <<EOF
+int foo (void) { return 123; }
+EOF
+gmp_compile="$SHELL ./libtool --mode=compile $CXX $CXXFLAGS $CPPFLAGS -c conftest.cc >&AC_FD_CC 2>&AC_FD_CC"
+if AC_TRY_EVAL(gmp_compile); then
+ for i in "-Wc,-symbolic" "-Wl,-Bsymbolic"; do
+ gmp_link="$SHELL ./libtool --mode=link $CXX $CXXFLAGS $LDFLAGS $GMP_LDFLAGS $i -rpath $gmp_libdir conftest.lo -o libconftest.la >conftest.out 2>&1"
+ if AC_TRY_EVAL(gmp_link); then
+ cat conftest.out >&AC_FD_CC
+ gmp_opt=`echo "$i" | sed 's/-W.,//'`
+ if grep -e "$gmp_opt" conftest.out >/dev/null; then
+ # must have our option appear in libtool's echos
+ if grep "unrecognized option \`$gmp_opt'" conftest.out >/dev/null; then
+ :
+ else
+ gmp_cv_ldflags_cxx_symbolic=$i
+ break
+ fi
+ fi
+ else
+ cat conftest.out >&AC_FD_CC
+ fi
+ done
+fi
+rm -f conftest* $lt_cv_objdir/conftest* libconftest* $lt_cv_objdir/libconftest*
+])
+AC_SUBST(LDFLAGS_CXX_SYMBOLIC,$gmp_cv_ldflags_cxx_symbolic)
+])
+
+
dnl GMP_INIT([M4-DEF-FILE])
dnl -----------------------
dnl Initializations for GMP config.m4 generation.
@@ -1293,9 +1447,8 @@ dnl The assembler directive to mark a label as a global symbol.
dnl
dnl ia64 - .global is standard, according to the Intel documentation.
dnl
-dnl hppa - ".export foo,entry" is demanded by HP hppa "as".
-dnl HP hppa "as" accepts .global, but it's not clear what it does, only
-dnl .export actually creates a global symbol.
+dnl hppa - ".export foo,entry" is demanded by HP hppa "as". ".global" is a
+dnl kind of import.
dnl
dnl other - .globl is usual.
dnl