]> git.ipfire.org Git - thirdparty/bird.git/blame - configure.ac
Autoconf: Minor cleanup
[thirdparty/bird.git] / configure.ac
CommitLineData
2f9bcf97
MM
1dnl ** This is a configure script template for BIRD
2dnl ** Process it with autoconf to get ./configure
9fac310d 3dnl ** (c) 1999--2000 Martin Mares <mj@ucw.cz>
2f9bcf97 4
7a855725
OZ
5AC_INIT
6AC_CONFIG_SRCDIR([conf/confbase.Y])
b81a73d1
OZ
7AC_CONFIG_AUX_DIR([tools])
8
9AC_ARG_ENABLE([client],
10 [AS_HELP_STRING([--enable-client], [enable building of BIRD client @<:@yes@:>@])],
11 [],
12 [enable_client=yes]
13)
14
15AC_ARG_ENABLE([debug],
16 [AS_HELP_STRING([--enable-debug], [enable internal debugging routines @<:@no@:>@])],
17 [],
18 [enable_debug=no]
19)
20
21AC_ARG_ENABLE([ipv6],
22 [AS_HELP_STRING([--enable-ipv6], [enable building of IPv6 version @<:@no@:>@])],
23 [],
24 [enable_ipv6=no]
25)
26
27AC_ARG_ENABLE([memcheck],
28 [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])],
29 [],
30 [enable_memcheck=yes]
31)
32
33AC_ARG_ENABLE([pthreads],
34 [AS_HELP_STRING([--enable-pthreads], [enable POSIX threads support @<:@try@:>@])],
35 [],
36 [enable_pthreads=try]
37)
38
39AC_ARG_WITH([protocols],
40 [AS_HELP_STRING([--with-protocols=LIST], [include specified routing protocols @<:@all@:>@])],
41 [],
42 [with_protocols="all"]
43)
44
45AC_ARG_WITH([suffix],
46 [AS_HELP_STRING([--with-suffix=STRING], [use specified suffix for BIRD files @<:@6 for IPv6@:>@])],
47 [given_suffix="yes"]
48)
49
50AC_ARG_WITH([sysconfig],
b47d33b3 51 [AS_HELP_STRING([--with-sysconfig=FILE], [use specified BIRD system configuration file])]
b81a73d1
OZ
52)
53
54AC_ARG_WITH([runtimedir],
16fb28e5 55 [AS_HELP_STRING([--with-runtimedir=PATH], [run-state data, obsolete variant of --runstatedir])],
b47d33b3 56 [runstatedir="$with_runtimedir"]
b81a73d1
OZ
57)
58
59AC_ARG_WITH([iproutedir],
60 [AS_HELP_STRING([--with-iproutedir=PATH], [path to iproute2 config files @<:@/etc/iproute2@:>@])],
61 [given_iproutedir="yes"]
62)
63
ab188fb7
OZ
64AC_ARG_VAR([FLEX], [location of the Flex program])
65AC_ARG_VAR([BISON], [location of the Bison program])
66AC_ARG_VAR([M4], [location of the M4 program])
67
2f9bcf97 68
49e7e5ee 69if test "$srcdir" = . ; then
b81a73d1
OZ
70 # Building in current directory => create obj directory holding all objects
71 objdir=obj
72 mkdir -p obj
73 srcdir_rel=..
74 makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
75 exedir=..
49e7e5ee 76else
b81a73d1
OZ
77 # Building in separate directory
78 objdir=.
79 srcdir_rel=$srcdir
80 makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
81 exedir=.
49e7e5ee 82fi
b81a73d1 83
49e7e5ee 84case $srcdir_rel in
b81a73d1
OZ
85 /*) srcdir_rel_mf=$srcdir_rel ;;
86 *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
49e7e5ee 87esac
b81a73d1
OZ
88
89AC_SUBST([objdir])
90AC_SUBST([exedir])
91AC_SUBST([srcdir_rel_mf])
16fb28e5
OZ
92
93# Workaround for older Autoconfs that do not define runstatedir
94AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run'])
95AC_SUBST([runstatedir])
96
49e7e5ee 97
c817b991 98if test "$enable_ipv6" = yes ; then
b81a73d1
OZ
99 ip=ipv6
100 SUFFIX=6
101 proto_radv=radv
c817b991 102else
b81a73d1
OZ
103 ip=ipv4
104 SUFFIX=""
c3226991
OZ
105fi
106
ab188fb7 107if test "$given_suffix" = yes ; then
b81a73d1 108 SUFFIX="$with_suffix"
ab188fb7 109fi
b81a73d1 110AC_SUBST([SUFFIX])
ab188fb7 111
ab188fb7 112if test "$enable_debug" = yes ; then
b81a73d1
OZ
113 CONFIG_FILE="bird$SUFFIX.conf"
114 CONTROL_SOCKET="bird$SUFFIX.ctl"
ab188fb7 115else
b81a73d1 116 CONFIG_FILE="\$(sysconfdir)/bird$SUFFIX.conf"
16fb28e5 117 CONTROL_SOCKET="\$(runstatedir)/bird.ctl"
ab188fb7 118fi
b81a73d1
OZ
119AC_SUBST([CONFIG_FILE])
120AC_SUBST([CONTROL_SOCKET])
ab188fb7 121
b81a73d1
OZ
122AC_SEARCH_LIBS([clock_gettime], [rt posix4],
123 [],
124 [AC_MSG_ERROR([Function clock_gettime not available.])]
125)
fd91ae33 126
2f9bcf97 127AC_CANONICAL_HOST
416e3ee4 128
b1c030b0 129# Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
416e3ee4 130if test "$ac_test_CFLAGS" != set ; then
b81a73d1 131 bird_cflags_default=yes
416e3ee4 132fi
416e3ee4 133
e81b440f
OZ
134AC_PROG_CC
135if test -z "$GCC" ; then
b81a73d1 136 AC_MSG_ERROR([This program requires the GNU C Compiler.])
e81b440f
OZ
137fi
138
1ec52253 139if test "$enable_pthreads" != no ; then
b81a73d1
OZ
140 BIRD_CHECK_PTHREADS
141
142 if test "$bird_cv_lib_pthreads" = yes ; then
143 AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled])
144 CFLAGS="$CFLAGS -pthread"
145 LDFLAGS="$LDFLAGS -pthread"
146 proto_bfd=bfd
147 elif test "$enable_pthreads" = yes ; then
148 AC_MSG_ERROR([POSIX threads not available.])
149 fi
150
151 if test "$enable_pthreads" = try ; then
152 enable_pthreads="$bird_cv_lib_pthreads"
153 fi
1ec52253
OZ
154fi
155
bed41728 156if test "$bird_cflags_default" = yes ; then
b81a73d1
OZ
157 BIRD_CHECK_GCC_OPTION([bird_cv_c_option_wno_pointer_sign], [-Wno-pointer-sign], [-Wall])
158 BIRD_CHECK_GCC_OPTION([bird_cv_c_option_wno_missing_init], [-Wno-missing-field-initializers], [-Wall -Wextra])
159 BIRD_CHECK_GCC_OPTION([bird_cv_c_option_fno_strict_aliasing], [-fno-strict-aliasing])
160 BIRD_CHECK_GCC_OPTION([bird_cv_c_option_fno_strict_overflow], [-fno-strict-overflow])
161
162 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
163 BIRD_ADD_GCC_OPTION([bird_cv_c_option_wno_pointer_sign], [-Wno-pointer-sign])
164 BIRD_ADD_GCC_OPTION([bird_cv_c_option_wno_missing_init], [-Wno-missing-field-initializers])
165 BIRD_ADD_GCC_OPTION([bird_cv_c_option_fno_strict_aliasing], [-fno-strict-aliasing])
166 BIRD_ADD_GCC_OPTION([bird_cv_c_option_fno_strict_overflow], [-fno-strict-overflow])
b1c030b0 167fi
efd6d12b 168AC_MSG_CHECKING([CFLAGS])
b81a73d1 169AC_MSG_RESULT([$CFLAGS])
b1c030b0
OZ
170
171
416e3ee4
MM
172AC_PROG_CPP
173AC_PROG_INSTALL
174AC_PROG_RANLIB
b81a73d1
OZ
175AC_CHECK_PROG([FLEX], [flex], [flex])
176AC_CHECK_PROG([BISON], [bison], [bison])
177AC_CHECK_PROGS([M4], [gm4 m4])
8de11deb
OZ
178
179test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
180test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
181test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
b81a73d1
OZ
182
183BIRD_CHECK_PROG_FLAVOR_GNU([$M4],
184 [],
185 [AC_MSG_ERROR([Provided M4 is not GNU M4.])]
186)
416e3ee4 187
2f9bcf97 188if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
b81a73d1
OZ
189 if test -f $with_sysconfig ; then
190 sysdesc=$with_sysconfig
191 else
192 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
193 if ! test -f $sysdesc ; then
194 sysdesc=$sysdesc.h
195 fi
196 fi
2f9bcf97 197elif test -f sysconfig.h ; then
b81a73d1 198 sysdesc=sysconfig
2f9bcf97 199else
b81a73d1
OZ
200 case "$ip:$host_os" in
201 ipv6:linux*)
202 sysdesc=linux-v6
203 default_iproutedir="/etc/iproute2"
204 ;;
205 ipv4:linux*)
206 sysdesc=linux
207 default_iproutedir="/etc/iproute2"
208 ;;
209 ipv6:netbsd*)
210 sysdesc=bsd-v6
211 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
212 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
213 ;;
214 ipv4:netbsd*)
215 sysdesc=bsd
216 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
217 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
218 ;;
219 ipv6:freebsd*)
220 sysdesc=bsd-v6
3140c8b2
OZ
221 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
222 LDFLAGS="$LDFLAGS -L/usr/local/lib"
b81a73d1
OZ
223 ;;
224 ipv4:freebsd*)
225 sysdesc=bsd
3140c8b2
OZ
226 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
227 LDFLAGS="$LDFLAGS -L/usr/local/lib"
b81a73d1
OZ
228 ;;
229 ipv6:dragonfly*)
230 sysdesc=bsd-v6
231 ;;
232 ipv4:dragonfly*)
233 sysdesc=bsd
234 ;;
235 ipv6:kfreebsd*)
236 sysdesc=bsd-v6
237 ;;
238 ipv4:kfreebsd*)
239 sysdesc=bsd
240 ;;
241 ipv6:openbsd*)
242 sysdesc=bsd-v6
243 ;;
244 ipv4:openbsd*)
245 sysdesc=bsd
246 ;;
247 *)
248 AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
249 ;;
250 esac
251 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
2f9bcf97 252fi
416e3ee4 253AC_MSG_CHECKING([which OS configuration should we use])
b81a73d1 254AC_MSG_RESULT([$sysdesc])
49e7e5ee 255if ! test -f $sysdesc ; then
b81a73d1 256 AC_MSG_ERROR([The system configuration file is missing.])
2f9bcf97 257fi
49e7e5ee 258sysname=`echo $sysdesc | sed 's/\.h$//'`
7a855725 259AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include])
49e7e5ee
MM
260
261AC_MSG_CHECKING([system-dependent directories])
262sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
b81a73d1
OZ
263AC_MSG_RESULT([$sysdep_dirs])
264AC_SUBST([sysdep_dirs])
2f9bcf97 265
acc93efd
OZ
266if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
267
268if test -n "$given_iproutedir"
269then iproutedir=$with_iproutedir
270else iproutedir=$default_iproutedir
271fi
272
b81a73d1 273AC_SUBST([iproutedir])
acc93efd 274
c0fc3e67 275all_protocols="$proto_bfd bgp mrt ospf pipe $proto_radv rip static"
937e75d8
OZ
276if test "$ip" = ipv6 ; then
277 all_protocols="$all_protocols babel"
278fi
1ec52253
OZ
279all_protocols=`echo $all_protocols | sed 's/ /,/g'`
280
281if test "$with_protocols" = all ; then
b81a73d1 282 with_protocols="$all_protocols"
1ec52253
OZ
283fi
284
7a855725
OZ
285AH_TEMPLATE([CONFIG_BABEL], [Babel protocol])
286AH_TEMPLATE([CONFIG_BFD], [BFD protocol])
287AH_TEMPLATE([CONFIG_BGP], [BGP protocol])
c0fc3e67 288AH_TEMPLATE([CONFIG_MRT], [MRT protocol])
7a855725
OZ
289AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol])
290AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol])
291AH_TEMPLATE([CONFIG_RADV], [RAdv protocol])
292AH_TEMPLATE([CONFIG_RIP], [RIP protocol])
293AH_TEMPLATE([CONFIG_STATIC], [Static protocol])
294
2f9bcf97
MM
295AC_MSG_CHECKING([protocols])
296protocols=`echo "$with_protocols" | sed 's/,/ /g'`
b296730c 297if test "$protocols" = no ; then protocols= ; fi
2f9bcf97 298for a in $protocols ; do
b81a73d1
OZ
299 if ! test -f $srcdir/proto/$a/Makefile ; then
300 AC_MSG_RESULT([failed])
301 AC_MSG_ERROR([Requested protocol $a not found])
302 fi
303 AC_DEFINE_UNQUOTED([CONFIG_`echo $a | tr 'a-z' 'A-Z'`])
304done
305AC_MSG_RESULT([ok])
306AC_SUBST([protocols])
2f9bcf97 307
a07e9d82 308case $sysdesc in
b81a73d1
OZ
309 */linux*|*/linux-v6*)
310 AC_CHECK_HEADER([linux/rtnetlink.h],
311 [],
312 [AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],
81edd3b3
OZ
313 [
314 dnl Some older versions of Linux kernel headers require these includes
315 #include <asm/types.h>
316 #include <sys/socket.h>
317 ]
b81a73d1
OZ
318 )
319 ;;
a07e9d82
MM
320esac
321
c253ec3a 322AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
e40542ef 323AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
7a855725
OZ
324
325AC_C_BIGENDIAN(
326 [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
327 [AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
328 [AC_MSG_ERROR([Cannot determine CPU endianity.])]
329)
e6ff7a08 330
1e921ec8
MM
331BIRD_CHECK_ANDROID_GLOB
332if test "$bird_cv_lib_glob" = no ; then
333 AC_MSG_ERROR([glob.h not found.])
334elif test "$bird_cv_lib_glob" != yes ; then
335 LIBS="$LIBS $bird_cv_lib_glob"
336fi
337
338BIRD_CHECK_ANDROID_LOG
339if test "$bird_cv_lib_log" = no ; then
340 AC_MSG_ERROR([don't know how to link syslog.])
341elif test "$bird_cv_lib_log" != yes ; then
342 LIBS="$LIBS $bird_cv_lib_log"
343fi
344
2f9bcf97 345if test "$enable_debug" = yes ; then
b81a73d1
OZ
346 AC_DEFINE([DEBUGGING], [1], [Define to 1 if debugging is enabled])
347 if test "$enable_memcheck" = yes ; then
348 AC_CHECK_LIB([dmalloc], [dmalloc_debug])
349 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
350 AC_CHECK_LIB([efence], [malloc])
351 fi
352 fi
2f9bcf97
MM
353fi
354
7211be1c
MM
355CLIENT=
356CLIENT_LIBS=
9fac310d 357if test "$enable_client" = yes ; then
b81a73d1 358 CLIENT=birdc
a01e951d
OZ
359 BASE_LIBS="$LIBS"
360 LIBS=""
361
362 AC_CHECK_HEADERS([curses.h],
363 [],
364 [AC_MSG_ERROR([The client requires ncurses library. Either install the library or use --disable-client to compile without the client.])],
81edd3b3 365 [AC_INCLUDES_DEFAULT]
b81a73d1
OZ
366 )
367
a01e951d
OZ
368 AC_SEARCH_LIBS([tgetent], [tinfo tinfow ncurses curses termcap],
369 [TINFO_LIBS="$LIBS"; LIBS=""],
370 [AC_MSG_ERROR([The client requires ncurses library. Either install the library or use --disable-client to compile without the client.])],
371 )
372
373 AC_CHECK_HEADERS([readline/readline.h readline/history.h],
374 [],
375 [AC_MSG_ERROR([The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client.])],
81edd3b3 376 [AC_INCLUDES_DEFAULT]
a01e951d
OZ
377 )
378
a01e951d
OZ
379 AC_SEARCH_LIBS([rl_callback_read_char], [readline],
380 [READLINE_LIBS="$LIBS"; LIBS=""],
381 [AC_MSG_ERROR([The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client.])],
382 [$TINFO_LIBS]
b81a73d1
OZ
383 )
384
385 AC_CHECK_LIB([readline], [rl_crlf],
386 [AC_DEFINE([HAVE_RL_CRLF], [1], [Define to 1 if you have rl_crlf()])],
387 [],
a01e951d 388 [$TINFO_LIBS]
b81a73d1
OZ
389 )
390
391 AC_CHECK_LIB([readline], [rl_ding],
392 [AC_DEFINE([HAVE_RL_DING], [1], [Define to 1 if you have rl_ding()])],
393 [],
a01e951d 394 [$TINFO_LIBS]
b81a73d1 395 )
a01e951d
OZ
396
397 LIBS="$BASE_LIBS"
cce6ba4d 398 CLIENT_LIBS="$READLINE_LIBS $TINFO_LIBS"
9fac310d 399fi
b81a73d1
OZ
400AC_SUBST([CLIENT])
401AC_SUBST([CLIENT_LIBS])
9fac310d 402
54165b13 403mkdir -p $objdir/sysdep
7cb37e6f 404AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
b81a73d1 405AC_CONFIG_COMMANDS([merge],
1e921ec8 406 [ export CPP="$CPP"; sh $srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs ],
b81a73d1
OZ
407 [
408 srcdir=$srcdir
409 srcdir_rel=$srcdir_rel
410 objdir=$objdir
411 sysdep_dirs="$sysdep_dirs"
412 ]
413)
414AC_CONFIG_FILES([$makefiles])
22122d4d 415AC_OUTPUT
2f9bcf97 416
acc93efd
OZ
417rm -f $objdir/sysdep/paths.h
418
7a855725
OZ
419AC_MSG_RESULT()
420AC_MSG_RESULT([BIRD was configured with the following options:])
421AC_MSG_RESULT([ Source directory: $srcdir])
422AC_MSG_RESULT([ Object directory: $objdir])
423AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
424AC_MSG_RESULT([ System configuration: $sysdesc])
425AC_MSG_RESULT([ Debugging: $enable_debug])
426AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
427AC_MSG_RESULT([ Routing protocols: $protocols])
428AC_MSG_RESULT([ Client: $enable_client])
3140c8b2
OZ
429
430rm -f $objdir/.*-stamp