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