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