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