chiark / gitweb /
py: New Python module for writing services and suchlike
[tripe] / configure.ac
1 dnl -*-autoconf-*-
2 dnl
3 dnl Configuration script for TrIPE
4 dnl
5 dnl (c) 2001 Straylight/Edgeware
6 dnl
7
8 dnl ----- Licensing notice --------------------------------------------------
9 dnl
10 dnl This file is part of Trivial IP Encryption (TrIPE).
11 dnl
12 dnl TrIPE is free software; you can redistribute it and/or modify
13 dnl it under the terms of the GNU General Public License as published by
14 dnl the Free Software Foundation; either version 2 of the License, or
15 dnl (at your option) any later version.
16 dnl
17 dnl TrIPE is distributed in the hope that it will be useful,
18 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 dnl GNU General Public License for more details.
21 dnl
22 dnl You should have received a copy of the GNU General Public License
23 dnl along with TrIPE; if not, write to the Free Software Foundation,
24 dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 dnl--------------------------------------------------------------------------
27 dnl Initialization.
28
29 mdw_AUTO_VERSION
30 AC_INIT([tripe], AUTO_VERSION, [mdw@distorted.org.uk])
31 AC_CONFIG_SRCDIR([server/tripe.h])
32 AC_CONFIG_AUX_DIR([config])
33 AM_INIT_AUTOMAKE([foreign])
34
35 AC_PROG_CC
36 AM_PROG_CC_C_O
37 AX_CFLAGS_WARN_ALL
38 AC_CANONICAL_HOST
39 AM_PROG_LIBTOOL
40
41 AC_CHECK_PROGS([AUTOM4TE], [autom4te])
42
43 dnl--------------------------------------------------------------------------
44 dnl C programming environment.
45
46 AC_CHECK_HEADERS([stdarg.h])
47
48 AC_SEARCH_LIBS([socket], [socket])
49
50 case "$host_os" in
51   linux)
52     AC_ARG_WITH([linux-includes],
53                 AS_HELP_STRING(
54                   [--with-linux-includes=DIR],
55                   [Linux kernel includes]),
56                 [CFLAGS="$CFLAGS -I$withval"], [:])
57     ;;
58 esac
59
60 PKG_CHECK_MODULES([mLib], [mLib >= 2.1.0])
61 PKG_CHECK_MODULES([catacomb], [catacomb >= 2.1.1])
62
63 CFLAGS="$CFLAGS $mLib_CFLAGS $catacomb_CFLAGS"
64
65 dnl--------------------------------------------------------------------------
66 dnl Directories to install things into.
67
68 dnl TRIPE_DEFINE_PATH(VAR, ARG, HELP, DEFAULT, [DEFINE, DEFINEHELP])
69 AC_DEFUN([TRIPE_DEFINE_PATH], [
70   AC_ARG_WITH([$1], AS_HELP_STRING([--with-$1=$2], [$3]),
71               [$1=$withval], [$1=$4])
72   AC_SUBST([$1])
73   m4_if([$5], [], [], [
74     mdw_DEFINE_PATHS([mdw_DEFINE_PATH([$5], [$][$1], [$6])])
75   ])
76 ])
77
78 dnl Actual options.
79 TRIPE_DEFINE_PATH(
80   [configdir], [DIR], [keys and other configuration [[LOCALSTATE/tripe]]],
81   ['${localstatedir}/tripe'],
82   [CONFIGDIR], [Look for keys and other configuration here.])
83
84 TRIPE_DEFINE_PATH(
85   [socketdir], [DIR], [admin socket [[.]]], [.],
86   [SOCKETDIR], [Create or look for administration socket here.])
87
88 TRIPE_DEFINE_PATH(
89   [pidfile], [FILE], [process-id [[./tripectl.pid]]], [tripectl.pid])
90
91 TRIPE_DEFINE_PATH(
92   [initconfig], [FILE], [configuration for init script [[/etc/tripe.conf]]],
93   [/etc/tripe.conf])
94
95 TRIPE_DEFINE_PATH(
96   [logfile], [FILE], [logging output [[./tripe.log]]], [tripe.log])
97
98 dnl--------------------------------------------------------------------------
99 dnl Privilege-separation helper.
100
101 mdw_DEFINE_PATHS([
102   AC_DEFINE_UNQUOTED([PRIVSEP_HELPER],
103     ["mdw_PATH([$libexecdir])/mdw_PROG([tripe-privhelper])"],
104     [Pathname of privilege-separation helper.])
105 ])
106
107 dnl--------------------------------------------------------------------------
108 dnl Other options.
109
110 AC_ARG_WITH([tracing],
111             AS_HELP_STRING(
112               [--without-tracing],
113               [compile out tracing support (not recommended)]),
114             [test "$withval" = no &&
115               AC_DEFINE([NTRACE], [1], [Disable all tracing.])],
116             [:])
117
118 dnl--------------------------------------------------------------------------
119 dnl Path MTU discovery.
120
121 case $host_os in
122   linux*)
123     pmtu=yes
124     ;;
125   *)
126     pmtu=no
127     ;;
128 esac
129 AM_CONDITIONAL([PATHMTU], [test $pmtu = yes])
130
131 dnl--------------------------------------------------------------------------
132 dnl Tunnel devices.
133
134 dnl Provide the user with a choice.
135 AC_ARG_WITH([tunnel],
136             AS_HELP_STRING(
137               [--with-tunnel=KIND],
138               [kinds of tunnel device to use (linux, unet, bsd, slip)]),
139             [tun=$withval], [tun=auto])
140
141 dnl If he doesn't choose, pick something sensible.
142 if test "$tun" = auto; then
143   AC_CACHE_CHECK([tunnel drivers to use], [mdw_cv_tunnel], [
144     mdw_cv_tunnel=""
145     case $host_os in
146       linux*)
147         case `uname -r` in
148           [2.[4-9].*] | [2.[1-9][0-9]*.*] | [[3-9].*] | [[1-9][0-9]*.*])
149             mdw_cv_tunnel=linux
150             ;;
151           *)
152             mdw_cv_tunnel=unet
153             ;;
154         esac
155         ;;
156       *bsd*)
157         mdw_cv_tunnel=bsd
158         ;;
159     esac
160     mdw_cv_tunnel=$mdw_cv_tunnel${mdw_cv_tunnel:+ }slip
161   ])
162   tun=$mdw_cv_tunnel
163 fi
164
165 tunnels=""
166 for i in $tun; do
167   case $i in
168     linux) AC_DEFINE([TUN_LINUX], [1],
169                      [Install the Linux TUN/TAP driver.]) ;;
170     bsd) AC_DEFINE([TUN_BSD], [1],
171                    [Install the BSD tunnel driver.]) ;;
172     unet) AC_DEFINE([TUN_UNET], [1],
173                     [Install the obsolete Linux Usernet driver.]) ;;
174     slip) ;;
175     *) AC_MSG_ERROR([Unknown tunnel type]) ;;
176   esac
177   tunnels="$tunnels&tun_$i, "
178 done
179 AC_DEFINE_UNQUOTED([TUN_LIST], [$tunnels 0],
180   [List of tunnel drivers to install.])
181
182 dnl--------------------------------------------------------------------------
183 dnl Python.
184
185 dnl Find out whether Python exists at all.
186 AM_PATH_PYTHON([2.4], [python=yes], [python=no])
187 AM_CONDITIONAL([HAVE_PYTHON], [test $python = yes])
188
189 dnl Find out whether we can use Catacomb and GTK.
190 if test $python = yes; then
191   AC_PYTHON_MODULE([pygtk])
192   AC_PYTHON_MODULE([catacomb])
193 fi
194 AM_CONDITIONAL([HAVE_PYGTK], [test ${HAVE_PYMOD_PYGTK-no} = yes])
195 AM_CONDITIONAL([HAVE_PYCATACOMB], [test ${HAVE_PYMOD_CATACOMB-no} = yes])
196
197 dnl--------------------------------------------------------------------------
198 dnl Wireshark.
199 dnl
200 dnl This is all distressingly ugly and complicated.  Why they can't just
201 dnl provide a pkg-config dropping containing all the useful information about
202 dnl the installation I don't know.
203
204 WIRESHARK_CFLAGS=""
205 : ${wireshark_plugindir=unknown}
206
207 dnl Get the user to help.
208 AC_ARG_WITH([wireshark],
209             AS_HELP_STRING(
210               [--with-wireshark[=DIR]],
211               [build and install Wireshark plugin]),
212             [case "$withval" in
213                no)  haveshark=no needshark=no ;;
214                yes) haveshark=yes needshark=yes ;;
215                *)   haveshark=yes needshark=yes
216                     wireshark_plugindir=$withval ;;
217             esac],
218             [haveshark=yes needshark=no])
219
220 dnl Try to find the Wireshark installation directory the hard way.
221 case "$haveshark,$wireshark_plugindir" in
222   yes,unknown)
223     AC_CACHE_CHECK([where to put Wireshark plugins],
224       [mdw_cv_wireshark_plugin_dir], [
225       mdw_cv_wireshark_plugin_dir="failed"
226       wsprefix=none
227       for i in "${prefix}" /usr/local /usr `echo $PATH | tr : " "`; do
228         if test -x "$i/bin/tshark"; then
229            wsprefix=$i
230            break
231         fi
232       done
233       if test "$wsprefix" != none; then
234         wsbin=$wsprefix/bin/tshark
235         wsver=`$wsbin -v | sed ['s/^[^ ]* \([0-9A-Za-z.]*\).*$/\1/;q']`
236         dir=$wsprefix/lib/wireshark/plugins
237         test -d "$dir/$wsver" && dir="$dir/$wsver"
238         if test -d "$dir"; then
239           mdw_cv_wireshark_plugin_dir=$dir
240         fi
241       fi
242     ])
243     case $mdw_cv_wireshark_plugin_dir in
244       failed) haveshark=no ;;
245       *) wireshark_plugindir=$mdw_cv_wireshark_plugin_dir ;;
246     esac
247 esac
248
249 dnl If we're still interested, find Glib.
250 case "$haveshark" in
251   yes) AM_PATH_GLIB_2_0([2.4.0], [], [haveshark=false], [gmodule]) ;;
252 esac
253
254 dnl Find the include directory.  This would be much easier if they just
255 dnl provided a pkg-config file.
256 case "$haveshark" in
257   yes)
258     bad=yes
259     mdw_CFLAGS=$CFLAGS
260     wsprefix=`echo $wireshark_plugindir | sed 's:/lib/.*$::'`
261     AC_CACHE_CHECK([how to find the Wireshark headers],
262                    [mdw_cv_wireshark_includes], [
263       mdw_cv_wireshark_includes=failed
264       for i in \
265           "" \
266           "-I${wsprefix}/include/wireshark" \
267           "-I${wsprefix}/include" \
268           "-I${prefix}/include/wireshark" \
269           "-I${prefix}/include" \
270           "-I/usr/include/wireshark" \
271           "-I/usr/local/include/wireshark" \
272           "-I/usr/local/include"; do
273         CFLAGS="$GLIB_CFLAGS $i"
274         AC_TRY_COMPILE([
275 #include <netinet/in.h>
276 #include <glib.h>
277 #include <wireshark/config.h>
278 #include <wireshark/epan/packet.h>],
279         [dissector_handle_t dh; dh = create_dissector_handle(0, 0);],
280         [bad=no; break])
281       done
282       case "$bad" in
283         no) mdw_cv_wireshark_includes=$i ;;
284       esac
285       CFLAGS=$mdw_CFLAGS
286     ])
287     case "$mdw_cv_wireshark_includes" in
288       failed) haveshark=no ;;
289     esac
290 esac
291
292 case "$haveshark,$needshark" in
293   no,yes)
294     AC_MSG_ERROR([failed to configure Wireshark plugin])
295     ;;
296   yes,*)
297     WIRESHARK_CFLAGS="$CFLAGS $GLIB_CFLAGS $mdw_cv_wireshark_includes"
298     AC_SUBST(WIRESHARK_CFLAGS)
299     AC_SUBST(wireshark_plugindir)
300     ;;
301 esac
302
303 AM_CONDITIONAL([HAVE_WIRESHARK], [test "$haveshark" = yes])
304
305 dnl--------------------------------------------------------------------------
306 dnl Produce output.
307
308 AC_CONFIG_HEADER([config/config.h])
309 AC_CONFIG_TESTDIR([t])
310
311 AC_CONFIG_FILES(
312   [Makefile]
313   [common/Makefile]
314   [uslip/Makefile]
315   [pathmtu/Makefile]
316   [client/Makefile]
317   [priv/Makefile]
318   [server/Makefile]
319   [proxy/Makefile]
320   [pkstream/Makefile]
321   [wireshark/Makefile]
322   [init/Makefile]
323   [py/Makefile]
324   [keys/Makefile]
325   [svc/Makefile]
326   [mon/Makefile]
327   [t/Makefile t/atlocal])
328 AC_OUTPUT
329
330 dnl ----- That's all, folks -------------------------------------------------