File: configure.in

package info (click to toggle)
tsocks 1.8beta4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 400 kB
  • ctags: 168
  • sloc: sh: 2,526; ansic: 1,837; makefile: 125
file content (300 lines) | stat: -rw-r--r-- 8,729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
dnl Process this file with autoconf to produce a configure script.
AC_INIT(saveme.c)
AC_CONFIG_HEADER(config.h)

dnl Our default prefix is /usr/ since most people will be using tsocks
dnl on Linux systems and that /usr/local/ stuff annoys them
AC_PREFIX_DEFAULT(/usr)

dnl if libdir hasn't been set by the user default it to /lib since
dnl tsocks needs to be on the root partition if put in the
dnl /etc/ld.so.preload file
test "$libdir" = "\${exec_prefix}/lib" && libdir="/lib"

dnl Arguments we allow
AC_ARG_ENABLE(socksdns,
[  --enable-socksdns	      force dns lookups to use tcp ])
AC_ARG_ENABLE(debug,
[  --disable-debug         disable ALL error messages from tsocks ])
AC_ARG_ENABLE(oldmethod,
[  --enable-oldmethod	   use the old method to override connect ])
AC_ARG_ENABLE(hostnames,
[  --disable-hostnames	   disable hostname lookups for socks servers ])
AC_ARG_ENABLE(envconf,
[  --disable-envconf       do not allow TSOCKS_CONF_FILE to specify configuration file ])
AC_ARG_WITH(conf,
[  --with-conf=<file>      location of configuration file (/etc/tsocks.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}")
fi
], [
  AC_DEFINE_UNQUOTED(CONF_FILE, "/etc/tsocks.conf")
])


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

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 Other headers we're interested in
AC_CHECK_HEADERS(unistd.h)

dnl Checks for library functions.
AC_CHECK_FUNCS(strcspn strdup strerror strspn strtol,,[ 
	       AC_MSG_ERROR("Required function not found")])

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), [
  AC_CHECK_FUNC(inet_addr, AC_DEFINE(HAVE_INET_ADDR), [
    AC_CHECK_LIB(nsl, inet_addr, [ AC_DEFINE(HAVE_INET_ADDR)
                                   LIBS="${LIBS} -lnsl" ], [
		AC_MSG_ERROR("Neither inet_aton or inet_addr present")])])])

dnl Look for gethostbyname (needed by tsocks and inspectsocks)
AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME), [
  AC_CHECK_LIB(xnet, gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME), [
	       AC_MSG_ERROR(["gethostbyname not found, name lookups in " \
		      "tsocks and inspectsocks 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:
AC_CHECK_LIB(dl, dlsym,,AC_MSG_ERROR("libdl is required"))

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)
  ], [
    AC_MSG_RESULT(no)
    AC_DEFINE(USE_OLD_DLSYM)
    oldmethod="yes"
  ])    
])

if test "${enable_socksdns}" = "yes"; then
  AC_DEFINE(USE_SOCKS_DNS)
fi

if test "x${enable_envconf}" = "x"; then
  AC_DEFINE(ALLOW_ENV_CONFIG)
fi

if test "${enable_oldmethod}" = "yes"; then
  AC_DEFINE(USE_OLD_DLSYM)
  oldmethod="yes"
fi

if test "x${enable_debug}" = "x"; then
  AC_DEFINE(ALLOW_MSG_OUTPUT)
fi

if test "x${enable_hostnames}" = "x"; then
  AC_DEFINE(HOSTNAMES)
fi

if test "${enable_socksdns}" = "yes" -a \
        "x${enable_hostnames}" = "x" ; then
  AC_MSG_ERROR("--enable-socksdns is not valid without --disable-hostnames")
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()
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}")
  if test "${LIBCONNECT}" = ""; then
     AC_MSG_ERROR("not found!")
  fi

  AC_MSG_RESULT($LIBCONNECT)
fi

dnl Find the correct select prototype on this machine 
AC_MSG_CHECKING(for correct select prototype)
PROTO=
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}])

dnl Find the correct connect prototype on this machine 
AC_MSG_CHECKING(for correct connect prototype)
PROTO=
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/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}])

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}])

dnl Find the correct poll prototype on this machine 
AC_MSG_CHECKING(for correct poll prototype)
PROTO=
for testproto in 'struct pollfd *ufds, unsigned long 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}])

dnl Output the special librarys (libdl etc needed for tsocks)
SPECIALLIBS=${LIBS}
AC_SUBST(SPECIALLIBS)
LIBS=${SIMPLELIBS}

AC_OUTPUT(Makefile)