]> git.ipfire.org Git - thirdparty/bird.git/blame - configure.ac
Merge branch 'master' into int-new
[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])
2f9bcf97
MM
7AC_CONFIG_AUX_DIR(tools)
8
ab188fb7
OZ
9AC_ARG_ENABLE(debug, [ --enable-debug enable internal debugging routines (default: disabled)],,enable_debug=no)
10AC_ARG_ENABLE(memcheck, [ --enable-memcheck check memory allocations when debugging (default: enabled)],,enable_memcheck=yes)
11AC_ARG_ENABLE(client, [ --enable-client enable building of BIRD client (default: enabled)],,enable_client=yes)
1ec52253 12AC_ARG_ENABLE(pthreads, [ --enable-pthreads enable POSIX threads support (default: detect)],,enable_pthreads=try)
af62c0f9 13AC_ARG_ENABLE(libssh, [ --enable-libssh enable LibSSH support together with RPKI protocol (default: detect)],,enable_libssh=try)
ab188fb7
OZ
14AC_ARG_WITH(sysconfig, [ --with-sysconfig=FILE use specified BIRD system configuration file])
15AC_ARG_WITH(protocols, [ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"])
16AC_ARG_WITH(sysinclude, [ --with-sysinclude=PATH search for system includes on specified place])
17AC_ARG_WITH(runtimedir, [ --with-runtimedir=PATH path for runtime files (default: $(localstatedir)/run)],[runtimedir="$with_runtimedir"],[runtimedir="\$(localstatedir)/run"])
18AC_ARG_WITH(iproutedir, [ --with-iproutedir=PATH path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"])
19AC_ARG_VAR([FLEX], [location of the Flex program])
20AC_ARG_VAR([BISON], [location of the Bison program])
21AC_ARG_VAR([M4], [location of the M4 program])
22
2f9bcf97 23
49e7e5ee
MM
24if test "$srcdir" = . ; then
25 # Building in current directory => create obj directory holding all objects
26 objdir=obj
49e7e5ee
MM
27else
28 # Building in separate directory
29 objdir=.
49e7e5ee 30fi
7152e5ef
JMM
31
32exedir=.
33
49e7e5ee
MM
34AC_SUBST(objdir)
35AC_SUBST(exedir)
7152e5ef 36AC_SUBST(srcdir)
ab188fb7 37AC_SUBST(runtimedir)
49e7e5ee 38
ab188fb7 39
ab188fb7 40if test "$enable_debug" = yes ; then
d549b83f
OZ
41 CONFIG_FILE="bird.conf"
42 CONTROL_SOCKET="bird.ctl"
ab188fb7 43else
d549b83f
OZ
44 CONFIG_FILE="\$(sysconfdir)/bird.conf"
45 CONTROL_SOCKET="$runtimedir/bird.ctl"
ab188fb7
OZ
46fi
47AC_SUBST(CONFIG_FILE)
48AC_SUBST(CONTROL_SOCKET)
49
5d6dc930 50AC_SEARCH_LIBS(clock_gettime, [rt posix4], ,
d7765408 51 AC_MSG_ERROR([[Function clock_gettime not available.]]))
fd91ae33 52
2f9bcf97 53AC_CANONICAL_HOST
416e3ee4 54
b1c030b0 55# Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
416e3ee4 56if test "$ac_test_CFLAGS" != set ; then
b1c030b0 57 bird_cflags_default=yes
416e3ee4 58fi
416e3ee4 59
4e276a89 60AC_PROG_CC
9b0a0ba9 61AC_PROG_CC_C99
e81b440f
OZ
62if test -z "$GCC" ; then
63 AC_MSG_ERROR([This program requires the GNU C Compiler.])
64fi
65
1ec52253
OZ
66if test "$enable_pthreads" != no ; then
67 BIRD_CHECK_PTHREADS
68
69 if test "$bird_cv_lib_pthreads" = yes ; then
7a855725 70 AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled])
1ec52253
OZ
71 CFLAGS="$CFLAGS -pthread"
72 LDFLAGS="$LDFLAGS -pthread"
73 proto_bfd=bfd
74 elif test "$enable_pthreads" = yes ; then
75 AC_MSG_ERROR([POSIX threads not available.])
76 fi
77
78 if test "$enable_pthreads" = try ; then
79 enable_pthreads="$bird_cv_lib_pthreads"
80 fi
81fi
82
af62c0f9
JMM
83if test "$enable_libssh" != no ; then
84 AC_CHECK_LIB(ssh, ssh_connect)
85 if test $ac_cv_lib_ssh_ssh_connect = yes ; then
86 proto_rpki=rpki
87 enable_libssh=yes
af62c0f9
JMM
88 else
89 if test "$enable_libssh" = yes ; then
90 AC_MSG_ERROR([LibSSH not available.])
91 else
92 enable_libssh=no
93 fi
94 fi
95fi
96
bed41728 97if test "$bird_cflags_default" = yes ; then
efd6d12b 98 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
3e236955 99 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
efd6d12b
OZ
100 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
101 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
b1c030b0 102
3e236955 103 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
efd6d12b 104 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
3e236955 105 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
efd6d12b
OZ
106 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
107 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
b1c030b0 108fi
efd6d12b 109AC_MSG_CHECKING([CFLAGS])
b1c030b0
OZ
110AC_MSG_RESULT($CFLAGS)
111
112
416e3ee4
MM
113AC_PROG_CPP
114AC_PROG_INSTALL
115AC_PROG_RANLIB
116AC_CHECK_PROG(FLEX, flex, flex)
117AC_CHECK_PROG(BISON, bison, bison)
8de11deb
OZ
118AC_CHECK_PROGS(M4, gm4 m4)
119
120test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
121test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
122test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
123BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])])
416e3ee4 124
2f9bcf97 125if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
2f9bcf97 126 if test -f $with_sysconfig ; then
49e7e5ee 127 sysdesc=$with_sysconfig
2f9bcf97 128 else
49e7e5ee
MM
129 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
130 if ! test -f $sysdesc ; then
131 sysdesc=$sysdesc.h
132 fi
2f9bcf97
MM
133 fi
134elif test -f sysconfig.h ; then
49e7e5ee 135 sysdesc=sysconfig
2f9bcf97 136else
d549b83f
OZ
137 case "$host_os" in
138 linux*) sysdesc=linux
acc93efd 139 default_iproutedir="/etc/iproute2"
1127ac6e 140 ;;
d549b83f 141 freebsd*) sysdesc=bsd
c817b991 142 ;;
d549b83f 143 kfreebsd*) sysdesc=bsd
7cb37e6f 144 ;;
d549b83f 145 netbsd*) sysdesc=bsd
d0c64519 146 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
646b24d9 147 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
7cb37e6f 148 ;;
d549b83f 149 openbsd*) sysdesc=bsd
7cb37e6f 150 ;;
d549b83f 151 dragonfly*) sysdesc=bsd
ef9c9ab9 152 ;;
416e3ee4 153 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
2f9bcf97
MM
154 ;;
155 esac
49e7e5ee 156 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
2f9bcf97 157fi
416e3ee4 158AC_MSG_CHECKING([which OS configuration should we use])
49e7e5ee
MM
159AC_MSG_RESULT($sysdesc)
160if ! test -f $sysdesc ; then
2f9bcf97
MM
161 AC_MSG_ERROR([The system configuration file is missing.])
162fi
49e7e5ee 163sysname=`echo $sysdesc | sed 's/\.h$//'`
7a855725 164AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include])
49e7e5ee
MM
165
166AC_MSG_CHECKING([system-dependent directories])
7152e5ef 167sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`"
49e7e5ee
MM
168AC_MSG_RESULT($sysdep_dirs)
169AC_SUBST(sysdep_dirs)
2f9bcf97 170
acc93efd
OZ
171if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
172
173if test -n "$given_iproutedir"
174then iproutedir=$with_iproutedir
175else iproutedir=$default_iproutedir
176fi
177
178AC_SUBST(iproutedir)
179
5e8df049 180all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static"
d549b83f 181
1ec52253
OZ
182all_protocols=`echo $all_protocols | sed 's/ /,/g'`
183
184if test "$with_protocols" = all ; then
185 with_protocols="$all_protocols"
186fi
187
7a855725
OZ
188AH_TEMPLATE([CONFIG_BABEL], [Babel protocol])
189AH_TEMPLATE([CONFIG_BFD], [BFD protocol])
190AH_TEMPLATE([CONFIG_BGP], [BGP protocol])
191AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol])
192AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol])
193AH_TEMPLATE([CONFIG_RADV], [RAdv protocol])
194AH_TEMPLATE([CONFIG_RIP], [RIP protocol])
525a88d8 195AH_TEMPLATE([CONFIG_RPKI], [RPKI protocol])
7a855725
OZ
196AH_TEMPLATE([CONFIG_STATIC], [Static protocol])
197
2f9bcf97
MM
198AC_MSG_CHECKING([protocols])
199protocols=`echo "$with_protocols" | sed 's/,/ /g'`
b296730c 200if test "$protocols" = no ; then protocols= ; fi
2f9bcf97
MM
201for a in $protocols ; do
202 if ! test -f $srcdir/proto/$a/Makefile ; then
203 AC_MSG_RESULT(failed)
204 AC_MSG_ERROR([Requested protocol $a not found.])
205 fi
206 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
207 done
208AC_MSG_RESULT(ok)
49e7e5ee 209AC_SUBST(protocols)
2f9bcf97 210
a07e9d82 211case $sysdesc in
d549b83f 212 */linux*)
9f387e11
MM
213 AC_CHECK_HEADER(linux/rtnetlink.h,,[AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],[
214#include <asm/types.h>
215#include <sys/socket.h>
216])
c817b991 217 ;;
a07e9d82
MM
218esac
219
5d6dc930 220AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
71652572 221AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
7a855725 222
525a88d8
OZ
223AC_CHECK_HEADER([linux/lwtunnel.h], [AC_DEFINE([HAVE_LWTUNNEL], [1], [Define to 1 if you have the <linux/lwtunnel.h> header file.])])
224AC_CHECK_MEMBERS([struct rtvia.rtvia_family], [AC_DEFINE([HAVE_STRUCT_RTVIA], [1], [Define to 1 if you have rtvia structure.])],,[#include <linux/rtnetlink.h>])
2f9bcf97 225
7a855725
OZ
226AC_C_BIGENDIAN(
227 [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
228 [AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
229 [AC_MSG_ERROR([Cannot determine CPU endianity.])]
230)
e6ff7a08 231
2f9bcf97
MM
232BIRD_CHECK_STRUCT_ALIGN
233BIRD_CHECK_TIME_T
234
235if test "$enable_debug" = yes ; then
7a855725 236 AC_DEFINE([DEBUGGING], [1], [Define to 1 if debugging is enabled])
525a88d8 237 AC_CHECK_HEADER(execinfo.h, [AC_SEARCH_LIBS([backtrace, backtrace_symbols], [c execinfo], [AC_DEFINE([HAVE_EXECINFO_H], [1], [Define to 1 if you have the <execinfo.h> header file.])])])
9b0a0ba9
OZ
238 LDFLAGS="$LDFLAGS -rdynamic"
239 CFLAGS="$CFLAGS -O0 -ggdb -g3 -gdwarf-4"
6b5ab875
MM
240 if test "$enable_memcheck" = yes ; then
241 AC_CHECK_LIB(dmalloc, dmalloc_debug)
242 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
243 AC_CHECK_LIB(efence, malloc)
244 fi
7a2105be 245 fi
2f9bcf97
MM
246fi
247
65d2a88d 248DAEMON_LIBS=
65d2a88d
PT
249AC_SUBST(DAEMON_LIBS)
250
7152e5ef 251CLIENT=birdcl
7211be1c 252CLIENT_LIBS=
9fac310d 253if test "$enable_client" = yes ; then
7152e5ef 254 CLIENT="$CLIENT birdc"
7211be1c
MM
255 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
256 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
257 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
489c308a 258 AC_CHECK_LIB(tinfow, tgetent, USE_TERMCAP_LIB=-ltinfow,
9ae0f4b7
OZ
259 AC_CHECK_LIB(tinfo, tgetent, USE_TERMCAP_LIB=-ltinfo,
260 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap,
261 AC_MSG_ERROR([[The client requires ncurses library. Either install the library or use --disable-client to compile without the client.]]))))))
1d4ba658 262 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
df0cf75d 263 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)
7a855725
OZ
264 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE([HAVE_RL_CRLF], [1], [Define to 1 if you have rl_crlf()]),,$USE_TERMCAP_LIB)
265 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE([HAVE_RL_DING], [1], [Define to 1 if you have rl_ding()]),,$USE_TERMCAP_LIB)
9fac310d
MM
266fi
267AC_SUBST(CLIENT)
7211be1c 268AC_SUBST(CLIENT_LIBS)
9fac310d 269
54165b13 270mkdir -p $objdir/sysdep
7cb37e6f 271AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
7152e5ef 272AC_CONFIG_FILES(Makefile:Makefile.in)
22122d4d 273AC_OUTPUT
2f9bcf97 274
7a855725
OZ
275AC_MSG_RESULT()
276AC_MSG_RESULT([BIRD was configured with the following options:])
277AC_MSG_RESULT([ Source directory: $srcdir])
278AC_MSG_RESULT([ Object directory: $objdir])
279AC_MSG_RESULT([ Iproute2 directory: $iproutedir])
280AC_MSG_RESULT([ System configuration: $sysdesc])
281AC_MSG_RESULT([ Debugging: $enable_debug])
282AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
283AC_MSG_RESULT([ Routing protocols: $protocols])
284AC_MSG_RESULT([ Client: $enable_client])
525a88d8 285
b296730c 286rm -f $objdir/.*-stamp