configure.ac: Hack probed Wireshark plugin dir in case of corruption.
[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 AX_TYPE_SOCKLEN_T
40 AC_CANONICAL_HOST
41 AM_PROG_LIBTOOL
42
43 AC_CHECK_PROGS([AUTOM4TE], [autom4te])
44
45 mdw_ORIG_CFLAGS=$CFLAGS
46 mdw_ORIG_CPPFLAGS=$CPPFLAGS
47 AC_SUBST(AM_CFLAGS)
48 AC_SUBST(AM_CPPFLAGS)
49
50 dnl--------------------------------------------------------------------------
51 dnl C programming environment.
52
53 AC_CHECK_HEADERS([stdarg.h])
54
55 AC_SEARCH_LIBS([socket], [socket])
56
57 case "$host_os" in
58 linux)
59 AC_ARG_WITH([linux-includes],
60 AS_HELP_STRING(
61 [--with-linux-includes=DIR],
62 [Linux kernel includes]),
63 [AM_CPPFLAGS="AM_CPPFLAGS -I$withval"], [:])
64 ;;
65 esac
66
67 PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1])
68 PKG_CHECK_MODULES([catacomb], [catacomb >= 2.2.2-38])
69
70 AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS $catacomb_CFLAGS"
71
72 dnl--------------------------------------------------------------------------
73 dnl Directories to install things into.
74
75 dnl TRIPE_DEFINE_PATH(VAR, ARG, HELP, DEFAULT, [DEFINE, DEFINEHELP])
76 AC_DEFUN([TRIPE_DEFINE_PATH], [
77 AC_ARG_WITH([$1], AS_HELP_STRING([--with-$1=$2], [$3]),
78 [$1=$withval], [$1=$4])
79 AC_SUBST([$1])
80 m4_if([$5], [], [], [
81 mdw_DEFINE_PATHS([mdw_DEFINE_PATH([$5], [$][$1], [$6])])
82 ])
83 ])
84
85 dnl Actual options.
86 TRIPE_DEFINE_PATH(
87 [configdir], [DIR], [keys and other configuration [[LOCALSTATE/tripe]]],
88 ['${localstatedir}/tripe'],
89 [CONFIGDIR], [Look for keys and other configuration here.])
90
91 TRIPE_DEFINE_PATH(
92 [socketdir], [DIR], [admin socket [[.]]], [.],
93 [SOCKETDIR], [Create or look for administration socket here.])
94
95 TRIPE_DEFINE_PATH(
96 [pidfile], [FILE], [process-id [[./tripectl.pid]]], [tripectl.pid])
97
98 TRIPE_DEFINE_PATH(
99 [initconfig], [FILE],
100 [configuration for init script [[SYSCONFDIR/tripe.conf]]],
101 ['${sysconfdir}/tripe.conf'])
102
103 TRIPE_DEFINE_PATH(
104 [logfile], [FILE], [logging output [[./tripe.log]]], [tripe.log])
105
106 dnl--------------------------------------------------------------------------
107 dnl Privilege-separation helper.
108
109 mdw_DEFINE_PATHS([
110 AC_DEFINE_UNQUOTED([PRIVSEP_HELPER],
111 ["mdw_PATH([$libexecdir])/mdw_PROG([tripe-privhelper])"],
112 [Pathname of privilege-separation helper.])
113 ])
114
115 dnl--------------------------------------------------------------------------
116 dnl Other options.
117
118 AC_ARG_WITH([tracing],
119 AS_HELP_STRING(
120 [--without-tracing],
121 [compile out tracing support (not recommended)]),
122 [test "$withval" = no &&
123 AC_DEFINE([NTRACE], [1], [Disable all tracing.])],
124 [:])
125
126 dnl--------------------------------------------------------------------------
127 dnl Tunnel devices.
128
129 dnl Provide the user with a choice.
130 AC_ARG_WITH([tunnel],
131 AS_HELP_STRING(
132 [--with-tunnel=KIND],
133 [kinds of tunnel device to use (linux, unet, bsd, slip)]),
134 [tun=$withval], [tun=auto])
135
136 dnl If he doesn't choose, pick something sensible.
137 if test "$tun" = auto; then
138 AC_CACHE_CHECK([tunnel drivers to use], [mdw_cv_tunnel], [
139 mdw_cv_tunnel=""
140 case $host_os in
141 linux*)
142 case `uname -r` in
143 [2.[4-9].*] | [2.[1-9][0-9]*.*] | [[3-9].*] | [[1-9][0-9]*.*])
144 mdw_cv_tunnel=linux
145 ;;
146 *)
147 mdw_cv_tunnel=unet
148 ;;
149 esac
150 ;;
151 *bsd*)
152 mdw_cv_tunnel=bsd
153 ;;
154 esac
155 mdw_cv_tunnel=$mdw_cv_tunnel${mdw_cv_tunnel:+ }slip
156 ])
157 tun=$mdw_cv_tunnel
158 fi
159
160 tunnels=""
161 for i in $tun; do
162 case $i in
163 linux) AC_DEFINE([TUN_LINUX], [1],
164 [Install the Linux TUN/TAP driver.]) ;;
165 bsd) AC_DEFINE([TUN_BSD], [1],
166 [Install the BSD tunnel driver.]) ;;
167 unet) AC_DEFINE([TUN_UNET], [1],
168 [Install the obsolete Linux Usernet driver.]) ;;
169 slip) ;;
170 *) AC_MSG_ERROR([Unknown tunnel type]) ;;
171 esac
172 tunnels="$tunnels&tun_$i, "
173 done
174 AC_DEFINE_UNQUOTED([TUN_LIST], [$tunnels 0],
175 [List of tunnel drivers to install.])
176
177 dnl--------------------------------------------------------------------------
178 dnl Python.
179
180 dnl Find out whether Python exists at all.
181 AM_PATH_PYTHON([2.4], [python=yes], [python=no])
182 AM_CONDITIONAL([HAVE_PYTHON], [test $python = yes])
183
184 dnl Find out whether we can use the various external modules.
185 if test $python = yes; then
186 AC_PYTHON_MODULE([pygtk])
187 AC_PYTHON_MODULE([cdb])
188 AC_PYTHON_MODULE([mLib])
189 AC_PYTHON_MODULE([catacomb])
190 fi
191 AM_CONDITIONAL([HAVE_PYGTK], [test ${HAVE_PYMOD_PYGTK-no} = yes])
192 AM_CONDITIONAL([HAVE_PYCDB], [test ${HAVE_PYMOD_CDB-no} = yes])
193 AM_CONDITIONAL([HAVE_PYMLIB], [test ${HAVE_PYMOD_MLIB-no} = yes])
194 AM_CONDITIONAL([HAVE_PYCATACOMB], [test ${HAVE_PYMOD_CATACOMB-no} = yes])
195
196 dnl--------------------------------------------------------------------------
197 dnl Wireshark.
198
199 dnl Get the user to help.
200 wireshark_plugindir=unknown
201 AC_ARG_WITH([wireshark],
202 AS_HELP_STRING(
203 [--with-wireshark],
204 [build and install Wireshark plugin]),
205 [case "$withval" in
206 no) wantshark=no mustshark=no ;;
207 yes) wantshark=yes mustshark=yes ;;
208 *) wantshark=yes mustshark=yes
209 wireshark_plugindir=$withval ;;
210 esac],
211 [wantshark=yes mustshark=no])
212
213 case "$wantshark" in
214 yes)
215 PKG_CHECK_MODULES([WIRESHARK], [wireshark >= 1.12.1],
216 [haveshark=yes], [haveshark=no])
217 ;;
218 *)
219 haveshark=no
220 ;;
221 esac
222
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=$(
228 $PKG_CONFIG --variable=plugindir "wireshark >= 1.12.1")
229 dnl It seems that the Debian package has a habit of bungling the
230 dnl plugin path (#779788, #857729, ...).
231 case "$mdw_cv_wireshark_plugin_dir" in
232 /usr//usr/*)
233 mdw_cv_wireshark_plugin_dir=${mdw_cv_wireshark_plugin_dir#/usr/}
234 ;;
235 esac])
236 case "$mdw_cv_wireshark_plugin_dir" in
237 /*)
238 if test ! -d "$mdw_cv_wireshark_plugin_dir"; then
239 AC_MSG_WARN([alleged Wireshark plugin directory $mdw_cv_wireshark_plugin_dir doesn't exist])
240 haveshark=no
241 else
242 wireshark_plugindir=$mdw_cv_wireshark_plugin_dir
243 haveshark=yes
244 fi
245 ;;
246 *)
247 AC_MSG_WARN([failed to read Wireshark plugin directory])
248 haveshark=no
249 ;;
250 esac
251 ;;
252 esac
253
254 dnl If we're still interested, find Glib.
255 case "$haveshark" in
256 yes) AM_PATH_GLIB_2_0([2.4.0], [], [haveshark=false], [gmodule]) ;;
257 esac
258
259 case "$haveshark,$needshark" in
260 no,yes)
261 AC_MSG_ERROR([failed to configure Wireshark plugin])
262 ;;
263 yes,*)
264 WIRESHARK_CFLAGS="$GLIB_CFLAGS $WIRESHARK_CFLAGS"
265 AC_SUBST(WIRESHARK_CFLAGS)
266 AC_SUBST(wireshark_plugindir)
267 ;;
268 esac
269
270 AM_CONDITIONAL([HAVE_WIRESHARK], [test "$haveshark" = yes])
271
272 dnl--------------------------------------------------------------------------
273 dnl Produce output.
274
275 CFLAGS=$mdw_ORIG_CFLAGS
276 CPPFLAGS=$mdw_ORIG_CPPFLAGS
277
278 AC_CONFIG_HEADER([config/config.h])
279 AC_CONFIG_TESTDIR([t])
280
281 AC_CONFIG_FILES(
282 [Makefile]
283 [common/Makefile]
284 [uslip/Makefile]
285 [pathmtu/Makefile]
286 [client/Makefile]
287 [priv/Makefile]
288 [server/Makefile]
289 [proxy/Makefile]
290 [pkstream/Makefile]
291 [wireshark/Makefile]
292 [init/Makefile]
293 [py/Makefile]
294 [peerdb/Makefile]
295 [keys/Makefile]
296 [svc/Makefile]
297 [mon/Makefile]
298 [contrib/Makefile]
299 [t/Makefile t/atlocal])
300 AC_OUTPUT
301
302 dnl----- That's all, folks --------------------------------------------------