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_INIT(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(pthreads, [ --enable-pthreads enable POSIX threads support (default: detect)],,enable_pthreads=try)
13 AC_ARG_WITH(sysconfig, [ --with-sysconfig=FILE use specified BIRD system configuration file])
14 AC_ARG_WITH(protocols, [ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"])
15 AC_ARG_WITH(sysinclude, [ --with-sysinclude=PATH search for system includes on specified place])
16 AC_ARG_WITH(runtimedir, [ --with-runtimedir=PATH path for runtime files (default: $(localstatedir)/run)],[runtimedir="$with_runtimedir"],[runtimedir="\$(localstatedir)/run"])
17 AC_ARG_WITH(iproutedir, [ --with-iproutedir=PATH path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"])
18 AC_ARG_VAR([FLEX], [location of the Flex program])
19 AC_ARG_VAR([BISON], [location of the Bison program])
20 AC_ARG_VAR([M4], [location of the M4 program])
23 if test "$srcdir" = . ; then
24 # Building in current directory => create obj directory holding all objects
27 # Building in separate directory
39 if test "$enable_debug" = yes ; then
40 CONFIG_FILE="bird.conf"
41 CONTROL_SOCKET="bird.ctl"
43 CONFIG_FILE="\$(sysconfdir)/bird.conf"
44 CONTROL_SOCKET="$runtimedir/bird.ctl"
47 AC_SUBST(CONTROL_SOCKET)
49 AC_SEARCH_LIBS(clock_gettime, [c rt posix4], ,
50 AC_MSG_ERROR([[Function clock_gettime not available.]]))
54 # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
55 if test "$ac_test_CFLAGS" != set ; then
56 bird_cflags_default=yes
60 if test -z "$GCC" ; then
61 AC_MSG_ERROR([This program requires the GNU C Compiler.])
64 # Enable threads by default just in Linux and FreeBSD
65 #if test "$enable_pthreads" = try ; then
67 # (linux* | freebsd* | openbsd* | netbsd* ) enable_pthreads=try ;;
68 # (*) enable_pthreads=no ;;
72 if test "$enable_pthreads" != no ; then
75 if test "$bird_cv_lib_pthreads" = yes ; then
76 AC_DEFINE(USE_PTHREADS)
77 CFLAGS="$CFLAGS -pthread"
78 LDFLAGS="$LDFLAGS -pthread"
80 elif test "$enable_pthreads" = yes ; then
81 AC_MSG_ERROR([POSIX threads not available.])
84 if test "$enable_pthreads" = try ; then
85 enable_pthreads="$bird_cv_lib_pthreads"
89 if test "$bird_cflags_default" = yes ; then
90 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
91 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
92 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
93 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
95 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
96 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
97 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
98 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
99 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
101 AC_MSG_CHECKING([CFLAGS])
102 AC_MSG_RESULT($CFLAGS)
108 AC_CHECK_PROG(FLEX, flex, flex)
109 AC_CHECK_PROG(BISON, bison, bison)
110 AC_CHECK_PROGS(M4, gm4 m4)
112 test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
113 test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
114 test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
115 BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])])
117 if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
118 if test -f $with_sysconfig ; then
119 sysdesc=$with_sysconfig
121 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
122 if ! test -f $sysdesc ; then
126 elif test -f sysconfig.h ; then
130 linux*) sysdesc=linux
131 default_iproutedir="/etc/iproute2"
133 freebsd*) sysdesc=bsd
135 kfreebsd*) sysdesc=bsd
138 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
139 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
141 openbsd*) sysdesc=bsd
143 dragonfly*) sysdesc=bsd
145 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
148 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
150 AC_MSG_CHECKING([which OS configuration should we use])
151 AC_MSG_RESULT($sysdesc)
152 if ! test -f $sysdesc ; then
153 AC_MSG_ERROR([The system configuration file is missing.])
155 sysname=`echo $sysdesc | sed 's/\.h$//'`
156 AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
158 AC_MSG_CHECKING([system-dependent directories])
159 sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`"
160 AC_MSG_RESULT($sysdep_dirs)
161 AC_SUBST(sysdep_dirs)
163 if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
165 if test -n "$given_iproutedir"
166 then iproutedir=$with_iproutedir
167 else iproutedir=$default_iproutedir
172 # all_protocols="$proto_bfd babel bgp ospf pipe radv rip static"
173 all_protocols="$proto_bfd ospf pipe radv rip static"
175 all_protocols=`echo $all_protocols | sed 's/ /,/g'`
177 if test "$with_protocols" = all ; then
178 with_protocols="$all_protocols"
181 AC_MSG_CHECKING([protocols])
182 protocols=`echo "$with_protocols" | sed 's/,/ /g'`
183 if test "$protocols" = no ; then protocols= ; fi
184 for a in $protocols ; do
185 if ! test -f $srcdir/proto/$a/Makefile ; then
186 AC_MSG_RESULT(failed)
187 AC_MSG_ERROR([Requested protocol $a not found.])
189 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
196 AC_CHECK_HEADER(linux/rtnetlink.h,,[AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],[
197 #include <asm/types.h>
198 #include <sys/socket.h>
203 AC_CHECK_HEADER(syslog.h, [AC_DEFINE(HAVE_SYSLOG)])
204 AC_CHECK_HEADER(alloca.h, [AC_DEFINE(HAVE_ALLOCA_H)])
205 AC_MSG_CHECKING(whether 'struct sockaddr' has sa_len)
206 AC_TRY_COMPILE([#include <sys/types.h>
207 #include <sys/socket.h>
208 ], [static struct sockaddr sa; int i = sizeof(sa.sa_len);],
210 AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
213 AC_C_BIGENDIAN([AC_DEFINE(CPU_BIG_ENDIAN)], [AC_DEFINE(CPU_LITTLE_ENDIAN)],
214 [AC_MSG_ERROR([Cannot determine CPU endianity.])])
217 BIRD_CHECK_STRUCT_ALIGN
219 BIRD_CHECK_STRUCT_IP_MREQN
221 if test "$enable_debug" = yes ; then
223 AC_CHECK_HEADER(execinfo.h, [AC_SEARCH_LIBS([backtrace, backtrace_symbols], [c execinfo], [AC_DEFINE(HAVE_EXECINFO_H)])])
224 LDFLAGS="$LDFLAGS -rdynamic"
225 CFLAGS="$CFLAGS -O0 -ggdb -g3 -gdwarf-4"
226 if test "$enable_memcheck" = yes ; then
227 AC_CHECK_LIB(dmalloc, dmalloc_debug)
228 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
229 AC_CHECK_LIB(efence, malloc)
236 if test "$enable_client" = yes ; then
237 CLIENT="$CLIENT birdc"
238 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
239 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
240 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
241 AC_CHECK_LIB(tinfow, tgetent, USE_TERMCAP_LIB=-ltinfow,
242 AC_CHECK_LIB(tinfo, tgetent, USE_TERMCAP_LIB=-ltinfo,
243 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap,
244 AC_MSG_ERROR([[The client requires ncurses library. Either install the library or use --disable-client to compile without the client.]]))))))
245 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
246 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)
247 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE(HAVE_RL_CRLF),,$USE_TERMCAP_LIB)
248 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE(HAVE_RL_DING),,$USE_TERMCAP_LIB)
251 AC_SUBST(CLIENT_LIBS)
253 mkdir -p $objdir/sysdep
254 AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
255 AC_CONFIG_FILES(Makefile:Makefile.in)
258 cat >&AC_FD_MSG <<EOF
260 BIRD was configured with the following options:
261 Source directory: $srcdir
262 Object directory: $objdir
263 Iproute2 directory: $iproutedir
264 System configuration: $sysdesc
265 Debugging: $enable_debug
266 POSIX threads: $enable_pthreads
267 Routing protocols: $protocols
268 Client: $enable_client
270 rm -f $objdir/.*-stamp