]> git.ipfire.org Git - thirdparty/bird.git/blob - configure.in
Adding also our copy of struct rtvia.
[thirdparty/bird.git] / configure.in
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>
4
5 AC_REVISION($Id$)
6 AC_INIT(conf/confbase.Y)
7 AC_CONFIG_AUX_DIR(tools)
8
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_ENABLE(libssh, [ --enable-libssh enable LibSSH support together with RPKI protocol (default: detect)],,enable_libssh=try)
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
23
24 if test "$srcdir" = . ; then
25 # Building in current directory => create obj directory holding all objects
26 objdir=obj
27 else
28 # Building in separate directory
29 objdir=.
30 fi
31
32 exedir=.
33
34 AC_SUBST(objdir)
35 AC_SUBST(exedir)
36 AC_SUBST(srcdir)
37 AC_SUBST(runtimedir)
38
39
40 if test "$enable_debug" = yes ; then
41 CONFIG_FILE="bird.conf"
42 CONTROL_SOCKET="bird.ctl"
43 else
44 CONFIG_FILE="\$(sysconfdir)/bird.conf"
45 CONTROL_SOCKET="$runtimedir/bird.ctl"
46 fi
47 AC_SUBST(CONFIG_FILE)
48 AC_SUBST(CONTROL_SOCKET)
49
50 AC_SEARCH_LIBS(clock_gettime, [c rt posix4], ,
51 AC_MSG_ERROR([[Function clock_gettime not available.]]))
52
53 AC_CANONICAL_HOST
54
55 # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
56 if test "$ac_test_CFLAGS" != set ; then
57 bird_cflags_default=yes
58 fi
59
60 AC_PROG_CC
61 AC_PROG_CC_C99
62 if test -z "$GCC" ; then
63 AC_MSG_ERROR([This program requires the GNU C Compiler.])
64 fi
65
66 # Enable threads by default just in Linux and FreeBSD
67 #if test "$enable_pthreads" = try ; then
68 # case "$host_os" in
69 # (linux* | freebsd* | openbsd* | netbsd* ) enable_pthreads=try ;;
70 # (*) enable_pthreads=no ;;
71 # esac
72 #fi
73
74 if test "$enable_pthreads" != no ; then
75 BIRD_CHECK_PTHREADS
76
77 if test "$bird_cv_lib_pthreads" = yes ; then
78 AC_DEFINE(USE_PTHREADS)
79 CFLAGS="$CFLAGS -pthread"
80 LDFLAGS="$LDFLAGS -pthread"
81 proto_bfd=bfd
82 elif test "$enable_pthreads" = yes ; then
83 AC_MSG_ERROR([POSIX threads not available.])
84 fi
85
86 if test "$enable_pthreads" = try ; then
87 enable_pthreads="$bird_cv_lib_pthreads"
88 fi
89 fi
90
91 if test "$enable_libssh" != no ; then
92 AC_CHECK_LIB(ssh, ssh_connect)
93 if test $ac_cv_lib_ssh_ssh_connect = yes ; then
94 proto_rpki=rpki
95 enable_libssh=yes
96 AC_DEFINE(HAVE_LIBSSH)
97 else
98 if test "$enable_libssh" = yes ; then
99 AC_MSG_ERROR([LibSSH not available.])
100 else
101 enable_libssh=no
102 fi
103 fi
104 fi
105
106 if test "$bird_cflags_default" = yes ; then
107 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
108 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
109 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
110 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
111
112 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
113 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
114 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
115 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_aliasing, -fno-strict-aliasing)
116 BIRD_ADD_GCC_OPTION(bird_cv_c_option_fno_strict_overflow, -fno-strict-overflow)
117 fi
118 AC_MSG_CHECKING([CFLAGS])
119 AC_MSG_RESULT($CFLAGS)
120
121
122 AC_PROG_CPP
123 AC_PROG_INSTALL
124 AC_PROG_RANLIB
125 AC_CHECK_PROG(FLEX, flex, flex)
126 AC_CHECK_PROG(BISON, bison, bison)
127 AC_CHECK_PROGS(M4, gm4 m4)
128
129 test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
130 test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
131 test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
132 BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])])
133
134 if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
135 if test -f $with_sysconfig ; then
136 sysdesc=$with_sysconfig
137 else
138 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
139 if ! test -f $sysdesc ; then
140 sysdesc=$sysdesc.h
141 fi
142 fi
143 elif test -f sysconfig.h ; then
144 sysdesc=sysconfig
145 else
146 case "$host_os" in
147 linux*) sysdesc=linux
148 default_iproutedir="/etc/iproute2"
149 ;;
150 freebsd*) sysdesc=bsd
151 ;;
152 kfreebsd*) sysdesc=bsd
153 ;;
154 netbsd*) sysdesc=bsd
155 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
156 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
157 ;;
158 openbsd*) sysdesc=bsd
159 ;;
160 dragonfly*) sysdesc=bsd
161 ;;
162 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
163 ;;
164 esac
165 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
166 fi
167 AC_MSG_CHECKING([which OS configuration should we use])
168 AC_MSG_RESULT($sysdesc)
169 if ! test -f $sysdesc ; then
170 AC_MSG_ERROR([The system configuration file is missing.])
171 fi
172 sysname=`echo $sysdesc | sed 's/\.h$//'`
173 AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
174
175 AC_MSG_CHECKING([system-dependent directories])
176 sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`"
177 AC_MSG_RESULT($sysdep_dirs)
178 AC_SUBST(sysdep_dirs)
179
180 if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
181
182 if test -n "$given_iproutedir"
183 then iproutedir=$with_iproutedir
184 else iproutedir=$default_iproutedir
185 fi
186
187 AC_SUBST(iproutedir)
188
189 all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static"
190
191 all_protocols=`echo $all_protocols | sed 's/ /,/g'`
192
193 if test "$with_protocols" = all ; then
194 with_protocols="$all_protocols"
195 fi
196
197 AC_MSG_CHECKING([protocols])
198 protocols=`echo "$with_protocols" | sed 's/,/ /g'`
199 if test "$protocols" = no ; then protocols= ; fi
200 for a in $protocols ; do
201 if ! test -f $srcdir/proto/$a/Makefile ; then
202 AC_MSG_RESULT(failed)
203 AC_MSG_ERROR([Requested protocol $a not found.])
204 fi
205 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
206 done
207 AC_MSG_RESULT(ok)
208 AC_SUBST(protocols)
209
210 case $sysdesc in
211 */linux*)
212 AC_CHECK_HEADER(linux/rtnetlink.h,,[AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],[
213 #include <asm/types.h>
214 #include <sys/socket.h>
215 ])
216 ;;
217 esac
218
219 AC_CHECK_HEADER(syslog.h, [AC_DEFINE(HAVE_SYSLOG)])
220 AC_CHECK_HEADER(alloca.h, [AC_DEFINE(HAVE_ALLOCA_H)])
221 AC_CHECK_HEADER([linux/lwtunnel.h], [AC_DEFINE(HAVE_LWTUNNEL)])
222 AC_CHECK_MEMBERS([struct rtvia.rtvia_family], [AC_DEFINE(HAVE_STRUCT_RTVIA)],,[#include <linux/rtnetlink.h>])
223 AC_MSG_CHECKING(whether 'struct sockaddr' has sa_len)
224 AC_TRY_COMPILE([#include <sys/types.h>
225 #include <sys/socket.h>
226 ], [static struct sockaddr sa; int i = sizeof(sa.sa_len);],
227 [AC_MSG_RESULT(yes)
228 AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
229 AC_MSG_RESULT(no))
230
231 AC_C_BIGENDIAN([AC_DEFINE(CPU_BIG_ENDIAN)], [AC_DEFINE(CPU_LITTLE_ENDIAN)],
232 [AC_MSG_ERROR([Cannot determine CPU endianity.])])
233
234 BIRD_CHECK_INTEGERS
235 BIRD_CHECK_STRUCT_ALIGN
236 BIRD_CHECK_TIME_T
237 BIRD_CHECK_STRUCT_IP_MREQN
238
239 if test "$enable_debug" = yes ; then
240 AC_DEFINE(DEBUGGING)
241 AC_CHECK_HEADER(execinfo.h, [AC_SEARCH_LIBS([backtrace, backtrace_symbols], [c execinfo], [AC_DEFINE(HAVE_EXECINFO_H)])])
242 LDFLAGS="$LDFLAGS -rdynamic"
243 CFLAGS="$CFLAGS -O0 -ggdb -g3 -gdwarf-4"
244 if test "$enable_memcheck" = yes ; then
245 AC_CHECK_LIB(dmalloc, dmalloc_debug)
246 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
247 AC_CHECK_LIB(efence, malloc)
248 fi
249 fi
250 fi
251
252 DAEMON_LIBS=
253 AC_SUBST(DAEMON_LIBS)
254
255 CLIENT=birdcl
256 CLIENT_LIBS=
257 if test "$enable_client" = yes ; then
258 CLIENT="$CLIENT birdc"
259 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
260 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
261 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
262 AC_CHECK_LIB(tinfow, tgetent, USE_TERMCAP_LIB=-ltinfow,
263 AC_CHECK_LIB(tinfo, tgetent, USE_TERMCAP_LIB=-ltinfo,
264 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap,
265 AC_MSG_ERROR([[The client requires ncurses library. Either install the library or use --disable-client to compile without the client.]]))))))
266 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
267 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)
268 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE(HAVE_RL_CRLF),,$USE_TERMCAP_LIB)
269 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE(HAVE_RL_DING),,$USE_TERMCAP_LIB)
270 fi
271 AC_SUBST(CLIENT)
272 AC_SUBST(CLIENT_LIBS)
273
274 mkdir -p $objdir/sysdep
275 AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
276 AC_CONFIG_FILES(Makefile:Makefile.in)
277 AC_OUTPUT
278
279 cat >&AC_FD_MSG <<EOF
280
281 BIRD was configured with the following options:
282 Source directory: $srcdir
283 Object directory: $objdir
284 Iproute2 directory: $iproutedir
285 System configuration: $sysdesc
286 Debugging: $enable_debug
287 POSIX threads: $enable_pthreads
288 Routing protocols: $protocols
289 Client: $enable_client
290 EOF
291 rm -f $objdir/.*-stamp