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(debug, [ --enable-debug enable internal debugging routines (default: disabled)],,enable_debug=no)
10 AC_ARG_ENABLE(memcheck, [ --enable-memcheck check memory allocations when debugging (default: enabled)],,enable_memcheck=yes)
11 AC_ARG_ENABLE(client, [ --enable-client enable building of BIRD client (default: enabled)],,enable_client=yes)
12 AC_ARG_ENABLE(ipv6, [ --enable-ipv6 enable building of IPv6 version (default: disabled)],,enable_ipv6=no)
13 AC_ARG_ENABLE(pthreads, [ --enable-pthreads enable POSIX threads support (default: detect)],,enable_pthreads=try)
14 AC_ARG_WITH(suffix, [ --with-suffix=STRING use specified suffix for BIRD files (default: 6 for IPv6 version)],[given_suffix="yes"])
15 AC_ARG_WITH(sysconfig, [ --with-sysconfig=FILE use specified BIRD system configuration file])
16 AC_ARG_WITH(protocols, [ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"])
17 AC_ARG_WITH(sysinclude, [ --with-sysinclude=PATH search for system includes on specified place])
18 AC_ARG_WITH(runtimedir, [ --with-runtimedir=PATH path for runtime files (default: $(localstatedir)/run)],[runtimedir="$with_runtimedir"],[runtimedir="\$(localstatedir)/run"])
19 AC_ARG_WITH(iproutedir, [ --with-iproutedir=PATH path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"])
20 AC_ARG_VAR([FLEX], [location of the Flex program])
21 AC_ARG_VAR([BISON], [location of the Bison program])
22 AC_ARG_VAR([M4], [location of the M4 program])
25 if test "$srcdir" = . ; then
26 # Building in current directory => create obj directory holding all objects
30 makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
33 # Building in separate directory
36 makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
40 /*) srcdir_rel_mf=$srcdir_rel ;;
41 *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
45 AC_SUBST(srcdir_rel_mf)
48 if test "$enable_ipv6" = yes ; then
57 if test "$given_suffix" = yes ; then
62 if test "$enable_debug" = yes ; then
63 CONFIG_FILE="bird$SUFFIX.conf"
64 CONTROL_SOCKET="bird$SUFFIX.ctl"
66 CONFIG_FILE="\$(sysconfdir)/bird$SUFFIX.conf"
67 CONTROL_SOCKET="$runtimedir/bird$SUFFIX.ctl"
70 AC_SUBST(CONTROL_SOCKET)
72 AC_SEARCH_LIBS(clock_gettime, [rt posix4], ,
73 AC_MSG_ERROR([[Function clock_gettime not available.]]))
77 # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
78 if test "$ac_test_CFLAGS" != set ; then
79 bird_cflags_default=yes
83 if test -z "$GCC" ; then
84 AC_MSG_ERROR([This program requires the GNU C Compiler.])
87 if test "$enable_pthreads" != no ; then
90 if test "$bird_cv_lib_pthreads" = yes ; then
91 AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled])
92 CFLAGS="$CFLAGS -pthread"
93 LDFLAGS="$LDFLAGS -pthread"
95 elif test "$enable_pthreads" = yes ; then
96 AC_MSG_ERROR([POSIX threads not available.])
99 if test "$enable_pthreads" = try ; then
100 enable_pthreads="$bird_cv_lib_pthreads"
104 if test "$bird_cflags_default" = yes ; then
105 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
106 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
107 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
108 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
110 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
111 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
112 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
113 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
114 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
116 AC_MSG_CHECKING([CFLAGS])
117 AC_MSG_RESULT($CFLAGS)
123 AC_CHECK_PROG(FLEX, flex, flex)
124 AC_CHECK_PROG(BISON, bison, bison)
125 AC_CHECK_PROGS(M4, gm4 m4)
127 test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
128 test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
129 test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
130 BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])])
132 if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
133 if test -f $with_sysconfig ; then
134 sysdesc=$with_sysconfig
136 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
137 if ! test -f $sysdesc ; then
141 elif test -f sysconfig.h ; then
144 case "$ip:$host_os" in
145 ipv6:linux*) sysdesc=linux-v6
146 default_iproutedir="/etc/iproute2"
148 ipv4:linux*) sysdesc=linux
149 default_iproutedir="/etc/iproute2"
151 ipv6:netbsd*) sysdesc=bsd-v6
152 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
153 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
155 ipv4:netbsd*) sysdesc=bsd
156 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
157 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
159 ipv6:freebsd*) sysdesc=bsd-v6
161 ipv4:freebsd*) sysdesc=bsd
163 ipv6:dragonfly*) sysdesc=bsd-v6
165 ipv4:dragonfly*) sysdesc=bsd
167 ipv6:kfreebsd*) sysdesc=bsd-v6
169 ipv4:kfreebsd*) sysdesc=bsd
171 ipv6:openbsd*) sysdesc=bsd-v6
173 ipv4:openbsd*) sysdesc=bsd
175 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
178 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
180 AC_MSG_CHECKING([which OS configuration should we use])
181 AC_MSG_RESULT($sysdesc)
182 if ! test -f $sysdesc ; then
183 AC_MSG_ERROR([The system configuration file is missing.])
185 sysname=`echo $sysdesc | sed 's/\.h$//'`
186 AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include])
188 AC_MSG_CHECKING([system-dependent directories])
189 sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
190 AC_MSG_RESULT($sysdep_dirs)
191 AC_SUBST(sysdep_dirs)
193 if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
195 if test -n "$given_iproutedir"
196 then iproutedir=$with_iproutedir
197 else iproutedir=$default_iproutedir
202 all_protocols="$proto_bfd bgp ospf pipe $proto_radv rip static"
203 if test "$ip" = ipv6 ; then
204 all_protocols="$all_protocols babel"
206 all_protocols=`echo $all_protocols | sed 's/ /,/g'`
208 if test "$with_protocols" = all ; then
209 with_protocols="$all_protocols"
212 AH_TEMPLATE([CONFIG_BABEL], [Babel protocol])
213 AH_TEMPLATE([CONFIG_BFD], [BFD protocol])
214 AH_TEMPLATE([CONFIG_BGP], [BGP protocol])
215 AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol])
216 AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol])
217 AH_TEMPLATE([CONFIG_RADV], [RAdv protocol])
218 AH_TEMPLATE([CONFIG_RIP], [RIP protocol])
219 AH_TEMPLATE([CONFIG_STATIC], [Static protocol])
221 AC_MSG_CHECKING([protocols])
222 protocols=`echo "$with_protocols" | sed 's/,/ /g'`
223 if test "$protocols" = no ; then protocols= ; fi
224 for a in $protocols ; do
225 if ! test -f $srcdir/proto/$a/Makefile ; then
226 AC_MSG_RESULT(failed)
227 AC_MSG_ERROR([Requested protocol $a not found.])
229 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
235 */linux*|*/linux-v6*)
236 AC_CHECK_HEADER(linux/rtnetlink.h,,[AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],[
237 #include <asm/types.h>
238 #include <sys/socket.h>
243 AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
244 AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
247 [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
248 [AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
249 [AC_MSG_ERROR([Cannot determine CPU endianity.])]
252 BIRD_CHECK_STRUCT_ALIGN
255 if test "$enable_debug" = yes ; then
256 AC_DEFINE([DEBUGGING], [1], [Define to 1 if debugging is enabled])
257 if test "$enable_memcheck" = yes ; then
258 AC_CHECK_LIB(dmalloc, dmalloc_debug)
259 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
260 AC_CHECK_LIB(efence, malloc)
267 if test "$enable_client" = yes ; then
269 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
270 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
271 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
272 AC_CHECK_LIB(tinfow, tgetent, USE_TERMCAP_LIB=-ltinfow,
273 AC_CHECK_LIB(tinfo, tgetent, USE_TERMCAP_LIB=-ltinfo,
274 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap,
275 AC_MSG_ERROR([[The client requires ncurses library. Either install the library or use --disable-client to compile without the client.]]))))))
276 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
277 AC_MSG_ERROR([[The client requires GNU readline library 2.1 or newer. Either install the library or use --disable-client to compile without the client.]]), $USE_TERMCAP_LIB)
278 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE([HAVE_RL_CRLF], [1], [Define to 1 if you have rl_crlf()]),,$USE_TERMCAP_LIB)
279 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE([HAVE_RL_DING], [1], [Define to 1 if you have rl_ding()]),,$USE_TERMCAP_LIB)
282 AC_SUBST(CLIENT_LIBS)
284 mkdir -p $objdir/sysdep
285 AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
286 AC_CONFIG_COMMANDS([merge],[[export CPP="$CPP"
287 $srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs]],
289 [srcdir_rel=$srcdir_rel]
291 [sysdep_dirs="$sysdep_dirs"]])
292 AC_CONFIG_FILES($makefiles)
295 rm -f $objdir/sysdep/paths.h
298 AC_MSG_RESULT([BIRD was configured with the following options:])
299 AC_MSG_RESULT([ Source directory: $srcdir])
300 AC_MSG_RESULT([ Object directory: $objdir])
301 AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
302 AC_MSG_RESULT([ System configuration: $sysdesc])
303 AC_MSG_RESULT([ Debugging: $enable_debug])
304 AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
305 AC_MSG_RESULT([ Routing protocols: $protocols])
306 AC_MSG_RESULT([ Client: $enable_client])
307 rm -f $objdir/.*-stamp