]> git.proxmox.com Git - mirror_iproute2.git/blame - configure
update kernel headers to net-next 4.0-rc5
[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
14743a78 60check_xt()
f1a0125b 61{
07a6f5ec
SH
62 #check if we have xtables from iptables >= 1.4.5.
63 cat >$TMPDIR/ipttest.c <<EOF
a36ceb85
AH
64#include <xtables.h>
65#include <linux/netfilter.h>
66static struct xtables_globals test_globals = {
67 .option_offset = 0,
68 .program_name = "tc-ipt",
69 .program_version = XTABLES_VERSION,
70 .orig_opts = NULL,
71 .opts = NULL,
72 .exit_err = NULL,
73};
74
75int main(int argc, char **argv)
76{
77 xtables_init_all(&test_globals, NFPROTO_IPV4);
78 return 0;
79}
a36ceb85
AH
80EOF
81
07a6f5ec
SH
82 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
83 $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
84 then
a36ceb85 85 echo "TC_CONFIG_XT:=y" >>Config
f1a0125b 86 echo "using xtables"
07a6f5ec
SH
87 fi
88 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
89}
90
14743a78 91check_xt_old()
f1a0125b 92{
07a6f5ec
SH
93 # bail if previous XT checks has already succeded.
94 if grep -q TC_CONFIG_XT Config
95 then
f1a0125b 96 return
07a6f5ec 97 fi
a36ceb85 98
07a6f5ec
SH
99 #check if we dont need our internal header ..
100 cat >$TMPDIR/ipttest.c <<EOF
63c7d26f
JHS
101#include <xtables.h>
102char *lib_dir;
103unsigned int global_option_offset = 0;
104const char *program_version = XTABLES_VERSION;
105const char *program_name = "tc-ipt";
106struct afinfo afinfo = {
107 .libprefix = "libxt_",
108};
109
110void exit_error(enum exittype status, const char *msg, ...)
111{
112}
113
114int main(int argc, char **argv) {
115
116 return 0;
117}
118
119EOF
63c7d26f 120
07a6f5ec
SH
121 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
122 if [ $? -eq 0 ]
123 then
80d689d0 124 echo "TC_CONFIG_XT_OLD:=y" >>Config
f1a0125b 125 echo "using old xtables (no need for xt-internal.h)"
07a6f5ec
SH
126 fi
127 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
128}
129
14743a78 130check_xt_old_internal_h()
f1a0125b 131{
07a6f5ec
SH
132 # bail if previous XT checks has already succeded.
133 if grep -q TC_CONFIG_XT Config
134 then
f1a0125b 135 return
07a6f5ec 136 fi
63c7d26f 137
07a6f5ec
SH
138 #check if we need our own internal.h
139 cat >$TMPDIR/ipttest.c <<EOF
63c7d26f
JHS
140#include <xtables.h>
141#include "xt-internal.h"
142char *lib_dir;
143unsigned int global_option_offset = 0;
144const char *program_version = XTABLES_VERSION;
145const char *program_name = "tc-ipt";
146struct afinfo afinfo = {
147 .libprefix = "libxt_",
148};
149
150void exit_error(enum exittype status, const char *msg, ...)
151{
152}
153
154int main(int argc, char **argv) {
155
156 return 0;
157}
158
159EOF
07a6f5ec 160 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
63c7d26f 161
07a6f5ec
SH
162 if [ $? -eq 0 ]
163 then
164 echo "using old xtables with xt-internal.h"
165 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
166 fi
167 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
f1a0125b
AH
168}
169
14743a78 170check_ipt()
f1a0125b
AH
171{
172 if ! grep TC_CONFIG_XT Config > /dev/null
173 then
174 echo "using iptables"
175 fi
176}
177
12ddfff7
AH
178check_ipt_lib_dir()
179{
e4fc4ada 180 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
da7fbb24
LW
181 if [ -n "$IPT_LIB_DIR" ]; then
182 echo $IPT_LIB_DIR
183 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
184 return
185 fi
186
12ddfff7
AH
187 for dir in /lib /usr/lib /usr/local/lib
188 do
44e743e5 189 for file in $dir/{xtables,iptables}/lib*t_*so ; do
12ddfff7 190 if [ -f $file ]; then
44e743e5
DM
191 echo ${file%/*}
192 echo "IPT_LIB_DIR:=${file%/*}" >> Config
12ddfff7
AH
193 return
194 fi
195 done
196 done
197 echo "not found!"
198}
199
2e8a07f5
EB
200check_setns()
201{
07a6f5ec 202 cat >$TMPDIR/setnstest.c <<EOF
2e8a07f5 203#include <sched.h>
d116ff34 204int main(int argc, char **argv)
2e8a07f5
EB
205{
206 (void)setns(0,0);
207 return 0;
208}
209EOF
07a6f5ec
SH
210 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
211 if [ $? -eq 0 ]
212 then
2e8a07f5
EB
213 echo "IP_CONFIG_SETNS:=y" >>Config
214 echo "yes"
07a6f5ec 215 else
2e8a07f5 216 echo "no"
07a6f5ec
SH
217 fi
218 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
2e8a07f5
EB
219}
220
d116ff34
VK
221check_netnsid()
222{
223 cat >$TMPDIR/netnsid.c <<EOF
224#include <linux/rtnetlink.h>
225int test_def = RTM_GETNSID;
226EOF
227 $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
228 if [ $? -eq 0 ]
229 then
230 echo "IP_CONFIG_NETNSID:=y" >> Config
231 echo "yes"
232 else
233 echo "no"
234 fi
235 rm -f $TMPDIR/netnsid.c $TMPDIR/netnsid.o
236}
237
8194411a
FW
238check_ipset()
239{
07a6f5ec 240 cat >$TMPDIR/ipsettest.c <<EOF
8194411a
FW
241#include <linux/netfilter/ipset/ip_set.h>
242#ifndef IP_SET_INVALID
243#define IPSET_DIM_MAX 3
244typedef unsigned short ip_set_id_t;
245#endif
246#include <linux/netfilter/xt_set.h>
247
248struct xt_set_info info;
249#if IPSET_PROTOCOL == 6
250int main(void)
251{
252 return IPSET_MAXNAMELEN;
253}
254#else
255#error unknown ipset version
256#endif
257EOF
258
07a6f5ec
SH
259 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
260 then
8194411a
FW
261 echo "TC_CONFIG_IPSET:=y" >>Config
262 echo "yes"
07a6f5ec 263 else
8194411a 264 echo "no"
07a6f5ec
SH
265 fi
266 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
8194411a
FW
267}
268
116ac927
RH
269check_selinux()
270# SELinux is a compile time option in the ss utility
271{
272 if ${PKG_CONFIG} libselinux --exists
273 then
274 echo "HAVE_SELINUX:=y" >>Config
275 echo "yes"
276 else
277 echo "no"
278 fi
279}
280
f1a0125b 281echo "# Generated config based on" $INCLUDE >Config
601f60e5 282check_toolchain
f1a0125b
AH
283
284echo "TC schedulers"
285
286echo -n " ATM "
287check_atm
288
289echo -n " IPT "
290check_xt
291check_xt_old
292check_xt_old_internal_h
293check_ipt
294
8194411a
FW
295echo -n " IPSET "
296check_ipset
297
10ed8b7f 298echo -n -e "\niptables modules directory: "
12ddfff7 299check_ipt_lib_dir
2e8a07f5
EB
300
301echo -n "libc has setns: "
302check_setns
d116ff34
VK
303echo -n "netns has peer id suport: "
304check_netnsid
116ac927
RH
305
306echo -n "SELinux support: "
307check_selinux
10ed8b7f 308
309echo -e "\nDocs"
310check_docs