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