[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stegotorus/master] Have configure activate extended C library features and large file support. Detect whether 'ranlib' is unnecessary.
commit 491d09efb9e90c8762954f68e37efb7f42f38a16
Author: Zack Weinberg <zackw@xxxxxxx>
Date: Sat Jun 2 14:15:10 2012 -0700
Have configure activate extended C library features and large file support. Detect whether 'ranlib' is unnecessary.
---
configure.ac | 22 +++++++++----
m4/ranlib.m4 | 69 ++++++++++++++++++++++++++++++++++++++++
m4/system_extensions.m4 | 81 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 165 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 647879a..6dc4fe3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,10 +9,22 @@ AC_LANG([C++])
AM_INIT_AUTOMAKE([foreign nostdinc silent-rules subdir-objects])
AM_MAINTAINER_MODE([enable])
-### Programs ###
+### Compiler and language features ###
+AC_PROG_CC
AC_PROG_CXX
-AC_PROG_RANLIB
+AC_PROG_CXXCPP
+
+AX_SYS_EXTENSIONS
+AC_SYS_LARGEFILE
+
+AX_CXXFLAGS_STDCXX_11([ext])
+AX_CXX_DELETE_METHOD
+AX_CXX_STATIC_ASSERT
+
+### Programs ###
+
+AX_PROG_RANLIB
PKG_PROG_PKG_CONFIG
# We need python 2.7 for TestLoader.discover().
@@ -60,14 +72,10 @@ AC_SUBST(lib_CPPFLAGS)
AX_LIB_WINSOCK2
LIBS="$LIBS $ws32_LIBS"
-### Language features ###
+### System features ###
AC_CHECK_HEADERS([execinfo.h],,,[/**/])
-AX_CXXFLAGS_STDCXX_11([ext])
-AX_CXX_DELETE_METHOD
-AX_CXX_STATIC_ASSERT
-
### Output ###
AC_CONFIG_FILES([Makefile])
diff --git a/m4/ranlib.m4 b/m4/ranlib.m4
new file mode 100644
index 0000000..ce4fe33
--- /dev/null
+++ b/m4/ranlib.m4
@@ -0,0 +1,69 @@
+# SYNOPSIS
+#
+# AX_PROG_RANLIB
+#
+# DESCRIPTION
+#
+# In addition to everything AC_PROG_RANLIB does, determine whether it is
+# _necessary_ to run 'ranlib' after 'ar'. If it is unnecessary (which is
+# the case on most modern systems), reset the RANLIB variable to ':'.
+#
+# LICENSE
+#
+# Same as Autoconf proper.
+
+# serial 1
+
+# 'ranlib' may be needed to make it possible for objects that occur
+# later in an archive library to refer to symbols defined by objects
+# earlier in the archive. Therefore, the testing strategy is to
+# compile three small files where A refers to B refers to C, put C and
+# B in an archive *in that order*, and then see if we can link A
+# against the archive.
+
+AC_DEFUN([AX_PROG_RANLIB],
+[AC_CHECK_TOOL([AR], [ar])
+AC_CHECK_TOOL([RANLIB], [ranlib], [:])
+if test x$RANLIB != x:; then
+ AC_CACHE_CHECK([whether ranlib is necessary], [ac_cv_prog_RANLIB_necessary],
+ [AC_LANG_PUSH([C])
+
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ extern int B(void);
+ int main(void) { return B(); }
+ ]])],
+ [cp conftest.$ac_objext conftA.$ac_objext],
+ [AC_MSG_ERROR([failed to compile test file A])])
+
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ extern int C(void);
+ int B(void) { return C(); }
+ ]])],
+ [cp conftest.$ac_objext conftB.$ac_objext],
+ [AC_MSG_ERROR([failed to compile test file B])])
+
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ int C(void) { return 0; }
+ ]])],
+ [cp conftest.$ac_objext conftC.$ac_objext],
+ [AC_MSG_ERROR([failed to compile test file C])])
+
+ dnl There is no standard macro for creating an archive.
+ _AC_DO([$AR cru conftest.a conftC.$ac_objext conftB.$ac_objext]) ||
+ AC_MSG_ERROR([failed to create test archive])
+
+ dnl There's no good way to make AC_LINK_IFELSE do what we need.
+ AS_IF([_AC_DO([$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftA.$ac_objext conftest.a >&AS_MESSAGE_LOG_FD])],
+ [ac_cv_prog_RANLIB_necessary=no],
+ [AS_IF([_AC_DO([$RANLIB conftest.a && $CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftA.$ac_objext conftest.a >&AS_MESSAGE_LOG_FD])],
+ [ac_cv_prog_RANLIB_necessary=yes],
+ [AC_MSG_ERROR([test link failed with and without ranlib])])])
+
+ rm -f conftest$ac_exeext conft[ABC].$ac_objext conftest.a
+ AC_LANG_POP([C])
+ ])
+ if test $ac_cv_prog_RANLIB_necessary = no; then
+ RANLIB=:
+ fi
+fi
+])
diff --git a/m4/system_extensions.m4 b/m4/system_extensions.m4
new file mode 100644
index 0000000..46b2f9e
--- /dev/null
+++ b/m4/system_extensions.m4
@@ -0,0 +1,81 @@
+# SYNOPSIS
+#
+# AX_SYS_EXTENSIONS
+#
+# DESCRIPTION
+#
+# Functionally equivalent to the stock AC_USE_SYSTEM_EXTENSIONS, but:
+# does not trigger AC_CHECK_HEADER's backward compatibility mode;
+# does not make use of AC_INCLUDES_DEFAULT;
+# does not define _MINIX.
+#
+# LICENSE
+#
+# Same as Autoconf proper.
+
+# serial 1
+
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+#
+# Remember that #undef in AH_VERBATIM gets replaced with #define by
+# AC_DEFINE. The goal here is to define all known feature-enabling
+# macros, then, if reports of conflicts are made, disable macros that
+# cause problems on some platforms (such as __EXTENSIONS__).
+AC_DEFUN_ONCE([AX_SYS_EXTENSIONS],
+[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+AC_PROVIDE([AC_USE_SYSTEM_EXTENSIONS])dnl Suppress the stock macro if used.
+
+ AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=], [/**/])
+ if test "$MINIX" = yes; then
+ AC_DEFINE([_POSIX_SOURCE], [1],
+ [Define to 1 if you need to in order for `stat' and other
+ things to work.])
+ AC_DEFINE([_POSIX_1_SOURCE], [2],
+ [Define to 2 if the system does not provide POSIX.1 features
+ except with this defined.])
+ fi
+
+dnl Use a different key than __EXTENSIONS__, as that name broke existing
+dnl configure.ac when using autoheader 2.62.
+ AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
+[/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+])
+ AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
+ [ac_cv_safe_to_define___extensions__],
+ [AC_COMPILE_IFELSE(
+ dnl http://lists.gnu.org/archive/html/bug-gnulib/2006-02/msg00002.html
+ dnl implies that testing <stdlib.h> is adequate.
+ [AC_LANG_PROGRAM([[
+# define __EXTENSIONS__ 1
+# include <stdlib.h>
+ ]])],
+ [ac_cv_safe_to_define___extensions__=yes],
+ [ac_cv_safe_to_define___extensions__=no])])
+ test $ac_cv_safe_to_define___extensions__ = yes &&
+ AC_DEFINE([__EXTENSIONS__])
+ AC_DEFINE([_ALL_SOURCE])
+ AC_DEFINE([_GNU_SOURCE])
+ AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
+ AC_DEFINE([_TANDEM_SOURCE])
+])# AX_SYS_EXTENSIONS
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits