]> git.ipfire.org Git - thirdparty/bird.git/blame - configure.in
Merge branch 'master' into dev
[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
c0760ab0 9AC_ARG_ENABLE(debug,[ --enable-debug enable internal debugging routines (default: disabled)],,enable_debug=no)
6b5ab875 10AC_ARG_ENABLE(memcheck,[ --enable-memcheck check memory allocations when debugging (default: enabled)],,enable_memcheck=yes)
c817b991 11AC_ARG_ENABLE(warnings,[ --enable-warnings enable extra warnings (default: disabled)],,enable_warnings=no)
9fac310d 12AC_ARG_ENABLE(client,[ --enable-client enable building of BIRD client (default: enabled)],,enable_client=yes)
c817b991 13AC_ARG_ENABLE(ipv6,[ --enable-ipv6 enable building of IPv6 version (default: disabled)],,enable_ipv6=no)
2f9bcf97 14AC_ARG_WITH(sysconfig,[ --with-sysconfig=FILE use specified BIRD system configuration file])
c817b991 15AC_ARG_WITH(protocols,[ --with-protocols=LIST include specified routing protocols (default: all)],,[with_protocols="all"])
a07e9d82 16AC_ARG_WITH(sysinclude,[ --with-sysinclude=PATH search for system includes on specified place])
2f9bcf97 17
49e7e5ee
MM
18if test "$srcdir" = . ; then
19 # Building in current directory => create obj directory holding all objects
20 objdir=obj
21 mkdir -p obj
22 srcdir_rel=..
23 makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
24 exedir=..
25else
26 # Building in separate directory
27 objdir=.
28 srcdir_rel=$srcdir
29 makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
30 exedir=.
31fi
32case $srcdir_rel in
33 /*) srcdir_rel_mf=$srcdir_rel ;;
34 *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
35esac
36AC_SUBST(objdir)
37AC_SUBST(exedir)
38AC_SUBST(srcdir_rel_mf)
39
c817b991
MM
40if test "$enable_ipv6" = yes ; then
41 ip=ipv6
42 if test "$with_protocols" = all ; then
43 with_protocols=bgp,pipe,rip,static
44 fi
45else
46 ip=ipv4
47 if test "$with_protocols" = all ; then
48 with_protocols=bgp,ospf,pipe,rip,static
49 fi
50fi
51
08cca48a 52AC_SEARCH_LIBS(clock_gettime,[c rt posix4])
fd91ae33 53
2f9bcf97 54AC_CANONICAL_HOST
416e3ee4
MM
55
56AC_PROG_CC
57if test -z "$GCC" ; then
58 AC_MSG_ERROR([This program requires the GNU C Compiler.])
59 fi
60AC_MSG_CHECKING([what CFLAGS should we use])
61if test "$ac_test_CFLAGS" != set ; then
62 if test "$enable_warnings" = yes ; then
54c411f6 63 WARNS=" -Wmissing-prototypes -Wundef"
416e3ee4
MM
64 else
65 WARNS=" -Wno-unused"
66 fi
baa9ef18 67 CFLAGS="$CFLAGS -Wall -W -Wstrict-prototypes -Wno-pointer-sign -Wno-parentheses$WARNS"
416e3ee4
MM
68fi
69if test "$with_sysinclude" != no -a -n "$with_sysinclude"; then
70 CPPFLAGS="$CPPFLAGS -I$with_sysinclude"
71fi
72AC_MSG_RESULT($CFLAGS)
73
74AC_PROG_CPP
75AC_PROG_INSTALL
76AC_PROG_RANLIB
77AC_CHECK_PROG(FLEX, flex, flex)
78AC_CHECK_PROG(BISON, bison, bison)
79AC_CHECK_PROGS(M4, gm4 m4, m4)
80if test -z "$FLEX" -o -z "$BISON" -o -z "$M4" ; then
81 AC_MSG_ERROR([Some tools required for building BIRD are missing.])
82 fi
83
2f9bcf97 84if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
2f9bcf97 85 if test -f $with_sysconfig ; then
49e7e5ee 86 sysdesc=$with_sysconfig
2f9bcf97 87 else
49e7e5ee
MM
88 sysdesc=$srcdir/sysdep/cf/$with_sysconfig
89 if ! test -f $sysdesc ; then
90 sysdesc=$sysdesc.h
91 fi
2f9bcf97
MM
92 fi
93elif test -f sysconfig.h ; then
49e7e5ee 94 sysdesc=sysconfig
2f9bcf97 95else
c817b991 96 case "$ip:$host_os" in
416e3ee4
MM
97 ipv4:linux*) BIRD_CHECK_LINUX_VERSION
98 case $bird_cv_sys_linux_version in
1127ac6e 99 1.*|2.0.*) sysdesc=linux-20 ;;
f2ed663a 100 *) sysdesc=linux-22 ;;
1127ac6e
MM
101 esac
102 ;;
416e3ee4
MM
103 ipv6:linux*) BIRD_CHECK_LINUX_VERSION
104 case $bird_cv_sys_linux_version in
105 1.*|2.0.*) AC_MSG_ERROR([This version of Linux doesn't support IPv6.]) ;;
106 *) sysdesc=linux-v6 ;;
107 esac
c817b991 108 ;;
7cb37e6f
OF
109 ipv6:netbsd*) sysdesc=bsd-v6
110 ;;
111 ipv4:netbsd*) sysdesc=bsd
112 ;;
113 ipv6:freebsd*) sysdesc=bsd-v6
114 ;;
115 ipv4:freebsd*) sysdesc=bsd
116 ;;
ef9c9ab9
OF
117 ipv6:openbsd*) sysdesc=bsd-v6
118 ;;
119 ipv4:openbsd*) sysdesc=bsd
120 ;;
416e3ee4 121 *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.])
2f9bcf97
MM
122 ;;
123 esac
49e7e5ee 124 sysdesc=$srcdir/sysdep/cf/$sysdesc.h
2f9bcf97 125fi
416e3ee4 126AC_MSG_CHECKING([which OS configuration should we use])
49e7e5ee
MM
127AC_MSG_RESULT($sysdesc)
128if ! test -f $sysdesc ; then
2f9bcf97
MM
129 AC_MSG_ERROR([The system configuration file is missing.])
130fi
49e7e5ee
MM
131sysname=`echo $sysdesc | sed 's/\.h$//'`
132AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
133
134AC_MSG_CHECKING([system-dependent directories])
135sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
136AC_MSG_RESULT($sysdep_dirs)
137AC_SUBST(sysdep_dirs)
2f9bcf97
MM
138
139AC_MSG_CHECKING([protocols])
140protocols=`echo "$with_protocols" | sed 's/,/ /g'`
b296730c 141if test "$protocols" = no ; then protocols= ; fi
2f9bcf97
MM
142for a in $protocols ; do
143 if ! test -f $srcdir/proto/$a/Makefile ; then
144 AC_MSG_RESULT(failed)
145 AC_MSG_ERROR([Requested protocol $a not found.])
146 fi
147 AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
148 done
149AC_MSG_RESULT(ok)
49e7e5ee 150AC_SUBST(protocols)
2f9bcf97 151
a07e9d82 152case $sysdesc in
c817b991 153 */linux-22*|*/linux-v6*)
9f387e11
MM
154 AC_CHECK_HEADER(linux/rtnetlink.h,,[AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])],[
155#include <asm/types.h>
156#include <sys/socket.h>
157])
c817b991 158 ;;
a07e9d82
MM
159esac
160
2f9bcf97 161AC_CHECK_HEADER(syslog.h, [AC_DEFINE(HAVE_SYSLOG)])
7cb37e6f
OF
162AC_CHECK_HEADER(alloca.h, [AC_DEFINE(HAVE_ALLOCA_H)])
163AC_MSG_CHECKING(whether 'struct sockaddr' has sa_len)
164AC_TRY_COMPILE([#include <sys/types.h>
165 #include <sys/socket.h>
166 ], [static struct sockaddr sa; int i = sizeof(sa.sa_len);],
167 [AC_MSG_RESULT(yes)
168 AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
169 AC_MSG_RESULT(no))
2f9bcf97
MM
170
171BIRD_CHECK_INTEGERS
172BIRD_CHECK_ENDIAN
173BIRD_CHECK_STRUCT_ALIGN
174BIRD_CHECK_TIME_T
620c4f90 175BIRD_CHECK_STRUCT_IP_MREQN
2f9bcf97
MM
176
177if test "$enable_debug" = yes ; then
2f9bcf97 178 AC_DEFINE(DEBUGGING)
6b5ab875
MM
179 if test "$enable_memcheck" = yes ; then
180 AC_CHECK_LIB(dmalloc, dmalloc_debug)
181 if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
182 AC_CHECK_LIB(efence, malloc)
183 fi
7a2105be 184 fi
2f9bcf97
MM
185fi
186
7211be1c
MM
187CLIENT=
188CLIENT_LIBS=
9fac310d
MM
189if test "$enable_client" = yes ; then
190 CLIENT=client
7211be1c
MM
191 AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
192 AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses,
193 AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses,
194 AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap)))
1d4ba658 195 AC_CHECK_LIB(readline, rl_callback_read_char, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB",
df0cf75d 196 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
197 AC_CHECK_LIB(readline, rl_crlf, AC_DEFINE(HAVE_RL_CRLF),,$USE_TERMCAP_LIB)
198 AC_CHECK_LIB(readline, rl_ding, AC_DEFINE(HAVE_RL_DING),,$USE_TERMCAP_LIB)
9fac310d
MM
199fi
200AC_SUBST(CLIENT)
7211be1c 201AC_SUBST(CLIENT_LIBS)
9fac310d 202
54165b13 203mkdir -p $objdir/sysdep
7cb37e6f 204AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in])
22122d4d
OF
205AC_CONFIG_COMMANDS([merge],[[export CPP="$CPP"
206$srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs]],
207 [[srcdir=$srcdir]
208 [srcdir_rel=$srcdir_rel]
209 [objdir=$objdir]
210 [sysdep_dirs="$sysdep_dirs"]])
211AC_CONFIG_FILES($makefiles)
212AC_OUTPUT
2f9bcf97
MM
213
214cat >&AC_FD_MSG <<EOF
215
216BIRD was configured with the following options:
b296730c
MM
217 Source directory: $srcdir
218 Object directory: $objdir
49e7e5ee 219 System configuration: $sysdesc
2f9bcf97
MM
220 Debugging: $enable_debug
221 Routing protocols: $protocols
9fac310d 222 Client: $enable_client
2f9bcf97 223EOF
b296730c 224rm -f $objdir/.*-stamp