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