chiark / gitweb /
Support SLIP encapsulation as a tunnelling mechanism.
[tripe] / configure.in
1 dnl -*-autoconf-*-
2 dnl
3 dnl $Id$
4 dnl
5 dnl Configuration script for TrIPE
6 dnl
7 dnl (c) 2001 Straylight/Edgeware
8 dnl
9
10 dnl ----- Licensing notice --------------------------------------------------
11 dnl
12 dnl This file is part of Trivial IP Encryption (TrIPE).
13 dnl
14 dnl TrIPE is free software; you can redistribute it and/or modify
15 dnl it under the terms of the GNU General Public License as published by
16 dnl the Free Software Foundation; either version 2 of the License, or
17 dnl (at your option) any later version.
18 dnl 
19 dnl TrIPE is distributed in the hope that it will be useful,
20 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
21 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 dnl GNU General Public License for more details.
23 dnl 
24 dnl You should have received a copy of the GNU General Public License
25 dnl along with TrIPE; if not, write to the Free Software Foundation,
26 dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
28 AC_INIT(tripe.c)
29 AM_INIT_AUTOMAKE(tripe, 1.0.0pre6)
30 AM_CONFIG_HEADER(config.h)
31 AC_CANONICAL_HOST
32
33 AC_PROG_MAKE_SET
34 AC_PROG_CC
35 AM_PROG_LIBTOOL
36 AC_CHECK_HEADERS([stdarg.h])
37 mdw_GCC_FLAGS([-Wall])
38 mdw_OPT_TRACE
39
40 AC_ARG_WITH([linux-includes],
41 [  --with-linux-includes=DIR
42                           search for Linux kernel includes in DIR],
43 [CFLAGS="$CFLAGS -I$withval"],
44 [:])
45
46 AC_ARG_WITH([configdir],
47 [  --with-configdir=DIR    look for keys and other configuration in DIR
48                           [default=/var/lib/tripe]],
49 [configdir=$withval],
50 [configdir=/var/lib/tripe])
51
52 AC_ARG_WITH([socketdir],
53 [  --with-socketdir=DIR    put admin socket in DIR [default=.]],
54 [socketdir=$withval],
55 [socketdir=.])
56
57 AC_ARG_WITH([pidfile],
58 [  --with-pidfile=FILE     make tripectl write its pid to FILE
59                           [default=./tripectl.pid]],
60 [pidfile=$withval],
61 [pidfile=tripectl.pid])
62
63 AC_ARG_WITH([initconfig],
64 [  --with-initconfig=FILE  read definitions from FILE in init script
65                           [default=/etc/tripe.conf]],
66 [initconfig=$withval],
67 [initconfig=/etc/tripe.conf])
68
69 AC_ARG_WITH([logfile],
70 [  --with-logfile=DIR       make tripectl write its log to FILE 
71                            [default=./tripe.log]],
72 [logfile=$withval],
73 [logfile=tripe.log])
74
75 DIRS=""
76 ETHEREAL_CFLAGS=""
77 ETHEREAL_PLUGIN_DIR="unknown"
78 AC_ARG_WITH([ethereal],
79 [  --with-ethereal         build and install Ethereal plugin],
80 [case "$withval" in
81    no) ethereal=false requireethereal=false;;
82    yes) ethereal=true; requireethereal=true;;
83    *) ethereal=true requireethereal=true ETHEREAL_PLUGIN_DIR=$withval;;
84 esac],
85 [ethereal=true requireethereal=false])
86
87 tun=guess
88 AC_ARG_WITH([tunnel],
89 [  --with-tunnel=KIND      kind of tunnel device to use
90                             (linux, unet, bsd, slip)],
91 [tun=$withval])
92
93 if test "$tun" = guess; then
94   AC_CACHE_CHECK([tunnel device to use], [mdw_cv_tunnel], [
95     case $host_os in
96       linux*)
97         case `uname -r` in
98 changequote(,)dnl
99           2.[4-9].* | 2.[1-9][0-9]*.* | [3-9].* | [1-9][0-9]*.*)
100 changequote([,])dnl
101             mdw_cv_tunnel=linux
102             ;;
103           *)
104             mdw_cv_tunnel=unet
105             ;;
106         esac
107         ;;
108       *bsd*)
109         mdw_cv_tunnel=bsd
110         ;;
111       *)
112         mdw_cv_tunnel=slip
113         ;;
114     esac
115   ])
116   tun=$mdw_cv_tunnel
117 fi
118
119 case $tun in
120   linux | unet | bsd | slip) ;;
121   *) AC_MSG_ERROR([Unknown tunnel type]) ;;
122 esac
123 AC_DEFINE_UNQUOTED([TUN_TYPE], [TUN_`echo $tun | tr a-z A-Z`],
124   [Set to the tunnel driver for your OS.  See TUN_* in tripe.h.])
125 AC_SUBST(tun)
126
127 mdw_MLIB(2.0.0)
128 mdw_CATACOMB(2.1.0, [CFLAGS="$CFLAGS $CATACOMB_CFLAGS"])
129
130 if test "$ethereal" = true -a "$ETHEREAL_PLUGIN_DIR" = unknown; then
131   AC_CACHE_CHECK([where to put Ethereal plugins], 
132     [mdw_cv_ethereal_plugin_dir], [
133     changequote(,)
134     mdw_cv_ethereal_plugin_dir="failed"
135     ethprefix=none
136     for i in "${prefix}" /usr/local /usr `echo $PATH | tr : " "`; do
137       if test -x "$i/bin/tethereal"; then
138          ethprefix=$i
139          break
140       fi
141     done
142     if test "$ethprefix" != none; then
143       ethbin=$ethprefix/bin/tethereal
144       ethver=`$ethbin -v | sed 's/^[^ ]* \([0-9A-Za-z.]*\).*$/\1/;q'`
145       dir=$ethprefix/lib/ethereal/plugins/$ethver
146       if test -d "$dir"; then
147         mdw_cv_ethereal_plugin_dir=$dir
148       fi
149     fi
150     changequote([, ])
151   ])
152   case $mdw_cv_ethereal_plugin_dir in
153     failed) ethereal=false;;
154     *) ETHEREAL_PLUGIN_DIR=$mdw_cv_ethereal_plugin_dir;;
155   esac
156 fi
157
158 if test "$ethereal" = true; then
159   AM_PATH_GLIB([1.2.0], [], ethereal=false, [gmodule])
160 fi
161 if test "$ethereal" = true; then
162   bad=true
163   mdw_CFLAGS=$CFLAGS
164   ethprefix=`echo $ETHEREAL_PLUGIN_DIR | sed 's:/lib/.*$::'`
165   AC_CACHE_CHECK([how to find the Ethereal headers], 
166     [mdw_cv_ethereal_includes], [
167     mdw_cv_ethereal_includes=failed
168     for i in \
169         "" \
170         "-I${ethprefix}/include/ethereal" \
171         "-I${ethprefix}/include" \
172         "-I${prefix}/include/ethereal" \
173         "-I${prefix}/include" \
174         "-I/usr/include/ethereal" \
175         "-I/usr/local/include/ethereal" \
176         "-I/usr/local/include"; do
177       CFLAGS="$GLIB_CFLAGS $i"
178       AC_TRY_COMPILE([
179 #include <netinet/in.h>
180 #include <glib.h>
181 #include <ethereal/config.h>
182 #include <ethereal/epan/packet.h>
183 ], [
184         dissector_handle_t dh;
185         dh = create_dissector_handle(0, 0);
186       ], [bad=false; break])
187     done
188     if test $bad = false; then
189       mdw_cv_ethereal_includes=$i
190     fi
191     CFLAGS=$mdw_CFLAGS
192   ])
193   case $mdw_cv_ethereal_plugin_dir in
194     failed) ethereal=false;;
195     *) ETHEREAL_PLUGIN_DIR=$mdw_cv_ethereal_plugin_dir;;
196   esac  
197 fi
198
199 if test "$ethereal" = true; then
200   ETHEREAL_CFLAGS="$CFLAGS $GLIB_CFLAGS $mdw_cv_ethereal_includes"
201   AC_SUBST(ETHEREAL_CFLAGS)
202   AC_SUBST(ETHEREAL_PLUGIN_DIR)
203   DIRS="$DIRS ethereal"
204 fi
205
206 if test "$ethereal" = false -a "$requireethereal" = true; then
207   AC_MSG_ERROR([failed to configure Ethereal plugin])
208 fi
209
210 AH_TEMPLATE([CONFIGDIR],
211             [Tripe should look here for keys and other configuration.])
212 AH_TEMPLATE([SOCKETDIR],
213             [Tripe should make its administration socket here.])
214 mdw_DEFINE_PATHS([
215   mdw_DEFINE_PATH([CONFIGDIR], [$configdir])
216   mdw_DEFINE_PATH([SOCKETDIR], [$socketdir])
217   AC_SUBST(socketdir) AC_SUBST(configdir) AC_SUBST(logfile) AC_SUBST(pidfile)
218   AC_SUBST(initconfig)
219 ])
220 AC_SUBST(DIRS)
221 AC_OUTPUT(Makefile doc/Makefile ethereal/Makefile tripe-init)
222
223 dnl ----- That's all, folks -------------------------------------------------