1 dnl $Id: aclocal.m4,v 1.1 2000/07/29 13:34:15 lukem Exp $
7 dnl Written by Luke Mewburn <lukem@netbsd.org>
10 dnl AC_MSG_TRY_COMPILE(Message, CacheVar, Includes, Code,
11 dnl ActionPass [,ActionFail] )
14 dnl AC_CACHE_CHECK(Message, CacheVar,
15 dnl AC_TRY_COMPILE(Includes, Code, CacheVar = yes, CacheVar = no)
16 dnl if CacheVar == yes
17 dnl AC_MESSAGE_RESULT(yes)
20 dnl AC_MESSAGE_RESULT(no)
24 AC_DEFUN(AC_MSG_TRY_COMPILE, [
25 AC_CACHE_CHECK($1, $2, [
26 AC_TRY_COMPILE([ $3 ], [ $4; ], [ $2=yes ], [ $2=no ])
28 if test "x[$]$2" = "xyes"; then
40 dnl AC_MSG_TRY_LINK(Message, CacheVar, Includes, Code,
41 dnl ActionPass [,ActionFail] )
43 dnl as AC_MSG_TRY_COMPILE, but uses AC_TRY_LINK instead of AC_TRY_COMPILE
45 AC_DEFUN(AC_MSG_TRY_LINK, [
46 AC_CACHE_CHECK($1, $2, [
47 AC_TRY_LINK([ $3 ], [ $4; ], [ $2=yes ], [ $2=no ])
49 if test "x[$]$2" = "xyes"; then
59 dnl AC_LIBRARY_NET: #Id: net.m4,v 1.5 1997/11/09 21:36:54 jhawk Exp #
61 dnl Written by John Hawkinson <jhawk@mit.edu>. This code is in the Public
64 dnl This test is for network applications that need socket() and
65 dnl gethostbyname() -ish functions. Under Solaris, those applications need to
66 dnl link with "-lsocket -lnsl". Under IRIX, they should *not* link with
67 dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
68 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
71 dnl Unfortunately, many application developers are not aware of this, and
72 dnl mistakenly write tests that cause -lsocket to be used under IRIX. It is
73 dnl also easy to write tests that cause -lnsl to be used under operating
74 dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
75 dnl uses -lnsl for TLI.
77 dnl This test exists so that every application developer does not test this in
78 dnl a different, and subtly broken fashion.
80 dnl It has been argued that this test should be broken up into two seperate
81 dnl tests, one for the resolver libraries, and one for the libraries necessary
82 dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
83 dnl allowing the autoconf user to use them independantly potentially results in
84 dnl unfortunate ordering dependancies -- as such, such component macros would
85 dnl have to carefully use indirection and be aware if the other components were
86 dnl executed. Since other autoconf macros do not go to this trouble, and almost
87 dnl no applications use sockets without the resolver, this complexity has not
90 dnl The check for libresolv is in case you are attempting to link statically
91 dnl and happen to have a libresolv.a lying around (and no libnsl.a).
93 AC_DEFUN(AC_LIBRARY_NET, [
94 # Most operating systems have gethostbyname() in the default searched
95 # libraries (i.e. libc):
96 AC_CHECK_FUNC(gethostbyname, ,
97 # Some OSes (eg. Solaris) place it in libnsl:
98 AC_CHECK_LIB(nsl, gethostbyname, ,
99 # Some strange OSes (SINIX) have it in libsocket:
100 AC_CHECK_LIB(socket, gethostbyname, ,
101 # Unfortunately libsocket sometimes depends on libnsl.
102 # AC_CHECK_LIB's API is essentially broken so the following
103 # ugliness is necessary:
104 AC_CHECK_LIB(socket, gethostbyname,
105 LIBS="-lsocket -lnsl $LIBS",
106 AC_CHECK_LIB(resolv, gethostbyname),
111 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
112 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
116 dnl Checks for SOCKS firewall support.
118 dnl Written by Matthew R. Green <mrg@eterna.com.au>
120 AC_DEFUN(AC_LIBRARY_SOCKS, [
121 AC_MSG_CHECKING(whether to support SOCKS)
123 [ --with-socks Compile with SOCKS firewall traversal support.],
131 AC_CHECK_LIB(socks5, SOCKSconnect, [
133 LIBS="-lsocks5 $LIBS"], [
134 AC_CHECK_LIB(socks, Rconnect, [
136 LIBS="-lsocks $LIBS"], [
137 AC_MSG_ERROR(Could not find socks library. You must first install socks.) ] ) ] )
144 if test "x$socks" = "x"; then
145 AC_MSG_CHECKING(whether to support SOCKS5)
147 [ --with-socks5[=PATH] Compile with SOCKS5 firewall traversal support.],
156 if test "x$withval" = "xyes"; then
159 if test -d "$withval"; then
160 if test -d "$withval/include"; then
161 CFLAGS="$CFLAGS -I$withval/include"
163 CFLAGS="$CFLAGS -I$withval"
165 if test -d "$withval/lib"; then
166 withval="-L$withval/lib -lsocks5"
168 withval="-L$withval -lsocks5"
172 LIBS="$withval $LIBS"
173 # If Socks was compiled with Kerberos support, we will need
174 # to link against kerberos libraries. Temporarily append
175 # to LIBS. This is harmless if there is no kerberos support.
177 LIBS="$LIBS $KERBEROS_LIBS"
181 [ AC_MSG_ERROR(Could not find the $withval library. You must first install socks5.) ])
190 if test "x$socks" = "x"; then
191 AC_MSG_CHECKING(whether to support SOCKS4)
193 [ --with-socks4[=PATH] Compile with SOCKS4 firewall traversal support.],
202 if test "x$withval" = "xyes"; then
205 if test -d "$withval"; then
206 withval="-L$withval -lsocks"
209 LIBS="$withval $LIBS"
213 [ AC_MSG_ERROR(Could not find the $withval library. You must first install socks.) ])
221 if test "x$socks" = "x4"; then
224 AC_DEFINE(connect, Rconnect)
225 AC_DEFINE(getsockname, Rgetsockname)
226 AC_DEFINE(bind, Rbind)
227 AC_DEFINE(accept, Raccept)
228 AC_DEFINE(listen, Rlisten)
229 AC_DEFINE(select, Rselect)
232 if test "x$socks" = "x5"; then
235 AC_DEFINE(connect,SOCKSconnect)
236 AC_DEFINE(getsockname,SOCKSgetsockname)
237 AC_DEFINE(getpeername,SOCKSgetpeername)
238 AC_DEFINE(bind,SOCKSbind)
239 AC_DEFINE(accept,SOCKSaccept)
240 AC_DEFINE(listen,SOCKSlisten)
241 AC_DEFINE(select,SOCKSselect)
242 AC_DEFINE(recvfrom,SOCKSrecvfrom)
243 AC_DEFINE(sendto,SOCKSsendto)
244 AC_DEFINE(recv,SOCKSrecv)
245 AC_DEFINE(send,SOCKSsend)
246 AC_DEFINE(read,SOCKSread)
247 AC_DEFINE(write,SOCKSwrite)
248 AC_DEFINE(rresvport,SOCKSrresvport)
249 AC_DEFINE(shutdown,SOCKSshutdown)
250 AC_DEFINE(listen,SOCKSlisten)
251 AC_DEFINE(close,SOCKSclose)
252 AC_DEFINE(dup,SOCKSdup)
253 AC_DEFINE(dup2,SOCKSdup2)
254 AC_DEFINE(fclose,SOCKSfclose)
255 AC_DEFINE(gethostbyname,SOCKSgethostbyname)