]> git.proxmox.com Git - mirror_iproute2.git/blame - configure
netlink route attribute cleanup
[mirror_iproute2.git] / configure
CommitLineData
449bf1f3 1#! /bin/bash
07a6f5ec 2# This is not an autoconf generated configure
449bf1f3 3#
4b1bbd9c 4INCLUDE=${1:-"$PWD/include"}
449bf1f3 5
e557d1ac
SH
6# Make a temp directory in build tree.
7TMPDIR=$(mktemp -d config.XXXXXX)
c2f7d6c7 8trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
e557d1ac 9
10ed8b7f 10check_prog()
11{
12 echo -n "$2"
13 command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> Config; echo "yes") || (echo "no"; return 1)
14}
15
16check_docs()
17{
18 if check_prog latex " latex: " HAVE_LATEX; then
19 check_prog pdflatex " pdflatex: " HAVE_PDFLATEX || echo " WARNING: no PDF docs can be built from LaTeX files"
20 check_prog sgml2latex " sgml2latex: " HAVE_SGML2LATEX || echo " WARNING: no LaTeX files can be build from SGML files"
21 else
22 echo " WARNING: no docs can be built from LaTeX files"
23 fi
24
25 check_prog sgml2html " sgml2html: " HAVE_SGML2HTML || echo " WARNING: no HTML docs can be built from SGML"
26}
27
601f60e5
MF
28check_toolchain()
29{
07a6f5ec
SH
30 : ${PKG_CONFIG:=pkg-config}
31 : ${AR=ar}
32 : ${CC=gcc}
ae7b9a0d 33 echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
07a6f5ec
SH
34 echo "AR:=${AR}" >>Config
35 echo "CC:=${CC}" >>Config
601f60e5
MF
36}
37
14743a78 38check_atm()
f1a0125b 39{
07a6f5ec 40 cat >$TMPDIR/atmtest.c <<EOF
c830d77b
SH
41#include <atm.h>
42int main(int argc, char **argv) {
43 struct atm_qos qos;
44 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
45 return 0;
46}
47EOF
07a6f5ec
SH
48
49 $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
50 if [ $? -eq 0 ]
51 then
52 echo "TC_CONFIG_ATM:=y" >>Config
53 echo yes
54 else
55 echo no
56 fi
57 rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest
f1a0125b 58}
63c7d26f 59
4710e46e
DB
60check_xtables()
61{
62 if ! ${PKG_CONFIG} xtables --exists
63 then
64 echo "TC_CONFIG_NO_XT:=y" >>Config
65 fi
66}
67
14743a78 68check_xt()
f1a0125b 69{
07a6f5ec
SH
70 #check if we have xtables from iptables >= 1.4.5.
71 cat >$TMPDIR/ipttest.c <<EOF
a36ceb85
AH
72#include <xtables.h>
73#include <linux/netfilter.h>
74static struct xtables_globals test_globals = {
75 .option_offset = 0,
76 .program_name = "tc-ipt",
77 .program_version = XTABLES_VERSION,
78 .orig_opts = NULL,
79 .opts = NULL,
80 .exit_err = NULL,
81};
82
83int main(int argc, char **argv)
84{
85 xtables_init_all(&test_globals, NFPROTO_IPV4);
86 return 0;
87}
a36ceb85
AH
88EOF
89
07a6f5ec
SH
90 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
91 $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
92 then
a36ceb85 93 echo "TC_CONFIG_XT:=y" >>Config
f1a0125b 94 echo "using xtables"
07a6f5ec
SH
95 fi
96 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
97}
98
14743a78 99check_xt_old()
f1a0125b 100{
07a6f5ec
SH
101 # bail if previous XT checks has already succeded.
102 if grep -q TC_CONFIG_XT Config
103 then
f1a0125b 104 return
07a6f5ec 105 fi
a36ceb85 106
07a6f5ec
SH
107 #check if we dont need our internal header ..
108 cat >$TMPDIR/ipttest.c <<EOF
63c7d26f
JHS
109#include <xtables.h>
110char *lib_dir;
111unsigned int global_option_offset = 0;
112const char *program_version = XTABLES_VERSION;
113const char *program_name = "tc-ipt";
114struct afinfo afinfo = {
115 .libprefix = "libxt_",
116};
117
118void exit_error(enum exittype status, const char *msg, ...)
119{
120}
121
122int main(int argc, char **argv) {
123
124 return 0;
125}
126
127EOF
63c7d26f 128
07a6f5ec
SH
129 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
130 if [ $? -eq 0 ]
131 then
80d689d0 132 echo "TC_CONFIG_XT_OLD:=y" >>Config
f1a0125b 133 echo "using old xtables (no need for xt-internal.h)"
07a6f5ec
SH
134 fi
135 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
136}
137
14743a78 138check_xt_old_internal_h()
f1a0125b 139{
07a6f5ec
SH
140 # bail if previous XT checks has already succeded.
141 if grep -q TC_CONFIG_XT Config
142 then
f1a0125b 143 return
07a6f5ec 144 fi
63c7d26f 145
07a6f5ec
SH
146 #check if we need our own internal.h
147 cat >$TMPDIR/ipttest.c <<EOF
63c7d26f
JHS
148#include <xtables.h>
149#include "xt-internal.h"
150char *lib_dir;
151unsigned int global_option_offset = 0;
152const char *program_version = XTABLES_VERSION;
153const char *program_name = "tc-ipt";
154struct afinfo afinfo = {
155 .libprefix = "libxt_",
156};
157
158void exit_error(enum exittype status, const char *msg, ...)
159{
160}
161
162int main(int argc, char **argv) {
163
164 return 0;
165}
166
167EOF
07a6f5ec 168 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
63c7d26f 169
07a6f5ec
SH
170 if [ $? -eq 0 ]
171 then
172 echo "using old xtables with xt-internal.h"
173 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
174 fi
175 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
176}
177
14743a78 178check_ipt()
f1a0125b
AH
179{
180 if ! grep TC_CONFIG_XT Config > /dev/null
181 then
182 echo "using iptables"
183 fi
184}
185
12ddfff7
AH
186check_ipt_lib_dir()
187{
e4fc4ada 188 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
da7fbb24
LW
189 if [ -n "$IPT_LIB_DIR" ]; then
190 echo $IPT_LIB_DIR
191 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
192 return
193 fi
194
12ddfff7
AH
195 for dir in /lib /usr/lib /usr/local/lib
196 do
44e743e5 197 for file in $dir/{xtables,iptables}/lib*t_*so ; do
12ddfff7 198 if [ -f $file ]; then
44e743e5
DM
199 echo ${file%/*}
200 echo "IPT_LIB_DIR:=${file%/*}" >> Config
12ddfff7
AH
201 return
202 fi
203 done
204 done
205 echo "not found!"
206}
207
2e8a07f5
EB
208check_setns()
209{
07a6f5ec 210 cat >$TMPDIR/setnstest.c <<EOF
2e8a07f5 211#include <sched.h>
d116ff34 212int main(int argc, char **argv)
2e8a07f5
EB
213{
214 (void)setns(0,0);
215 return 0;
216}
217EOF
07a6f5ec
SH
218 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
219 if [ $? -eq 0 ]
220 then
2e8a07f5
EB
221 echo "IP_CONFIG_SETNS:=y" >>Config
222 echo "yes"
07a6f5ec 223 else
2e8a07f5 224 echo "no"
07a6f5ec
SH
225 fi
226 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
2e8a07f5
EB
227}
228
8194411a
FW
229check_ipset()
230{
07a6f5ec 231 cat >$TMPDIR/ipsettest.c <<EOF
8194411a
FW
232#include <linux/netfilter/ipset/ip_set.h>
233#ifndef IP_SET_INVALID
234#define IPSET_DIM_MAX 3
235typedef unsigned short ip_set_id_t;
236#endif
237#include <linux/netfilter/xt_set.h>
238
239struct xt_set_info info;
240#if IPSET_PROTOCOL == 6
241int main(void)
242{
243 return IPSET_MAXNAMELEN;
244}
245#else
246#error unknown ipset version
247#endif
248EOF
249
07a6f5ec
SH
250 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
251 then
8194411a
FW
252 echo "TC_CONFIG_IPSET:=y" >>Config
253 echo "yes"
07a6f5ec 254 else
8194411a 255 echo "no"
07a6f5ec
SH
256 fi
257 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
8194411a
FW
258}
259
11c39b5e
DB
260check_elf()
261{
262 cat >$TMPDIR/elftest.c <<EOF
263#include <libelf.h>
264#include <gelf.h>
265int main(void)
266{
9f9ccc89
SH
267 Elf_Scn *scn __attribute__((__unused__));
268 GElf_Shdr shdr __attribute__((__unused__));;
11c39b5e
DB
269 return elf_version(EV_CURRENT);
270}
271EOF
272
273 if $CC -I$INCLUDE -o $TMPDIR/elftest $TMPDIR/elftest.c -lelf >/dev/null 2>&1
274 then
e4225669 275 echo "HAVE_ELF:=y" >>Config
11c39b5e
DB
276 echo "yes"
277 else
278 echo "no"
279 fi
280 rm -f $TMPDIR/elftest.c $TMPDIR/elftest
281}
282
116ac927
RH
283check_selinux()
284# SELinux is a compile time option in the ss utility
285{
286 if ${PKG_CONFIG} libselinux --exists
287 then
288 echo "HAVE_SELINUX:=y" >>Config
289 echo "yes"
290 else
291 echo "no"
292 fi
293}
294
b6907403
VK
295check_mnl()
296{
297 if ${PKG_CONFIG} libmnl --exists
298 then
299 echo "HAVE_MNL:=y" >>Config
a25df488 300 echo "yes"
b6907403 301 else
a25df488 302 echo "no"
b6907403
VK
303 fi
304}
305
a25df488
VK
306check_berkeley_db()
307{
308 cat >$TMPDIR/dbtest.c <<EOF
309#include <fcntl.h>
310#include <stdlib.h>
311#include <db_185.h>
312int main(int argc, char **argv) {
313 dbopen("/tmp/xxx_test_db.db", O_CREAT|O_RDWR, 0644, DB_HASH, NULL);
314 return 0;
315}
316EOF
317 $CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1
318 if [ $? -eq 0 ]
319 then
320 echo "HAVE_BERKELEY_DB:=y" >>Config
321 echo "yes"
322 else
323 echo "no"
324 fi
325 rm -f $TMPDIR/dbtest.c $TMPDIR/dbtest
326}
327
57bdf8b7
DA
328quiet_config()
329{
330 cat <<EOF
331# user can control verbosity similar to kernel builds (e.g., V=1)
332ifeq ("\$(origin V)", "command line")
333 VERBOSE = \$(V)
334endif
335ifndef VERBOSE
336 VERBOSE = 0
337endif
338ifeq (\$(VERBOSE),1)
339 Q =
340else
341 Q = @
342endif
343
344ifeq (\$(VERBOSE), 0)
345 QUIET_CC = @echo ' CC '\$@;
346 QUIET_AR = @echo ' AR '\$@;
347 QUIET_LINK = @echo ' LINK '\$@;
348 QUIET_YACC = @echo ' YACC '\$@;
349 QUIET_LEX = @echo ' LEX '\$@;
350endif
351EOF
352}
353
f1a0125b 354echo "# Generated config based on" $INCLUDE >Config
57bdf8b7
DA
355quiet_config >> Config
356
601f60e5 357check_toolchain
f1a0125b
AH
358
359echo "TC schedulers"
360
361echo -n " ATM "
362check_atm
363
4710e46e
DB
364check_xtables
365if ! grep -q TC_CONFIG_NO_XT Config
366then
367 echo -n " IPT "
368 check_xt
369 check_xt_old
370 check_xt_old_internal_h
371 check_ipt
f1a0125b 372
4710e46e
DB
373 echo -n " IPSET "
374 check_ipset
375fi
8194411a 376
aaf70458 377echo
4710e46e
DB
378if ! grep -q TC_CONFIG_NO_XT Config
379then
380 echo -n "iptables modules directory: "
381 check_ipt_lib_dir
382fi
2e8a07f5
EB
383
384echo -n "libc has setns: "
385check_setns
116ac927
RH
386
387echo -n "SELinux support: "
388check_selinux
10ed8b7f 389
11c39b5e
DB
390echo -n "ELF support: "
391check_elf
392
b6907403
VK
393echo -n "libmnl support: "
394check_mnl
b6907403 395
a25df488
VK
396echo -n "Berkeley DB: "
397check_berkeley_db
398
aaf70458
SH
399echo
400echo -n "docs:"
10ed8b7f 401check_docs
aaf70458 402echo
57bdf8b7
DA
403
404echo >> Config
405echo "%.o: %.c" >> Config
406echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<' >> Config