1 dnl ** This is a configure script template for BIRD
2 dnl ** Process it with autoconf to get ./configure
3 dnl ** (c) 1999--2000 Martin Mares <mj@ucw.cz>
6 AC_CONFIG_SRCDIR([conf/confbase.Y])
7 AC_CONFIG_AUX_DIR([tools])
9 AC_ARG_ENABLE([client],
10 [AS_HELP_STRING([--enable-client], [enable building of BIRD client @<:@yes@:>@])],
15 AC_ARG_ENABLE([debug],
16 [AS_HELP_STRING([--enable-debug], [enable internal debugging routines @<:@no@:>@])],
22 [AS_HELP_STRING([--enable-ipv6], [enable building of IPv6 version @<:@no@:>@])],
27 AC_ARG_ENABLE([memcheck],
28 [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])],
33 AC_ARG_ENABLE([pthreads],
34 [AS_HELP_STRING([--enable-pthreads], [enable POSIX threads support @<:@try@:>@])],
39 AC_ARG_WITH([protocols],
40 [AS_HELP_STRING([--with-protocols=LIST], [include specified routing protocols @<:@all@:>@])],
42 [with_protocols="all"]
46 [AS_HELP_STRING([--with-suffix=STRING], [use specified suffix for BIRD files @<:@6 for IPv6@:>@])],
50 AC_ARG_WITH([sysconfig],
51 [AS_HELP_STRING([--with-sysconfig=FILE], [use specified BIRD system configuration file])],
55 AC_ARG_WITH([runtimedir],
56 [AS_HELP_STRING([--with-runtimedir=PATH], [path for runtime files @<:@LOCALSTATEDIR/run@:>@])],
57 [runtimedir="$with_runtimedir"],
58 [runtimedir="\$(localstatedir)/run"]
61 AC_ARG_WITH([iproutedir],
62 [AS_HELP_STRING([--with-iproutedir=PATH], [path to iproute2 config files @<:@/etc/iproute2@:>@])],
63 [given_iproutedir="yes"]
66 AC_ARG_VAR([FLEX], [location of the Flex program])
67 AC_ARG_VAR([BISON], [location of the Bison program])
68 AC_ARG_VAR([M4], [location of the M4 program])
71 if test "$srcdir" = . ; then
72 # Building in current directory => create obj directory holding all objects
76 makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
79 # Building in separate directory
82 makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
87 /*) srcdir_rel_mf=$srcdir_rel ;;
88 *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
93 AC_SUBST([srcdir_rel_mf])
94 AC_SUBST([runtimedir])
96 if test "$enable_ipv6" = yes ; then
105 if test "$given_suffix" = yes ; then
106 SUFFIX="$with_suffix"
110 if test "$enable_debug" = yes ; then
111 CONFIG_FILE="bird$SUFFIX.conf"
112 CONTROL_SOCKET="bird$SUFFIX.ctl"
114 CONFIG_FILE="\$(sysconfdir)/bird$SUFFIX.conf"
115 CONTROL_SOCKET="$runtimedir/bird$SUFFIX.ctl"
117 AC_SUBST([CONFIG_FILE])
118 AC_SUBST([CONTROL_SOCKET])
120 AC_SEARCH_LIBS([clock_gettime], [rt posix4],
122 [AC_MSG_ERROR([Function clock_gettime not available.])]
127 # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
128 if test "$ac_test_CFLAGS" != set ; then
129 bird_cflags_default=yes
133 if test -z "$GCC" ; then
134 AC_MSG_ERROR([This program requires the GNU C Compiler.])
137 if test "$enable_pthreads" != no ; then
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"
145 elif test "$enable_pthreads" = yes ; then
146 AC_MSG_ERROR([POSIX threads not available.])
149 if test "$enable_pthreads" = try ; then
150 enable_pthreads="$bird_cv_lib_pthreads"
154 if test "$bird_cflags_default" = yes ; then
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])
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])
166 AC_MSG_CHECKING([CFLAGS])
167 AC_MSG_RESULT([$CFLAGS])
173 AC_CHECK_PROG([FLEX], [flex], [flex])
174 AC_CHECK_PROG([BISON], [bison], [bison])
175 AC_CHECK_PROGS([M4], [gm4 m4])
177 test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
178 test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
179 test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
181 BIRD_CHECK_PROG_FLAVOR_GNU([$M4],
183 [AC_MSG_ERROR([Provided M4 is not GNU M4.])]
186 if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
187 if test -f $with_sysconfig ; then
188 sysdesc=$with_sysconfig
190 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
191 if ! test -f $sysdesc ; then
195 elif test -f sysconfig.h ; then
198 case "$ip:$host_os" in
201 default_iproutedir="/etc/iproute2"
205 default_iproutedir="/etc/iproute2"
209 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
210 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
214 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
215 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
219 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
220 LDFLAGS="$LDFLAGS -L/usr/local/lib"
224 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
225 LDFLAGS="$LDFLAGS -L/usr/local/lib"
246 AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
249 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
251 AC_MSG_CHECKING([which OS configuration should we use])
252 AC_MSG_RESULT([$sysdesc])
253 if ! test -f $sysdesc ; then
254 AC_MSG_ERROR([The system configuration file is missing.])
256 sysname=`echo $sysdesc | sed 's/\.h$//'`
257 AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include])
259 AC_MSG_CHECKING([system-dependent directories])
260 sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
261 AC_MSG_RESULT([$sysdep_dirs])
262 AC_SUBST([sysdep_dirs])
264 if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
266 if test -n "$given_iproutedir"
267 then iproutedir=$with_iproutedir
268 else iproutedir=$default_iproutedir
271 AC_SUBST([iproutedir])
273 all_protocols="$proto_bfd bgp mrt ospf pipe $proto_radv rip static"
274 if test "$ip" = ipv6 ; then
275 all_protocols="$all_protocols babel"
277 all_protocols=`echo $all_protocols | sed 's/ /,/g'`
279 if test "$with_protocols" = all ; then
280 with_protocols="$all_protocols"
283 AH_TEMPLATE([CONFIG_BABEL], [Babel protocol])
284 AH_TEMPLATE([CONFIG_BFD], [BFD protocol])
285 AH_TEMPLATE([CONFIG_BGP], [BGP protocol])
286 AH_TEMPLATE([CONFIG_MRT], [MRT protocol])
287 AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol])
288 AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol])
289 AH_TEMPLATE([CONFIG_RADV], [RAdv protocol])
290 AH_TEMPLATE([CONFIG_RIP], [RIP protocol])
291 AH_TEMPLATE([CONFIG_STATIC], [Static protocol])
293 AC_MSG_CHECKING([protocols])
294 protocols=`echo "$with_protocols" | sed 's/,/ /g'`
295 if test "$protocols" = no ; then protocols= ; fi
296 for a in $protocols ; do
297 if ! test -f $srcdir/proto/$a/Makefile ; then
298 AC_MSG_RESULT([failed])
299 AC_MSG_ERROR([Requested protocol $a not found])
301 AC_DEFINE_UNQUOTED([CONFIG_`echo $a | tr 'a-z' 'A-Z'`])
304 AC_SUBST([protocols])
307 */linux*|*/linux-v6*)
308 AC_CHECK_HEADER([linux/rtnetlink.h],
310 [AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],
312 dnl Some older versions of Linux kernel headers require these includes
313 #include <asm/types.h>
314 #include <sys/socket.h>
320 AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
321 AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
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.])]
329 BIRD_CHECK_ANDROID_GLOB
330 if test "$bird_cv_lib_glob" = no ; then
331 AC_MSG_ERROR([glob.h not found.])
332 elif test "$bird_cv_lib_glob" != yes ; then
333 LIBS="$LIBS $bird_cv_lib_glob"
336 BIRD_CHECK_ANDROID_LOG
337 if test "$bird_cv_lib_log" = no ; then
338 AC_MSG_ERROR([don't know how to link syslog.])
339 elif test "$bird_cv_lib_log" != yes ; then
340 LIBS="$LIBS $bird_cv_lib_log"
343 if test "$enable_debug" = yes ; then
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])
355 if test "$enable_client" = yes ; then
360 AC_CHECK_HEADERS([curses.h],
362 [AC_MSG_ERROR([The client requires ncurses library. Either install the library or use --disable-client to compile without the client.])],
363 [AC_INCLUDES_DEFAULT]
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.])],
371 AC_CHECK_HEADERS([readline/readline.h readline/history.h],
373 [AC_MSG_ERROR([The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client.])],
374 [AC_INCLUDES_DEFAULT]
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.])],
383 AC_CHECK_LIB([readline], [rl_crlf],
384 [AC_DEFINE([HAVE_RL_CRLF], [1], [Define to 1 if you have rl_crlf()])],
389 AC_CHECK_LIB([readline], [rl_ding],
390 [AC_DEFINE([HAVE_RL_DING], [1], [Define to 1 if you have rl_ding()])],
396 CLIENT_LIBS="$READLINE_LIBS $TINFO_LIBS"
399 AC_SUBST([CLIENT_LIBS])
401 mkdir -p $objdir/sysdep
402 AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
403 AC_CONFIG_COMMANDS([merge],
404 [ export CPP="$CPP"; sh $srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs ],
407 srcdir_rel=$srcdir_rel
409 sysdep_dirs="$sysdep_dirs"
412 AC_CONFIG_FILES([$makefiles])
415 rm -f $objdir/sysdep/paths.h
418 AC_MSG_RESULT([BIRD was configured with the following options:])
419 AC_MSG_RESULT([ Source directory: $srcdir])
420 AC_MSG_RESULT([ Object directory: $objdir])
421 AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
422 AC_MSG_RESULT([ System configuration: $sysdesc])
423 AC_MSG_RESULT([ Debugging: $enable_debug])
424 AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
425 AC_MSG_RESULT([ Routing protocols: $protocols])
426 AC_MSG_RESULT([ Client: $enable_client])
428 rm -f $objdir/.*-stamp