commit 16dbf7bdf456cd27f36d036da11aa8b3dda3b22b Author: Robert Hogan robert@roberthogan.net Date: Thu Feb 24 20:52:23 2011 +0000
Clean up and comment configure.in --- configure.in | 169 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 89 insertions(+), 80 deletions(-)
diff --git a/configure.in b/configure.in index 113b09b..f74a3fd 100644 --- a/configure.in +++ b/configure.in @@ -1,17 +1,23 @@ -dnl Process this file with autoconf to produce a configure script. +############################################################################## +# 1. Initialize the autoconf build +############################################################################## + +# Process this file with autoconf to produce a configure script. AC_INIT() + +# Create a config.g file to store defines generated by configure AC_CONFIG_HEADER(config.h)
+# Automake initialization AM_INIT_AUTOMAKE(torsocks, 0.1)
-dnl Our default prefix is /usr/ since most people will be using torsocks -dnl on Linux systems and that /usr/local/ stuff annoys them -dnl AC_PREFIX_DEFAULT(/usr) +# Get hostname and other information. +AC_CANONICAL_HOST +dnl Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LN_S
-dnl if libdir hasn't been set by the user default it to /lib since -dnl torsocks needs to be on the root partition if put in the -dnl /etc/ld.so.preload file -dnl test "$libdir" = "${exec_prefix}/lib" && libdir="/lib"
dnl Arguments we allow AC_ARG_ENABLE(debug, @@ -21,15 +27,10 @@ AC_ARG_ENABLE(oldmethod, AC_ARG_ENABLE(envconf, [ --disable-envconf do not allow TORSOCKS_CONF_FILE to specify configuration file ])
-dnl ----------------------------------- -dnl Get hostname and other information. -dnl ----------------------------------- -AC_CANONICAL_HOST
-dnl Checks for programs. -AC_PROG_CC -AC_PROG_INSTALL -AC_PROG_LN_S +############################################################################## +# 2. Check for some standard headers and libraries +##############################################################################
dnl Check if the C compiler accepts -Wall AC_MSG_CHECKING(if the C compiler accepts -Wall) @@ -67,9 +68,12 @@ dnl Checks for library functions. AC_CHECK_FUNCS(strcspn strdup strerror strspn strtol mmap strcasecmp \ strncasecmp strtol,,[AC_MSG_ERROR("Required function not found")])
-dnl Find which version of gethostbyname_r we should be using (actually this -dnl isn't used right now). -dnl AX_FUNC_WHICH_GETHOSTBYNAME_R +############################################################################## +# 3. Determine libraries we need to include when linking libtorsocks. +# OpenBSD and OSX have some special requirements here. +# Also check the host we're building on, as some of the code +# in torsocks.c and elsewhere is platform-dependent. +##############################################################################
dnl First find the library that contains connect() (obviously dnl the most important library for us). Once we've found it @@ -90,6 +94,7 @@ if test "${CONNECTLIB}" = ""; then AC_MSG_ERROR('Could not find library containing connect()') fi
+ dnl Check for socket AC_CHECK_FUNC(socket,, [ AC_CHECK_LIB(socket, socket,,AC_MSG_ERROR("socket function not found"))]) @@ -102,43 +107,49 @@ AC_CHECK_FUNC(inet_aton, AC_DEFINE([HAVE_INET_ATON],[],[Description]), [ LIBS="${LIBS} -lnsl" ], [ AC_MSG_ERROR("Neither inet_aton or inet_addr present")])])])
+ dnl Look for gethostbyname (needed by torsocks) AC_CHECK_FUNC(gethostbyname, AC_DEFINE([HAVE_GETHOSTBYNAME],[],[Description]), [ AC_CHECK_LIB(xnet, gethostbyname, AC_DEFINE([HAVE_GETHOSTBYNAME],[],[Description]), [ AC_MSG_ERROR(["gethostbyname not found, name lookups in " \ "torsocks disabled"])])])
-dnl The simple programs (saveme and inspectsocks) have no further -dnl requirements, so save the libs needed here and use them in the -dnl Makefile -SIMPLELIBS=${LIBS} -LIBS=
-dnl Checks for libraries. -dnl Replace `main' with a function in -ldl: +dnl Our main libs to link against are -dl and -lresolv. +AC_SEARCH_LIBS(dlopen, [c dl]) +# Required to compile on machines that export res_query with a double underscore. +# Sourced from gnupg configure via cvsnt. +AC_SEARCH_LIBS(res_query,resolv bind,,AC_SEARCH_LIBS(__res_query,resolv bind)) +AC_DEFINE([SUPPORT_RES_API],[],[Support the res_query family of calls])
-AC_CHECK_LIB(dl, dlsym, [ tempdso="yes" ],tempdso="no") -if test "$tempdso" = "no"; then - AC_CHECK_LIB(c, dlsym,,AC_MSG_ERROR("dlsym() not found in libc or libdl." \ - "Check your system for libc.so and/or libdl.so.")) -fi
-AC_CHECK_FUNC(res_query, , - [AC_CHECK_LIB(resolv, res_query, [], - [ save_libs="$LIBS" - LIBS="-lresolv $LIBS" - AC_MSG_CHECKING([for res_query in -lresolv (alternate version)]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[#include <resolv.h>]], [[res_query(0,0,0,0,0)]])], - [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no) - LIBS="$save_libs" - AC_CHECK_LIB(resolv, res_query, - [], [ AC_MSG_ERROR(res_query not found in libc or libresolve. Check your system for libc.so and/or libresolve.so.) ] ) ] ) ] ) - ] -) +dnl OpenBSD needs -lpthread. It also doesn't support AI_V4MAPPED. +case $host in +*-*-openbsd*) + AC_DEFINE(OPENBSD, 1, "Define to handle OpenBSD") + AC_SEARCH_LIBS(pthread_create, [pthread]) + AC_SEARCH_LIBS(pthread_detach, [pthread]) + ;; +*-*-freebsd*) + AC_DEFINE(FREEBSD, 1, "Define to handle FreeBSD") + ;; +*-*-darwin*) + dnl Needed to compile tests. + dnl See https://bugs.g10code.com/gnupg/issue1292: + dnl "On OS X (at least in 10.6 and I believe starting at 10.3) the DNS resolution + dnl services fail to compile. This is a result of the addition of BIND9 compatible + dnl resolution libraries on OS X that are being picked up by the configure script + dnl instead of -lresolv causing the tests for useable resolution services to fail + dnl thus disabling features like pka auto lookup." + LIBS="-lresolv $LIBS" + ;; +esac
-AC_DEFINE([SUPPORT_RES_API],[],[Support the res_query family of calls]) + +############################################################################## +# 3. Check if we need to use --enable-oldmethod, regardless of what was +# given on the ./configure command line. +##############################################################################
dnl If we're using gcc here define _GNU_SOURCE AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h) @@ -174,6 +185,10 @@ if test "x${enable_envconf}" = "x"; then AC_DEFINE([ALLOW_ENV_CONFIG],[],[Description]) fi
+############################################################################## +# 3. If --enable-oldmethod was requested, perform the necessary checks +############################################################################## + if test "${enable_oldmethod}" = "yes"; then AC_DEFINE([USE_OLD_DLSYM],[],[Description]) oldmethod="yes" @@ -248,7 +263,16 @@ if test "${oldmethod}" = "yes"; then AC_MSG_RESULT($LIBC) fi
-dnl Find the correct select prototype on this machine +############################################################################## +# 4. Get the signatures for each of the functions we are going +# to override in torsocks. These are: +# connect, poll, select, close, getpeername, res_query, +# res_init, res_send, res_querydomain, gethostbyname, +# gethostbyaddr, getaddrinfo, getipnodebyname, sendto, +# sendmsg +############################################################################## + +dnl Find the correct select prototype on this machine AC_MSG_CHECKING(for correct select prototype) PROTO= NAMES='n, readfds, writefds, exceptfds, timeout' @@ -270,7 +294,8 @@ AC_MSG_RESULT([select(${PROTO})]) AC_DEFINE_UNQUOTED([SELECT_SIGNATURE],[${PROTO}],[Description]) AC_DEFINE_UNQUOTED([SELECT_ARGNAMES],[${NAMES}],[Argument names])
-dnl Find the correct connect prototype on this machine + +dnl Find the correct connect prototype on this machine AC_MSG_CHECKING(for correct connect prototype) PROTO= NAMES='__fd, __addr, __len' @@ -353,6 +378,7 @@ AC_MSG_RESULT([res_querydomain(${PROTO})]) AC_DEFINE_UNQUOTED([RES_QUERYDOMAIN_SIGNATURE], [${PROTO}],[Description]) AC_DEFINE_UNQUOTED([RES_QUERYDOMAIN_ARGNAMES],[${NAMES}],[Argument names])
+ dnl Find the correct res_send prototype on this machine AC_MSG_CHECKING(for correct res_send prototype) PROTO= @@ -513,15 +539,12 @@ NAMES='s, msg, flags' AC_DEFINE_UNQUOTED(SENDMSG_SIGNATURE, [${PROTO}], [Description]) AC_DEFINE_UNQUOTED([SENDMSG_ARGNAMES],[${NAMES}],[Argument names])
-dnl Output the special librarys (libdl etc needed for torsocks) -SPECIALLIBS=${LIBS} -AC_SUBST(SPECIALLIBS) -LIBS=${SIMPLELIBS}
-AC_SEARCH_LIBS(dlopen, [dl]) -# Required to compile on machines that export res_query with a double underscore. -# Sourced from gnupg configure via cvsnt. -AC_SEARCH_LIBS(res_query,resolv bind,,AC_SEARCH_LIBS(__res_query,resolv bind)) +############################################################################## +# 5. Determine how to preload libtorsocks.so on this system. +# On Linux this is with the LD_PRELOAD variable, on OSX +# we need to use DYLD_INSERT_LIBRARIES. +##############################################################################
TESTLDFLAGS="$LDFLAGS"
@@ -569,32 +592,13 @@ darwin*) ;; esac
-dnl OpenBSD needs -lpthread. It also doesn't support AI_V4MAPPED. -case $host in -*-*-openbsd*) - AC_DEFINE(OPENBSD, 1, "Define to handle OpenBSD") - AC_SEARCH_LIBS(pthread_create, [pthread]) - AC_SEARCH_LIBS(pthread_detach, [pthread]) - ;; -*-*-freebsd*) - AC_DEFINE(FREEBSD, 1, "Define to handle FreeBSD") - ;; -*-*-darwin*) - dnl Needed to compile tests. - dnl See https://bugs.g10code.com/gnupg/issue1292: - dnl "On OS X (at least in 10.6 and I believe starting at 10.3) the DNS resolution - dnl services fail to compile. This is a result of the addition of BIND9 compatible - dnl resolution libraries on OS X that are being picked up by the configure script - dnl instead of -lresolv causing the tests for useable resolution services to fail - dnl thus disabling features like pka auto lookup." - LIBS="-lresolv $LIBS" - ;; -esac - AC_SUBST(SHLIB_EXT) AC_SUBST(LD_PRELOAD)
- +############################################################################## +# 7. Determine where the install should write the default configuration +# file and where libtorsocks should read it from by default. +##############################################################################
if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix @@ -618,9 +622,12 @@ fi AC_DEFINE_UNQUOTED([CONF_FILE], ["${CONFDIR}/torsocks.conf"],[Description]) ])
+############################################################################## +# 8. Clean up and create some supporting scripts from their *.in files +############################################################################## + AC_LANG_C AC_PROG_CC - AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) @@ -629,8 +636,10 @@ AC_ENABLE_STATIC
AC_CONFIG_FILES([src/usewithtor src/torsocks src/torsocks.conf.5 src/torsocks.8 src/usewithtor.1 src/torsocks.1])
+dnl Output the Makefile for libtorsocks AC_OUTPUT(Makefile src/Makefile)
+dnl Output the Makefile for test/test_torsocks. dnl Dump any LDFLAGS that were only required for linking libtorsocks, such as -dynamiclib on OSX. LDFLAGS="$TESTLDFLAGS" AC_OUTPUT(test/Makefile)
tor-commits@lists.torproject.org