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