[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torsocks/master] Rename configure.in and improve it
commit c42326a036a9cadaf16aad741c969b44f29ea737
Author: David Goulet <dgoulet@xxxxxxxxx>
Date: Wed May 29 16:57:24 2013 -0400
Rename configure.in and improve it
Signed-off-by: David Goulet <dgoulet@xxxxxxxxx>
---
configure.ac | 655 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
configure.in | 645 ---------------------------------------------------------
2 files changed, 655 insertions(+), 645 deletions(-)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..4bf2e36
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,655 @@
+##############################################################################
+# 1. Initialize the autoconf build
+##############################################################################
+
+# Process this file with autoconf to produce a configure script.
+AC_INIT([torsocks], [2.0.0-rc1],[jacob@xxxxxxxxxxxxx],[],[https://torproject.org])
+AC_CONFIG_AUX_DIR([config])
+AC_CANONICAL_TARGET
+# Get hostname and other information.
+AC_CANONICAL_HOST
+AC_CONFIG_MACRO_DIR([config])
+
+# Create a config.g file to store defines generated by configure
+AC_CONFIG_HEADER([include/config.h])
+
+# Automake initialization
+AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
+
+# Silent compilation. Easier to spot errors!
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+
+dnl Arguments we allow
+AC_ARG_ENABLE(debug,
+[ --disable-debug disable ALL error messages from torsocks ])
+AC_ARG_ENABLE(oldmethod,
+[ --enable-oldmethod use the old method to override connect ])
+AC_ARG_ENABLE(envconf,
+[ --disable-envconf do not allow TORSOCKS_CONF_FILE to specify configuration file ])
+
+
+##############################################################################
+# 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)
+OLDCFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wall"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
+ CFLAGS="$OLDCFLAGS"
+ AC_MSG_RESULT(no)])
+
+dnl Checks for standard header files.
+AC_HEADER_STDC
+
+dnl Check for the dynamic loader function header
+AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR("dlfcn.h not found"))
+
+dnl Check for the socket header
+AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR("sys/socket.h not found"))
+
+dnl Check for the arpa/inet.h header (inet_ntoa and inet_addr)
+AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR("arpa/inet.h not found"))
+
+dnl Check for the fcntl header
+AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR("fcntl.h not found"))
+
+dnl Check for the poll header
+AC_CHECK_HEADER(sys/poll.h,,AC_MSG_ERROR("sys/poll.h not found"))
+
+dnl Check for the mmap header
+AC_CHECK_HEADER(sys/mman.h,,AC_MSG_ERROR("sys/mman.h not found"))
+
+dnl Other headers we're interested in
+AC_CHECK_HEADERS(unistd.h)
+
+dnl Checks for library functions.
+AC_CHECK_FUNCS(strcspn strdup strerror strspn strtol mmap strcasecmp \
+ strncasecmp strtol,,[AC_MSG_ERROR("Required function not found")])
+
+##############################################################################
+# 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
+dnl we chuck it on the end of LIBS, that lib may end up there
+dnl more than once (since we do our search with an empty libs
+dnl list) but that isn't a problem
+OLDLIBS="${LIBS}"
+LIBS=
+CONNECTLIB=
+for LIB in c socket; do
+ AC_CHECK_LIB("${LIB}",connect,[
+ CONNECTLIB="${LIB}"
+ break
+ ],)
+done
+LIBS="${OLDLIBS} -l${CONNECTLIB}"
+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"))])
+
+dnl Check for a function to convert an ascii ip address
+dnl to a sin_addr.
+AC_CHECK_FUNC(inet_aton, AC_DEFINE([HAVE_INET_ATON],[],[Description]), [
+ AC_CHECK_FUNC(inet_addr, AC_DEFINE([HAVE_INET_ADDR],[],[Description]), [
+ AC_CHECK_LIB(nsl, inet_addr, [ AC_DEFINE([HAVE_INET_ADDR],[],[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 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])
+
+
+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
+
+
+##############################################################################
+# 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)
+AC_EGREP_CPP(yes,
+[
+ #include <dlfcn.h>
+ #ifdef RTLD_NEXT
+ yes
+ #endif
+], [
+ AC_MSG_RESULT(yes)
+], [
+ AC_MSG_RESULT(no)
+ AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h with _GNU_SOURCE)
+ AC_EGREP_CPP(yes,
+ [
+ #define _GNU_SOURCE
+ #include <dlfcn.h>
+ #ifdef RTLD_NEXT
+ yes
+ #endif
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([USE_GNU_SOURCE],[],[Description])
+ ], [
+ AC_MSG_RESULT(no)
+ AC_DEFINE([USE_OLD_DLSYM],[],[Description])
+ oldmethod="yes"
+ ])
+])
+
+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"
+fi
+
+dnl If we have to use the old method of overriding connect (i.e no
+dnl RTLD_NEXT) we need to know the location of the library that
+dnl contains connect(), select(), poll() and close()
+if test "${oldmethod}" = "yes"; then
+ dnl We need to find the path to the library, to do
+ dnl this we use find on the usual suspects, i.e /lib and
+ dnl /usr/lib
+
+ dnl Check that find is available, it should be somehere
+ dnl in the path
+ AC_CHECK_PROG(FIND, find, find)
+ if test "${FIND}" = ""; then
+ AC_MSG_ERROR('find not found in path')
+ fi
+
+ dnl Find tail, it should always be somewhere in the path
+ dnl but for safety's sake
+ AC_CHECK_PROG(TAIL, tail, tail)
+ if test "${TAIL}" = ""; then
+ AC_MSG_ERROR('tail not found in path')
+ fi
+
+ dnl Now find the library we need
+ AC_MSG_CHECKING(location of lib${CONNECTLIB}.so)
+ LIBCONNECT=
+ for DIR in '/lib' '/usr/lib'; do
+ if test "${LIBCONNECT}" = ""; then
+ LIBCONNECT=`$FIND $DIR -name "lib${CONNECTLIB}.so.?" 2>/dev/null | $TAIL -1`
+ fi
+ done
+ AC_DEFINE_UNQUOTED([LIBCONNECT],["${LIBCONNECT}"],[Description])
+ if test "${LIBCONNECT}" = ""; then
+ AC_MSG_ERROR("not found!")
+ fi
+
+ AC_MSG_RESULT($LIBCONNECT)
+
+ dnl Now find the resolve library we need
+ AC_MSG_CHECKING(location of libresolv.so)
+ LIBRESOLV=
+ for DIR in '/lib' '/usr/lib'; do
+ if test "${LIBRESOLV}" = ""; then
+ LIBRESOLV=`$FIND $DIR -name "libresolv.so.?" 2>/dev/null | $TAIL -1`
+ fi
+ done
+ AC_DEFINE_UNQUOTED([LIBRESOLV],["${LIBRESOLV}"],[Description])
+ if test "${LIBRESOLV}" = ""; then
+ AC_MSG_ERROR("not found!")
+ fi
+
+ AC_MSG_RESULT($LIBRESOLV)
+
+ dnl close() should be in libc, find it
+ AC_MSG_CHECKING(location of libc.so)
+ LIBC=
+ for DIR in '/lib' '/usr/lib'; do
+ if test "${LIBC}" = ""; then
+ LIBC=`$FIND $DIR -name "libc.so.?" 2>/dev/null | $TAIL -1`
+ fi
+ done
+
+ AC_DEFINE_UNQUOTED([LIBC],["${LIBC}"],[Description])
+ if test "${LIBC}" = ""; then
+ AC_MSG_ERROR("not found!")
+ fi
+
+ AC_MSG_RESULT($LIBC)
+fi
+
+##############################################################################
+# 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'
+for testproto in 'int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout'
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+ int select($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+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
+AC_MSG_CHECKING(for correct connect prototype)
+PROTO=
+NAMES='__fd, __addr, __len'
+PROTO1='int __fd, const struct sockaddr * __addr, int __len'
+PROTO2='int __fd, const struct sockaddr_in * __addr, socklen_t __len'
+PROTO3='int __fd, struct sockaddr * __addr, int __len'
+PROTO4='int __fd, const struct sockaddr * __addr, socklen_t __len'
+for testproto in "${PROTO1}" \
+ "${PROTO2}" \
+ "${PROTO3}" \
+ "${PROTO4}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ int connect($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([connect(${PROTO})])
+AC_DEFINE_UNQUOTED([CONNECT_SIGNATURE],[${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([CONNECT_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Pick which of the sockaddr type arguments we need for
+dnl connect(), we need to cast one of ours to it later
+SOCKETARG="struct sockaddr *"
+case "${PROTO}" in
+ *sockaddr_in*)
+ SOCKETARG="struct sockaddr_in *"
+ ;;
+esac
+AC_DEFINE_UNQUOTED([CONNECT_SOCKARG],[${SOCKETARG}],[Description])
+
+dnl Find the correct close prototype on this machine
+AC_MSG_CHECKING(for correct close prototype)
+PROTO=
+NAMES='fd'
+PROTO1='int fd'
+for testproto in "${PROTO1}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <stdlib.h>
+ int close($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([close(${PROTO})])
+AC_DEFINE_UNQUOTED([CLOSE_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([CLOSE_ARGNAMES],[${NAMES}],[Argument names])
+
+
+dnl Find the correct res_querydomain prototype on this machine
+AC_MSG_CHECKING(for correct res_querydomain prototype)
+PROTO=
+NAMES='name, domain, class, type, answer, anslen'
+PROTO1='const char *name, const char *domain, int class, int type, unsigned char *answer, int anslen'
+for testproto in "${PROTO1}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ int res_querydomain($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+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=
+NAMES='msg, msglen, answer, anslen'
+PROTO1='const char *msg, int msglen, char *answer, int anslen'
+PROTO2='const unsigned char *msg, int msglen, unsigned char *answer, int anslen'
+for testproto in "${PROTO1}" \
+ "${PROTO2}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ int res_send($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([res_send(${PROTO})])
+AC_DEFINE_UNQUOTED([RES_SEND_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([RES_SEND_ARGNAMES],[${NAMES}],[Argument names])
+
+
+dnl Find the correct res_search prototype on this machine
+AC_MSG_CHECKING(for correct res_search prototype)
+PROTO=
+NAMES='dname, class, type, answer, anslen'
+PROTO1='const char *dname, int class, int type, unsigned char *answer, int anslen'
+for testproto in "${PROTO1}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ int res_search($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([res_search(${PROTO})])
+AC_DEFINE_UNQUOTED([RES_SEARCH_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([RES_SEARCH_ARGNAMES],[${NAMES}],[Argument names])
+
+
+dnl Find the correct res_query prototype on this machine
+AC_MSG_CHECKING(for correct res_query prototype)
+PROTO=
+NAMES='dname, class, type, answer, anslen'
+PROTO1='const char *dname, int class, int type, unsigned char *answer, int anslen'
+for testproto in "${PROTO1}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ int res_query($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([res_query(${PROTO})])
+AC_DEFINE_UNQUOTED([RES_QUERY_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([RES_QUERY_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Find the correct getpeername prototype on this machine
+AC_MSG_CHECKING(for correct getpeername prototype)
+PROTO=
+NAMES='__fd, __name, __namelen'
+PROTO1='int __fd, const struct sockaddr * __name, int *__namelen'
+PROTO2='int __fd, const struct sockaddr_in * __name, socklen_t *__namelen'
+PROTO3='int __fd, struct sockaddr * __name, socklen_t *__namelen'
+PROTO4='int __fd, const struct sockaddr * __name, socklen_t *__namelen'
+for testproto in "${PROTO1}" \
+ "${PROTO2}" \
+ "${PROTO3}" \
+ "${PROTO4}"
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ int getpeername($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([getpeername(${PROTO})])
+AC_DEFINE_UNQUOTED(GETPEERNAME_SIGNATURE, [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([GETPEERNAME_ARGNAMES],[${NAMES}],[Argument names])
+
+
+dnl Find the correct poll prototype on this machine
+AC_MSG_CHECKING(for correct poll prototype)
+PROTO=
+NAMES='ufds, nfds, timeout'
+for testproto in 'struct pollfd *ufds, unsigned long nfds, int timeout' \
+ 'struct pollfd *ufds, nfds_t nfds, int timeout' \
+ 'struct pollfd *ufds, unsigned int nfds, int timeout'
+do
+ if test "${PROTO}" = ""; then
+ AC_TRY_COMPILE([
+ #include <sys/poll.h>
+ int poll($testproto);
+ ],,[PROTO="$testproto";],)
+ fi
+done
+if test "${PROTO}" = ""; then
+ AC_MSG_ERROR("no match found!")
+fi
+AC_MSG_RESULT([poll(${PROTO})])
+AC_DEFINE_UNQUOTED([POLL_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([POLL_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for gethostbyname
+PROTO="const char *name"
+NAMES='name'
+AC_DEFINE_UNQUOTED([GETHOSTBYNAME_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([GETHOSTBYNAME_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for getaddrinfo
+PROTO="const char *node, const char *service, void *hints, void *res"
+NAMES='node, service, hints, res'
+AC_DEFINE_UNQUOTED([GETADDRINFO_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([GETADDRINFO_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for getipnodebyname
+PROTO="const char *name, int af, int flags, int *error_num"
+NAMES='name, af, flags, error_num'
+AC_DEFINE_UNQUOTED([GETIPNODEBYNAME_SIGNATURE], [${PROTO}],[Description])
+AC_DEFINE_UNQUOTED([GETIPNODEBYNAME_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for gethostbyaddr
+PROTO="const void *addr, socklen_t len, int type"
+NAMES='addr, len, type'
+AC_DEFINE_UNQUOTED(GETHOSTBYADDR_SIGNATURE, [${PROTO}], [Description])
+AC_DEFINE_UNQUOTED([GETHOSTBYADDR_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for sendto
+PROTO="int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen"
+NAMES='s, buf, len, flags, to, tolen'
+AC_DEFINE_UNQUOTED(SENDTO_SIGNATURE, [${PROTO}], [Description])
+AC_DEFINE_UNQUOTED([SENDTO_ARGNAMES],[${NAMES}],[Argument names])
+
+dnl Emit signature for sendmsg
+PROTO="int s, const struct msghdr *msg, int flags"
+NAMES='s, msg, flags'
+AC_DEFINE_UNQUOTED(SENDMSG_SIGNATURE, [${PROTO}], [Description])
+AC_DEFINE_UNQUOTED([SENDMSG_ARGNAMES],[${NAMES}],[Argument names])
+
+
+##############################################################################
+# 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.
+##############################################################################
+
+# This variable is used for the LDFLAGS in test/Makefile.am
+TESTLDFLAGS="$LDFLAGS"
+AC_SUBST(TESTLDFLAGS)
+
+# Version information for libtorsocks
+TORSOCKSLDFLAGS="$LDFLAGS -version-info 1:0:0"
+
+dnl Linker checks for Mac OSX, which uses DYLD_INSERT_LIBRARIES
+dnl instead of LD_PRELOAD
+case "$host_os" in
+darwin*)
+ dnl Check if the linker accepts -dynamiclib; necessary on Mac OS X
+ AC_MSG_CHECKING(if the linker accepts -dynamiclib)
+ OLDLDFLAGS="$TORSOCKSLDFLAGS"
+ TORSOCKSLDFLAGS="$TORSOCKSLDFLAGS -dynamiclib"
+ AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
+ TORSOCKSLDFLAGS="$OLDLDFLAGS"
+ AC_MSG_RESULT(no)])
+
+ # dnl Check if the linker accepts -multiply_defined suppress; necessary on Mac OS X
+ # AC_MSG_CHECKING(if the linker accepts -multiply_defined suppress)
+ # OLDLDFLAGS="$LDFLAGS"
+ # LDFLAGS="$LDFLAGS -multiply_defined suppress"
+ # AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
+ # LDFLAGS="$OLDLDFLAGS"
+ # AC_MSG_RESULT(no)])
+
+ dnl Check if the linker accepts -single_module; necessary on Mac OS X
+ AC_MSG_CHECKING(if the linker accepts -single_module)
+ OLDLDFLAGS="$TORSOCKSLDFLAGS"
+ SHLIB_EXT="so"
+ LDPRELOAD="LD_PRELOAD"
+ TORSOCKSLDFLAGS="$TORSOCKSLDFLAGS -single_module"
+ AC_TRY_COMPILE(,,
+ [
+ SHLIB_EXT="dylib"
+ LDPRELOAD="DYLD_INSERT_LIBRARIES"
+ AC_MSG_RESULT(yes)
+ ], [
+ TORSOCKSLDFLAGS="$OLDLDFLAGS"
+ AC_MSG_RESULT(no)
+ ]
+ )
+
+ ;;
+*)
+ SHLIB_EXT="so"
+ LDPRELOAD="LD_PRELOAD"
+ ;;
+esac
+
+AC_SUBST(SHLIB_EXT)
+AC_SUBST(LDPRELOAD)
+AC_SUBST(TORSOCKSLDFLAGS)
+
+##############################################################################
+# 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
+fi
+
+if test "x$CONFDIR" = "x"; then
+ CONFDIR=`eval echo $sysconfdir`
+fi
+AC_SUBST(CONFDIR)
+AH_TEMPLATE([CONFDIR],[torsock's configuration directory])
+AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
+
+AC_ARG_WITH(conf,
+[ --with-conf=<file> location of configuration file (${CONFDIR}/torsocks.conf default)],[
+if test "${withval}" = "yes" ; then
+ AC_MSG_ERROR("--with-conf requires the location of the configuration file as an argument")
+else
+ AC_DEFINE_UNQUOTED([CONF_FILE], ["${withval}"],[Description])
+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)
+AC_ENABLE_SHARED
+AC_ENABLE_STATIC
+
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ doc/Makefile
+ test/Makefile
+])
+
+AC_OUTPUT
diff --git a/configure.in b/configure.in
deleted file mode 100644
index f0bbcdb..0000000
--- a/configure.in
+++ /dev/null
@@ -1,645 +0,0 @@
-##############################################################################
-# 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, 1.3)
-
-# Get hostname and other information.
-AC_CANONICAL_HOST
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_LN_S
-
-
-dnl Arguments we allow
-AC_ARG_ENABLE(debug,
-[ --disable-debug disable ALL error messages from torsocks ])
-AC_ARG_ENABLE(oldmethod,
-[ --enable-oldmethod use the old method to override connect ])
-AC_ARG_ENABLE(envconf,
-[ --disable-envconf do not allow TORSOCKS_CONF_FILE to specify configuration file ])
-
-
-##############################################################################
-# 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)
-OLDCFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wall"
-AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
- CFLAGS="$OLDCFLAGS"
- AC_MSG_RESULT(no)])
-
-dnl Checks for standard header files.
-AC_HEADER_STDC
-
-dnl Check for the dynamic loader function header
-AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR("dlfcn.h not found"))
-
-dnl Check for the socket header
-AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR("sys/socket.h not found"))
-
-dnl Check for the arpa/inet.h header (inet_ntoa and inet_addr)
-AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR("arpa/inet.h not found"))
-
-dnl Check for the fcntl header
-AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR("fcntl.h not found"))
-
-dnl Check for the poll header
-AC_CHECK_HEADER(sys/poll.h,,AC_MSG_ERROR("sys/poll.h not found"))
-
-dnl Check for the mmap header
-AC_CHECK_HEADER(sys/mman.h,,AC_MSG_ERROR("sys/mman.h not found"))
-
-dnl Other headers we're interested in
-AC_CHECK_HEADERS(unistd.h)
-
-dnl Checks for library functions.
-AC_CHECK_FUNCS(strcspn strdup strerror strspn strtol mmap strcasecmp \
- strncasecmp strtol,,[AC_MSG_ERROR("Required function not found")])
-
-##############################################################################
-# 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
-dnl we chuck it on the end of LIBS, that lib may end up there
-dnl more than once (since we do our search with an empty libs
-dnl list) but that isn't a problem
-OLDLIBS="${LIBS}"
-LIBS=
-CONNECTLIB=
-for LIB in c socket; do
- AC_CHECK_LIB("${LIB}",connect,[
- CONNECTLIB="${LIB}"
- break
- ],)
-done
-LIBS="${OLDLIBS} -l${CONNECTLIB}"
-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"))])
-
-dnl Check for a function to convert an ascii ip address
-dnl to a sin_addr.
-AC_CHECK_FUNC(inet_aton, AC_DEFINE([HAVE_INET_ATON],[],[Description]), [
- AC_CHECK_FUNC(inet_addr, AC_DEFINE([HAVE_INET_ADDR],[],[Description]), [
- AC_CHECK_LIB(nsl, inet_addr, [ AC_DEFINE([HAVE_INET_ADDR],[],[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 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])
-
-
-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
-
-
-##############################################################################
-# 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)
-AC_EGREP_CPP(yes,
-[
- #include <dlfcn.h>
- #ifdef RTLD_NEXT
- yes
- #endif
-], [
- AC_MSG_RESULT(yes)
-], [
- AC_MSG_RESULT(no)
- AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h with _GNU_SOURCE)
- AC_EGREP_CPP(yes,
- [
- #define _GNU_SOURCE
- #include <dlfcn.h>
- #ifdef RTLD_NEXT
- yes
- #endif
- ], [
- AC_MSG_RESULT(yes)
- AC_DEFINE([USE_GNU_SOURCE],[],[Description])
- ], [
- AC_MSG_RESULT(no)
- AC_DEFINE([USE_OLD_DLSYM],[],[Description])
- oldmethod="yes"
- ])
-])
-
-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"
-fi
-
-dnl If we have to use the old method of overriding connect (i.e no
-dnl RTLD_NEXT) we need to know the location of the library that
-dnl contains connect(), select(), poll() and close()
-if test "${oldmethod}" = "yes"; then
- dnl We need to find the path to the library, to do
- dnl this we use find on the usual suspects, i.e /lib and
- dnl /usr/lib
-
- dnl Check that find is available, it should be somehere
- dnl in the path
- AC_CHECK_PROG(FIND, find, find)
- if test "${FIND}" = ""; then
- AC_MSG_ERROR('find not found in path')
- fi
-
- dnl Find tail, it should always be somewhere in the path
- dnl but for safety's sake
- AC_CHECK_PROG(TAIL, tail, tail)
- if test "${TAIL}" = ""; then
- AC_MSG_ERROR('tail not found in path')
- fi
-
- dnl Now find the library we need
- AC_MSG_CHECKING(location of lib${CONNECTLIB}.so)
- LIBCONNECT=
- for DIR in '/lib' '/usr/lib'; do
- if test "${LIBCONNECT}" = ""; then
- LIBCONNECT=`$FIND $DIR -name "lib${CONNECTLIB}.so.?" 2>/dev/null | $TAIL -1`
- fi
- done
- AC_DEFINE_UNQUOTED([LIBCONNECT],["${LIBCONNECT}"],[Description])
- if test "${LIBCONNECT}" = ""; then
- AC_MSG_ERROR("not found!")
- fi
-
- AC_MSG_RESULT($LIBCONNECT)
-
- dnl Now find the resolve library we need
- AC_MSG_CHECKING(location of libresolv.so)
- LIBRESOLV=
- for DIR in '/lib' '/usr/lib'; do
- if test "${LIBRESOLV}" = ""; then
- LIBRESOLV=`$FIND $DIR -name "libresolv.so.?" 2>/dev/null | $TAIL -1`
- fi
- done
- AC_DEFINE_UNQUOTED([LIBRESOLV],["${LIBRESOLV}"],[Description])
- if test "${LIBRESOLV}" = ""; then
- AC_MSG_ERROR("not found!")
- fi
-
- AC_MSG_RESULT($LIBRESOLV)
-
- dnl close() should be in libc, find it
- AC_MSG_CHECKING(location of libc.so)
- LIBC=
- for DIR in '/lib' '/usr/lib'; do
- if test "${LIBC}" = ""; then
- LIBC=`$FIND $DIR -name "libc.so.?" 2>/dev/null | $TAIL -1`
- fi
- done
-
- AC_DEFINE_UNQUOTED([LIBC],["${LIBC}"],[Description])
- if test "${LIBC}" = ""; then
- AC_MSG_ERROR("not found!")
- fi
-
- AC_MSG_RESULT($LIBC)
-fi
-
-##############################################################################
-# 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'
-for testproto in 'int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout'
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/time.h>
- #include <sys/types.h>
- #include <unistd.h>
- int select($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-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
-AC_MSG_CHECKING(for correct connect prototype)
-PROTO=
-NAMES='__fd, __addr, __len'
-PROTO1='int __fd, const struct sockaddr * __addr, int __len'
-PROTO2='int __fd, const struct sockaddr_in * __addr, socklen_t __len'
-PROTO3='int __fd, struct sockaddr * __addr, int __len'
-PROTO4='int __fd, const struct sockaddr * __addr, socklen_t __len'
-for testproto in "${PROTO1}" \
- "${PROTO2}" \
- "${PROTO3}" \
- "${PROTO4}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <sys/socket.h>
- int connect($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([connect(${PROTO})])
-AC_DEFINE_UNQUOTED([CONNECT_SIGNATURE],[${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([CONNECT_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Pick which of the sockaddr type arguments we need for
-dnl connect(), we need to cast one of ours to it later
-SOCKETARG="struct sockaddr *"
-case "${PROTO}" in
- *sockaddr_in*)
- SOCKETARG="struct sockaddr_in *"
- ;;
-esac
-AC_DEFINE_UNQUOTED([CONNECT_SOCKARG],[${SOCKETARG}],[Description])
-
-dnl Find the correct close prototype on this machine
-AC_MSG_CHECKING(for correct close prototype)
-PROTO=
-NAMES='fd'
-PROTO1='int fd'
-for testproto in "${PROTO1}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <stdlib.h>
- int close($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([close(${PROTO})])
-AC_DEFINE_UNQUOTED([CLOSE_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([CLOSE_ARGNAMES],[${NAMES}],[Argument names])
-
-
-dnl Find the correct res_querydomain prototype on this machine
-AC_MSG_CHECKING(for correct res_querydomain prototype)
-PROTO=
-NAMES='name, domain, class, type, answer, anslen'
-PROTO1='const char *name, const char *domain, int class, int type, unsigned char *answer, int anslen'
-for testproto in "${PROTO1}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <resolv.h>
- int res_querydomain($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-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=
-NAMES='msg, msglen, answer, anslen'
-PROTO1='const char *msg, int msglen, char *answer, int anslen'
-PROTO2='const unsigned char *msg, int msglen, unsigned char *answer, int anslen'
-for testproto in "${PROTO1}" \
- "${PROTO2}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <resolv.h>
- int res_send($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([res_send(${PROTO})])
-AC_DEFINE_UNQUOTED([RES_SEND_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([RES_SEND_ARGNAMES],[${NAMES}],[Argument names])
-
-
-dnl Find the correct res_search prototype on this machine
-AC_MSG_CHECKING(for correct res_search prototype)
-PROTO=
-NAMES='dname, class, type, answer, anslen'
-PROTO1='const char *dname, int class, int type, unsigned char *answer, int anslen'
-for testproto in "${PROTO1}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <resolv.h>
- int res_search($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([res_search(${PROTO})])
-AC_DEFINE_UNQUOTED([RES_SEARCH_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([RES_SEARCH_ARGNAMES],[${NAMES}],[Argument names])
-
-
-dnl Find the correct res_query prototype on this machine
-AC_MSG_CHECKING(for correct res_query prototype)
-PROTO=
-NAMES='dname, class, type, answer, anslen'
-PROTO1='const char *dname, int class, int type, unsigned char *answer, int anslen'
-for testproto in "${PROTO1}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <resolv.h>
- int res_query($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([res_query(${PROTO})])
-AC_DEFINE_UNQUOTED([RES_QUERY_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([RES_QUERY_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Find the correct getpeername prototype on this machine
-AC_MSG_CHECKING(for correct getpeername prototype)
-PROTO=
-NAMES='__fd, __name, __namelen'
-PROTO1='int __fd, const struct sockaddr * __name, int *__namelen'
-PROTO2='int __fd, const struct sockaddr_in * __name, socklen_t *__namelen'
-PROTO3='int __fd, struct sockaddr * __name, socklen_t *__namelen'
-PROTO4='int __fd, const struct sockaddr * __name, socklen_t *__namelen'
-for testproto in "${PROTO1}" \
- "${PROTO2}" \
- "${PROTO3}" \
- "${PROTO4}"
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <sys/socket.h>
- int getpeername($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([getpeername(${PROTO})])
-AC_DEFINE_UNQUOTED(GETPEERNAME_SIGNATURE, [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([GETPEERNAME_ARGNAMES],[${NAMES}],[Argument names])
-
-
-dnl Find the correct poll prototype on this machine
-AC_MSG_CHECKING(for correct poll prototype)
-PROTO=
-NAMES='ufds, nfds, timeout'
-for testproto in 'struct pollfd *ufds, unsigned long nfds, int timeout' \
- 'struct pollfd *ufds, nfds_t nfds, int timeout' \
- 'struct pollfd *ufds, unsigned int nfds, int timeout'
-do
- if test "${PROTO}" = ""; then
- AC_TRY_COMPILE([
- #include <sys/poll.h>
- int poll($testproto);
- ],,[PROTO="$testproto";],)
- fi
-done
-if test "${PROTO}" = ""; then
- AC_MSG_ERROR("no match found!")
-fi
-AC_MSG_RESULT([poll(${PROTO})])
-AC_DEFINE_UNQUOTED([POLL_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([POLL_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for gethostbyname
-PROTO="const char *name"
-NAMES='name'
-AC_DEFINE_UNQUOTED([GETHOSTBYNAME_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([GETHOSTBYNAME_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for getaddrinfo
-PROTO="const char *node, const char *service, void *hints, void *res"
-NAMES='node, service, hints, res'
-AC_DEFINE_UNQUOTED([GETADDRINFO_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([GETADDRINFO_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for getipnodebyname
-PROTO="const char *name, int af, int flags, int *error_num"
-NAMES='name, af, flags, error_num'
-AC_DEFINE_UNQUOTED([GETIPNODEBYNAME_SIGNATURE], [${PROTO}],[Description])
-AC_DEFINE_UNQUOTED([GETIPNODEBYNAME_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for gethostbyaddr
-PROTO="const void *addr, socklen_t len, int type"
-NAMES='addr, len, type'
-AC_DEFINE_UNQUOTED(GETHOSTBYADDR_SIGNATURE, [${PROTO}], [Description])
-AC_DEFINE_UNQUOTED([GETHOSTBYADDR_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for sendto
-PROTO="int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen"
-NAMES='s, buf, len, flags, to, tolen'
-AC_DEFINE_UNQUOTED(SENDTO_SIGNATURE, [${PROTO}], [Description])
-AC_DEFINE_UNQUOTED([SENDTO_ARGNAMES],[${NAMES}],[Argument names])
-
-dnl Emit signature for sendmsg
-PROTO="int s, const struct msghdr *msg, int flags"
-NAMES='s, msg, flags'
-AC_DEFINE_UNQUOTED(SENDMSG_SIGNATURE, [${PROTO}], [Description])
-AC_DEFINE_UNQUOTED([SENDMSG_ARGNAMES],[${NAMES}],[Argument names])
-
-
-##############################################################################
-# 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.
-##############################################################################
-
-# This variable is used for the LDFLAGS in test/Makefile.am
-TESTLDFLAGS="$LDFLAGS"
-AC_SUBST(TESTLDFLAGS)
-
-# Version information for libtorsocks
-TORSOCKSLDFLAGS="$LDFLAGS -version-info 1:0:0"
-
-dnl Linker checks for Mac OSX, which uses DYLD_INSERT_LIBRARIES
-dnl instead of LD_PRELOAD
-case "$host_os" in
-darwin*)
- dnl Check if the linker accepts -dynamiclib; necessary on Mac OS X
- AC_MSG_CHECKING(if the linker accepts -dynamiclib)
- OLDLDFLAGS="$TORSOCKSLDFLAGS"
- TORSOCKSLDFLAGS="$TORSOCKSLDFLAGS -dynamiclib"
- AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
- TORSOCKSLDFLAGS="$OLDLDFLAGS"
- AC_MSG_RESULT(no)])
-
- # dnl Check if the linker accepts -multiply_defined suppress; necessary on Mac OS X
- # AC_MSG_CHECKING(if the linker accepts -multiply_defined suppress)
- # OLDLDFLAGS="$LDFLAGS"
- # LDFLAGS="$LDFLAGS -multiply_defined suppress"
- # AC_TRY_COMPILE(,,AC_MSG_RESULT(yes),[
- # LDFLAGS="$OLDLDFLAGS"
- # AC_MSG_RESULT(no)])
-
- dnl Check if the linker accepts -single_module; necessary on Mac OS X
- AC_MSG_CHECKING(if the linker accepts -single_module)
- OLDLDFLAGS="$TORSOCKSLDFLAGS"
- SHLIB_EXT="so"
- LDPRELOAD="LD_PRELOAD"
- TORSOCKSLDFLAGS="$TORSOCKSLDFLAGS -single_module"
- AC_TRY_COMPILE(,,
- [
- SHLIB_EXT="dylib"
- LDPRELOAD="DYLD_INSERT_LIBRARIES"
- AC_MSG_RESULT(yes)
- ], [
- TORSOCKSLDFLAGS="$OLDLDFLAGS"
- AC_MSG_RESULT(no)
- ]
- )
-
- ;;
-*)
- SHLIB_EXT="so"
- LDPRELOAD="LD_PRELOAD"
- ;;
-esac
-
-AC_SUBST(SHLIB_EXT)
-AC_SUBST(LDPRELOAD)
-AC_SUBST(TORSOCKSLDFLAGS)
-
-##############################################################################
-# 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
-fi
-
-if test "x$CONFDIR" = "x"; then
- CONFDIR=`eval echo $sysconfdir`
-fi
-AC_SUBST(CONFDIR)
-AH_TEMPLATE([CONFDIR],[torsock's configuration directory])
-AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
-
-AC_ARG_WITH(conf,
-[ --with-conf=<file> location of configuration file (${CONFDIR}/torsocks.conf default)],[
-if test "${withval}" = "yes" ; then
- AC_MSG_ERROR("--with-conf requires the location of the configuration file as an argument")
-else
- AC_DEFINE_UNQUOTED([CONF_FILE], ["${withval}"],[Description])
-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)
-AC_ENABLE_SHARED
-AC_ENABLE_STATIC
-
-AC_CONFIG_FILES([src/usewithtor src/torsocks doc/torsocks.conf.5 doc/torsocks.8 doc/usewithtor.1 doc/torsocks.1])
-AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile test/Makefile)
-AC_OUTPUT
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits