1dnl Process this file with autoconf to produce a configure script.
2dnl Autoconfigure input file for suck
3
4AC_INIT(suck.c)
5AC_CONFIG_HEADER(config.h)
6
7AC_ARG_WITH(inn-lib, [ --with-inn-lib=path location of libinn.a])
8AC_ARG_WITH(inn-include, [ --with-inn-include=path location of inn include files])
9AC_ARG_WITH(perl-exe, [ --with-perl-exe=full path to perl executable eg: /usr/bin])
10
11# we want these before the checks, so the checks can modify their values
12test -z "$CFLAGS" && CFLAGS=-O2 AC_SUBST(CFLAGS)
13test -z "$LDFLAGS" && LDFLAGS=-s AC_SUBST(LDFLAGS)
14
15AC_PROG_CC
16AC_PROG_INSTALL
17AC_PROG_MAKE_SET
18AC_SUBST(GCC)
19
20dnl Checks for libraries.
21AC_CHECK_LIB(nsl, gethostbyname)
22AC_CHECK_LIB(socket, socket)
23AC_CHECK_LIB(socks, Rconnect)
24AC_CHECK_LIB(socks5, SOCKSconnect)
25AC_CHECK_LIB(cV, fprintf)
26dnl Do I need -lcrypto????? for SSL
27AC_CHECK_LIB(ssl, SSL_get_error, [SSL_LIB="-lssl"; SSL_DEFS="-DHAVE_LIBSSL"])
28
29dnl Checks for header files.
30AC_HEADER_DIRENT
31AC_HEADER_STDC
32AC_HEADER_SYS_WAIT
33AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h limits.h regex.h sys/select.h net/socket.h arpa/inet.h socks.h)
34
35dnl Checks for typedefs, structures, and compiler characteristics.
36AC_C_CONST
37AC_TYPE_PID_T
38AC_TYPE_SIZE_T
39AC_HEADER_TIME
40
41dnl Checks for library functions.
42AC_TYPE_SIGNAL
43AC_CHECK_FUNCS(gettimeofday select strerror memmove setvbuf sigaction)
44if test "$with_inn_lib" ; then
45    LDFLAGS+="$DB_LIB -L${with_inn_lib}"
46fi
47if test "$with_inn_include" ; then
48   testpath=$with_inn_include
49else
50   testpath="/usr/include/inn /usr/local/include /usr/local/include/inn"
51fi
52HISTORY="chkhistory_db.o"
53AC_CHECK_LIB(inn, main, [
54  DB_LIB="-linn"
55  DB_TYPE="-DUSE_INN23"
56  savedLIBS=$LIBS
57  LIBS="$LIBS -linn"
58  AC_CHECK_FUNC(QIOopen, , [
59    LIBS="$savedLIBS -lstorage"
60    AC_CHECK_FUNC(QIOopen, [DB_LIB="$DB_LIB -lstorage"])
61  ])
62  LIBS=$savedLIBS
63  AC_MSG_CHECKING([for libinn.h])
64  for path in $testpath ; do
65    if [ test -f $path/libinn.h ] || [ test -f $path/inn/libinn.h ] ; then
66      AC_MSG_RESULT($path)
67      found="yes"
68      CPPFLAGS="$CPPFLAGS -I$path"
69      break
70    fi
71  done
72  test "$found" != "yes" && AC_MSG_RESULT(not found)
73  ], [
74  AC_CHECK_LIB(dbz, main, [DB_LIB="-ldbz"; DB_TYPE="-DUSE_DBZ"], [
75    AC_CHECK_LIB(ndbm, main, [DB_LIB="-lndbm"; DB_TYPE="-DUSE_NDBM"], [
76      AC_CHECK_LIB(gdbm, main, [DB_LIB="-lgdbm"; DB_TYPE="-DUSE_GDBM"], [
77        AC_CHECK_LIB(dbm, main, [DB_LIB="-ldbm"; DB_TYPE="-DUSE_DBM"], [
78         HISTORY="chkhistory.o"])])])])
79])
80
81if test "$with_perl_exe" ; then
82	AC_CHECK_PROG(PERL, perl, true, false, [$with_perl_exe])
83	whichperl=${with_perl_exe}/perl
84else
85	AC_CHECK_PROG(PERL, perl, true, false)
86	whichperl=perl
87fi
88if test "$PERL" = "true"; then
89  found="no"
90  AC_MSG_CHECKING([for libperl.a])
91  for path in `$whichperl -e 'foreach $i (@INC) { printf("%s ", $i) }'`; do
92    if test -f $path/libperl.a; then
93      AC_MSG_RESULT($path)
94      found="yes"
95      break
96    fi
97    path="${path}/CORE"
98    if test -f $path/libperl.a; then
99      AC_MSG_RESULT($path)
100      found="yes"
101      break
102    fi
103  done
104  if test "$found" = "yes"; then
105    PERL_DEFS="-DPERL_EMBED -Dbool=char -DHAS_BOOL"
106    PERL_LIB="-lperl"
107    PERL_LIB_LOC="-L$path"
108    PERL_INC_LOC="-I$path"
109    AC_CHECK_LIB(m, cos, [PERL_LIB="$PERL_LIB -lm"])
110    AC_CHECK_LIB(crypt, crypt, [PERL_LIB="$PERL_LIB -lcrypt"])
111  else
112     AC_MSG_RESULT(not found)
113  fi
114fi
115
116#AC_OUTPUT(Spanish.docs/Makefile Makefile, echo timestamp > stamp-h)
117AC_SUBST(DB_TYPE)
118AC_SUBST(DB_LIB)
119AC_SUBST(HISTORY)
120AC_SUBST(SSL_LIB)
121AC_SUBST(SSL_DEFS)
122AC_SUBST(PERL_DEFS)
123AC_SUBST(PERL_LIB)
124AC_SUBST(PERL_LIB_LOC)
125AC_SUBST(PERL_INC_LOC)
126
127AC_OUTPUT(Makefile, echo timestamp > stamp-h)
128