]> git.ipfire.org Git - thirdparty/bird.git/blame - configure.in
Merge branch 'master' into int-new
[thirdparty/bird.git] / configure.in
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
MM
4
5AC_REVISION($Id$)
6AC_INIT(conf/confbase.Y)
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)
ab188fb7
OZ
13AC_ARG_WITH(sysconfig, [ --with-sysconfig=FILE use specified BIRD system configuration file])
14AC_ARG_WITH(protocols, [ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"])
15AC_ARG_WITH(sysinclude, [ --with-sysinclude=PATH search for system includes on specified place])
16AC_ARG_WITH(runtimedir, [ --with-runtimedir=PATH path for runtime files (default: $(localstatedir)/run)],[runtimedir="$with_runtimedir"],[runtimedir="\$(localstatedir)/run"])
17AC_ARG_WITH(iproutedir, [ --with-iproutedir=PATH path to iproute2 config files (default: /etc/iproute2)],[given_iproutedir="yes"])
18AC_ARG_VAR([FLEX], [location of the Flex program])
19AC_ARG_VAR([BISON], [location of the Bison program])
20AC_ARG_VAR([M4], [location of the M4 program])
21
2f9bcf97 22
49e7e5ee
MM
23if test "$srcdir" = . ; then
24 # Building in current directory => create obj directory holding all objects
25 objdir=obj
49e7e5ee
MM
26else
27 # Building in separate directory
28 objdir=.
49e7e5ee 29fi
7152e5ef
JMM
30
31exedir=.
32
49e7e5ee
MM
33AC_SUBST(objdir)
34AC_SUBST(exedir)
7152e5ef 35AC_SUBST(srcdir)
ab188fb7 36AC_SUBST(runtimedir)
49e7e5ee 37
ab188fb7 38
ab188fb7 39if test "$enable_debug" = yes ; then
d549b83f
OZ
40 CONFIG_FILE="bird.conf"
41 CONTROL_SOCKET="bird.ctl"
ab188fb7 42else
d549b83f
OZ
43 CONFIG_FILE="\$(sysconfdir)/bird.conf"
44 CONTROL_SOCKET="$runtimedir/bird.ctl"
ab188fb7
OZ
45fi
46AC_SUBST(CONFIG_FILE)
47AC_SUBST(CONTROL_SOCKET)
48
d7765408
OZ
49AC_SEARCH_LIBS(clock_gettime, [c rt posix4], ,
50 AC_MSG_ERROR([[Function clock_gettime not available.]]))
fd91ae33 51
2f9bcf97 52AC_CANONICAL_HOST
416e3ee4 53
b1c030b0 54# Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
416e3ee4 55if test "$ac_test_CFLAGS" != set ; then
b1c030b0 56 bird_cflags_default=yes
416e3ee4 57fi
416e3ee4 58
e81b440f
OZ
59AC_PROG_CC
60if test -z "$GCC" ; then
61 AC_MSG_ERROR([This program requires the GNU C Compiler.])
62fi
63
547d3bf4 64# Enable threads by default just in Linux and FreeBSD
0e965f69
JMM
65#if test "$enable_pthreads" = try ; then
66# case "$host_os" in
67# (linux* | freebsd* | openbsd* | netbsd* ) enable_pthreads=try ;;
68# (*) enable_pthreads=no ;;
69# esac
70#fi
547d3bf4 71
1ec52253
OZ
72if test "$enable_pthreads" != no ; then
73 BIRD_CHECK_PTHREADS
74
75 if test "$bird_cv_lib_pthreads" = yes ; then
76 AC_DEFINE(USE_PTHREADS)
77 CFLAGS="$CFLAGS -pthread"
78 LDFLAGS="$LDFLAGS -pthread"
79 proto_bfd=bfd
80 elif test "$enable_pthreads" = yes ; then
81 AC_MSG_ERROR([POSIX threads not available.])
82 fi
83
84 if test "$enable_pthreads" = try ; then
85 enable_pthreads="$bird_cv_lib_pthreads"
86 fi
87fi
88
bed41728 89if test "$bird_cflags_default" = yes ; then
efd6d12b 90 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign, -Wall)
3e236955 91 BIRD_CHECK_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers, -Wall -Wextra)
efd6d12b
OZ
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)
b1c030b0 94
3e236955 95 CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses"
efd6d12b 96 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_pointer_sign, -Wno-pointer-sign)
3e236955 97 BIRD_ADD_GCC_OPTION(bird_cv_c_option_wno_missing_init, -Wno-missing-field-initializers)
efd6d12b
OZ
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)
b1c030b0 100fi
efd6d12b 101AC_MSG_CHECKING([CFLAGS])
b1c030b0
OZ
102AC_MSG_RESULT($CFLAGS)
103
104
416e3ee4
MM
105AC_PROG_CPP
106AC_PROG_INSTALL
107AC_PROG_RANLIB
108AC_CHECK_PROG(FLEX, flex, flex)
109AC_CHECK_PROG(BISON, bison, bison)
8de11deb
OZ
110AC_CHECK_PROGS(M4, gm4 m4)
111
112test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.])
113test -z "$BISON" && AC_MSG_ERROR([Bison is missing.])
114test -z "$M4" && AC_MSG_ERROR([M4 is missing.])
115BIRD_CHECK_PROG_FLAVOR_GNU([$M4], , [AC_MSG_ERROR([Provided M4 is not GNU M4.])])
416e3ee4 116
2f9bcf97 117if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
2f9bcf97 118 if test -f $with_sysconfig ; then
49e7e5ee 119 sysdesc=$with_sysconfig
2f9bcf97 120 else
49e7e5ee
MM
121 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
122 if ! test -f $sysdesc ; then
123 sysdesc=$sysdesc.h
124 fi
2f9bcf97
MM
125 fi
126elif test -f sysconfig.h ; then
49e7e5ee 127 sysdesc=sysconfig
2f9bcf97 128else
d549b83f
OZ
129 case "$host_os" in
130 linux*) sysdesc=linux
acc93efd 131 default_iproutedir="/etc/iproute2"
1127ac6e 132 ;;
d549b83f 133 freebsd*) sysdesc=bsd
c817b991 134 ;;
d549b83f 135 kfreebsd*) sysdesc=bsd
7cb37e6f 136 ;;
d549b83f 137 netbsd*) sysdesc=bsd
d0c64519 138 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
646b24d9 139 LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib"
7cb37e6f 140 ;;
d549b83f 141 openbsd*) sysdesc=bsd
7cb37e6f 142 ;;
d549b83f 143 dragonfly*) sysdesc=bsd
ef9c9ab9 144 ;;
416e3ee4 145 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
2f9bcf97
MM
146 ;;
147 esac
49e7e5ee 148 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
2f9bcf97 149fi
416e3ee4 150AC_MSG_CHECKING([which OS configuration should we use])
49e7e5ee
MM
151AC_MSG_RESULT($sysdesc)
152if ! test -f $sysdesc ; then
2f9bcf97
MM
153 AC_MSG_ERROR([The system configuration file is missing.])
154fi
49e7e5ee
MM
155sysname=`echo $sysdesc | sed 's/\.h$//'`
156AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
157
158AC_MSG_CHECKING([system-dependent directories])
7152e5ef 159sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`"
49e7e5ee
MM
160AC_MSG_RESULT($sysdep_dirs)
161AC_SUBST(sysdep_dirs)
2f9bcf97 162
acc93efd
OZ
163if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
164
165if test -n "$given_iproutedir"
166then iproutedir=$with_iproutedir
167else iproutedir=$default_iproutedir
168fi
169
170AC_SUBST(iproutedir)
171
af678af0 172# all_protocols="$proto_bfd babel bgp ospf pipe radv rip static"
d549b83f
OZ
173all_protocols="$proto_bfd ospf pipe radv rip static"
174
1ec52253
OZ
175all_protocols=`echo $all_protocols | sed 's/ /,/g'`
176
177if test "$with_protocols" = all ; then
178 with_protocols="$all_protocols"
179fi
180
2f9bcf97
MM
181AC_MSG_CHECKING([protocols])
182protocols=`echo "$with_protocols" | sed 's/,/ /g'`
b296730c 183if test "$protocols" = no ; then protocols= ; fi
2f9bcf97
MM
184for 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.])
188 fi
189 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
190 done
191AC_MSG_RESULT(ok)
49e7e5ee 192AC_SUBST(protocols)
2f9bcf97 193
a07e9d82 194case $sysdesc in
d549b83f 195 */linux*)
9f387e11
MM
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>
199])
c817b991 200 ;;
a07e9d82
MM
201esac
202
2f9bcf97 203AC_CHECK_HEADER(syslog.h, [AC_DEFINE(HAVE_SYSLOG)])
7cb37e6f
OF
204AC_CHECK_HEADER(alloca.h, [AC_DEFINE(HAVE_ALLOCA_H)])
205AC_MSG_CHECKING(whether 'struct sockaddr' has sa_len)
206AC_TRY_COMPILE([#include <sys/types.h>
207 #include <sys/socket.h>
208 ], [static struct sockaddr sa; int i = sizeof(sa.sa_len);],
209 [AC_MSG_RESULT(yes)
210 AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
211 AC_MSG_RESULT(no))
2f9bcf97 212
e6ff7a08
OZ
213AC_C_BIGENDIAN([AC_DEFINE(CPU_BIG_ENDIAN)], [AC_DEFINE(CPU_LITTLE_ENDIAN)],
214 [AC_MSG_ERROR([Cannot determine CPU endianity.])])
215
2f9bcf97 216BIRD_CHECK_INTEGERS
2f9bcf97
MM
217BIRD_CHECK_STRUCT_ALIGN
218BIRD_CHECK_TIME_T
620c4f90 219BIRD_CHECK_STRUCT_IP_MREQN
2f9bcf97
MM
220
221if test "$enable_debug" = yes ; then
2f9bcf97 222 AC_DEFINE(DEBUGGING)
6b5ab875
MM
223 if test "$enable_memcheck" = yes ; then
224 AC_CHECK_LIB(dmalloc, dmalloc_debug)
225 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
226 AC_CHECK_LIB(efence, malloc)
227 fi
7a2105be 228 fi
2f9bcf97
MM
229fi
230
7152e5ef 231CLIENT=birdcl
7211be1c 232CLIENT_LIBS=
9fac310d 233if test "$enable_client" = yes ; then
7152e5ef 234 CLIENT="$CLIENT birdc"
7211be1c
MM
235 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
236 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
237 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
489c308a 238 AC_CHECK_LIB(tinfow, tgetent, USE_TERMCAP_LIB=-ltinfow,
9ae0f4b7
OZ
239 AC_CHECK_LIB(tinfo, tgetent, USE_TERMCAP_LIB=-ltinfo,
240 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap,
241 AC_MSG_ERROR([[The client requires ncurses library. Either install the library or use --disable-client to compile without the client.]]))))))
1d4ba658 242 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
df0cf75d 243 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)
6de62923
OF
244 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE(HAVE_RL_CRLF),,$USE_TERMCAP_LIB)
245 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE(HAVE_RL_DING),,$USE_TERMCAP_LIB)
9fac310d
MM
246fi
247AC_SUBST(CLIENT)
7211be1c 248AC_SUBST(CLIENT_LIBS)
9fac310d 249
54165b13 250mkdir -p $objdir/sysdep
7cb37e6f 251AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
7152e5ef 252AC_CONFIG_FILES(Makefile:Makefile.in)
22122d4d 253AC_OUTPUT
2f9bcf97
MM
254
255cat >&AC_FD_MSG <<EOF
256
257BIRD was configured with the following options:
b296730c
MM
258 Source directory: $srcdir
259 Object directory: $objdir
acc93efd 260 Iproute2 directory: $iproutedir
49e7e5ee 261 System configuration: $sysdesc
2f9bcf97 262 Debugging: $enable_debug
1ec52253 263 POSIX threads: $enable_pthreads
2f9bcf97 264 Routing protocols: $protocols
9fac310d 265 Client: $enable_client
2f9bcf97 266EOF
b296730c 267rm -f $objdir/.*-stamp