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