]>
Commit | Line | Data |
---|---|---|
2f9bcf97 MM |
1 | dnl ** This is a configure script template for BIRD |
2 | dnl ** Process it with autoconf to get ./configure | |
9fac310d | 3 | dnl ** (c) 1999--2000 Martin Mares <mj@ucw.cz> |
2f9bcf97 | 4 | |
7a855725 OZ |
5 | AC_INIT |
6 | AC_CONFIG_SRCDIR([conf/confbase.Y]) | |
2f9bcf97 MM |
7 | AC_CONFIG_AUX_DIR(tools) |
8 | ||
ab188fb7 OZ |
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) | |
1ec52253 | 12 | AC_ARG_ENABLE(pthreads, [ --enable-pthreads enable POSIX threads support (default: detect)],,enable_pthreads=try) |
af62c0f9 | 13 | AC_ARG_ENABLE(libssh, [ --enable-libssh enable LibSSH support together with RPKI protocol (default: detect)],,enable_libssh=try) |
ab188fb7 OZ |
14 | AC_ARG_WITH(sysconfig, [ --with-sysconfig=FILE use specified BIRD system configuration file]) |
15 | AC_ARG_WITH(protocols, [ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"]) | |
16 | AC_ARG_WITH(sysinclude, [ --with-sysinclude=PATH search for system includes on specified place]) | |
17 | AC_ARG_WITH(runtimedir, [ --with-runtimedir=PATH path for runtime files (default: $(localstatedir)/run)],[runtimedir="$with_runtimedir"],[runtimedir="\$(localstatedir)/run"]) | |
18 | AC_ARG_WITH(iproutedir, [ --with-iproutedir=PATH path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"]) | |
19 | AC_ARG_VAR([FLEX], [location of the Flex program]) | |
20 | AC_ARG_VAR([BISON], [location of the Bison program]) | |
21 | AC_ARG_VAR([M4], [location of the M4 program]) | |
22 | ||
2f9bcf97 | 23 | |
49e7e5ee MM |
24 | if test "$srcdir" = . ; then |
25 | # Building in current directory => create obj directory holding all objects | |
26 | objdir=obj | |
49e7e5ee MM |
27 | else |
28 | # Building in separate directory | |
29 | objdir=. | |
49e7e5ee | 30 | fi |
7152e5ef JMM |
31 | |
32 | exedir=. | |
33 | ||
49e7e5ee MM |
34 | AC_SUBST(objdir) |
35 | AC_SUBST(exedir) | |
7152e5ef | 36 | AC_SUBST(srcdir) |
ab188fb7 | 37 | AC_SUBST(runtimedir) |
49e7e5ee | 38 | |
ab188fb7 | 39 | |
ab188fb7 | 40 | if test "$enable_debug" = yes ; then |
d549b83f OZ |
41 | CONFIG_FILE="bird.conf" |
42 | CONTROL_SOCKET="bird.ctl" | |
ab188fb7 | 43 | else |
d549b83f OZ |
44 | CONFIG_FILE="\$(sysconfdir)/bird.conf" |
45 | CONTROL_SOCKET="$runtimedir/bird.ctl" | |
ab188fb7 OZ |
46 | fi |
47 | AC_SUBST(CONFIG_FILE) | |
48 | AC_SUBST(CONTROL_SOCKET) | |
49 | ||
5d6dc930 | 50 | AC_SEARCH_LIBS(clock_gettime, [rt posix4], , |
d7765408 | 51 | AC_MSG_ERROR([[Function clock_gettime not available.]])) |
fd91ae33 | 52 | |
2f9bcf97 | 53 | AC_CANONICAL_HOST |
416e3ee4 | 54 | |
b1c030b0 | 55 | # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC |
416e3ee4 | 56 | if test "$ac_test_CFLAGS" != set ; then |
b1c030b0 | 57 | bird_cflags_default=yes |
416e3ee4 | 58 | fi |
416e3ee4 | 59 | |
4e276a89 | 60 | AC_PROG_CC |
9b0a0ba9 | 61 | AC_PROG_CC_C99 |
e81b440f OZ |
62 | if test -z "$GCC" ; then |
63 | AC_MSG_ERROR([This program requires the GNU C Compiler.]) | |
64 | fi | |
65 | ||
1ec52253 OZ |
66 | if 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 | |
81 | fi | |
82 | ||
af62c0f9 JMM |
83 | if 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 | |
95 | fi | |
96 | ||
bed41728 | 97 | if 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 | 108 | fi |
efd6d12b | 109 | AC_MSG_CHECKING([CFLAGS]) |
b1c030b0 OZ |
110 | AC_MSG_RESULT($CFLAGS) |
111 | ||
112 | ||
416e3ee4 MM |
113 | AC_PROG_CPP |
114 | AC_PROG_INSTALL | |
115 | AC_PROG_RANLIB | |
116 | AC_CHECK_PROG(FLEX, flex, flex) | |
117 | AC_CHECK_PROG(BISON, bison, bison) | |
8de11deb OZ |
118 | AC_CHECK_PROGS(M4, gm4 m4) |
119 | ||
120 | test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.]) | |
121 | test -z "$BISON" && AC_MSG_ERROR([Bison is missing.]) | |
122 | test -z "$M4" && AC_MSG_ERROR([M4 is missing.]) | |
123 | BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])]) | |
416e3ee4 | 124 | |
2f9bcf97 | 125 | if 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 |
134 | elif test -f sysconfig.h ; then | |
49e7e5ee | 135 | sysdesc=sysconfig |
2f9bcf97 | 136 | else |
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 | 157 | fi |
416e3ee4 | 158 | AC_MSG_CHECKING([which OS configuration should we use]) |
49e7e5ee MM |
159 | AC_MSG_RESULT($sysdesc) |
160 | if ! test -f $sysdesc ; then | |
2f9bcf97 MM |
161 | AC_MSG_ERROR([The system configuration file is missing.]) |
162 | fi | |
49e7e5ee | 163 | sysname=`echo $sysdesc | sed 's/\.h$//'` |
7a855725 | 164 | AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include]) |
49e7e5ee MM |
165 | |
166 | AC_MSG_CHECKING([system-dependent directories]) | |
7152e5ef | 167 | sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`" |
49e7e5ee MM |
168 | AC_MSG_RESULT($sysdep_dirs) |
169 | AC_SUBST(sysdep_dirs) | |
2f9bcf97 | 170 | |
acc93efd OZ |
171 | if test "$with_iproutedir" = no ; then with_iproutedir= ; fi |
172 | ||
173 | if test -n "$given_iproutedir" | |
174 | then iproutedir=$with_iproutedir | |
175 | else iproutedir=$default_iproutedir | |
176 | fi | |
177 | ||
178 | AC_SUBST(iproutedir) | |
179 | ||
5e8df049 | 180 | all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static" |
d549b83f | 181 | |
1ec52253 OZ |
182 | all_protocols=`echo $all_protocols | sed 's/ /,/g'` |
183 | ||
184 | if test "$with_protocols" = all ; then | |
185 | with_protocols="$all_protocols" | |
186 | fi | |
187 | ||
7a855725 OZ |
188 | AH_TEMPLATE([CONFIG_BABEL], [Babel protocol]) |
189 | AH_TEMPLATE([CONFIG_BFD], [BFD protocol]) | |
190 | AH_TEMPLATE([CONFIG_BGP], [BGP protocol]) | |
191 | AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol]) | |
192 | AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol]) | |
193 | AH_TEMPLATE([CONFIG_RADV], [RAdv protocol]) | |
194 | AH_TEMPLATE([CONFIG_RIP], [RIP protocol]) | |
525a88d8 | 195 | AH_TEMPLATE([CONFIG_RPKI], [RPKI protocol]) |
7a855725 OZ |
196 | AH_TEMPLATE([CONFIG_STATIC], [Static protocol]) |
197 | ||
2f9bcf97 MM |
198 | AC_MSG_CHECKING([protocols]) |
199 | protocols=`echo "$with_protocols" | sed 's/,/ /g'` | |
b296730c | 200 | if test "$protocols" = no ; then protocols= ; fi |
2f9bcf97 MM |
201 | for 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 | |
208 | AC_MSG_RESULT(ok) | |
49e7e5ee | 209 | AC_SUBST(protocols) |
2f9bcf97 | 210 | |
a07e9d82 | 211 | case $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 |
218 | esac |
219 | ||
5d6dc930 | 220 | AC_CHECK_HEADERS_ONCE([alloca.h syslog.h]) |
71652572 | 221 | AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>]) |
7a855725 | 222 | |
525a88d8 OZ |
223 | AC_CHECK_HEADER([linux/lwtunnel.h], [AC_DEFINE([HAVE_LWTUNNEL], [1], [Define to 1 if you have the <linux/lwtunnel.h> header file.])]) |
224 | AC_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 |
226 | AC_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 |
232 | BIRD_CHECK_STRUCT_ALIGN |
233 | BIRD_CHECK_TIME_T | |
234 | ||
235 | if 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 |
246 | fi |
247 | ||
65d2a88d | 248 | DAEMON_LIBS= |
65d2a88d PT |
249 | AC_SUBST(DAEMON_LIBS) |
250 | ||
7152e5ef | 251 | CLIENT=birdcl |
7211be1c | 252 | CLIENT_LIBS= |
9fac310d | 253 | if 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 |
266 | fi |
267 | AC_SUBST(CLIENT) | |
7211be1c | 268 | AC_SUBST(CLIENT_LIBS) |
9fac310d | 269 | |
54165b13 | 270 | mkdir -p $objdir/sysdep |
7cb37e6f | 271 | AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in]) |
7152e5ef | 272 | AC_CONFIG_FILES(Makefile:Makefile.in) |
22122d4d | 273 | AC_OUTPUT |
2f9bcf97 | 274 | |
7a855725 OZ |
275 | AC_MSG_RESULT() |
276 | AC_MSG_RESULT([BIRD was configured with the following options:]) | |
277 | AC_MSG_RESULT([ Source directory: $srcdir]) | |
278 | AC_MSG_RESULT([ Object directory: $objdir]) | |
279 | AC_MSG_RESULT([ Iproute2 directory: $iproutedir]) | |
280 | AC_MSG_RESULT([ System configuration: $sysdesc]) | |
281 | AC_MSG_RESULT([ Debugging: $enable_debug]) | |
282 | AC_MSG_RESULT([ POSIX threads: $enable_pthreads]) | |
283 | AC_MSG_RESULT([ Routing protocols: $protocols]) | |
284 | AC_MSG_RESULT([ Client: $enable_client]) | |
525a88d8 | 285 | |
b296730c | 286 | rm -f $objdir/.*-stamp |