]> git.proxmox.com Git - mirror_iproute2.git/blob - configure
9912114438e908ffd0820876c69968c4db399a59
[mirror_iproute2.git] / configure
1 #! /bin/bash
2 # This is not an autconf generated configure
3 #
4 INCLUDE=${1:-"$PWD/include"}
5 : ${PKG_CONFIG:=pkg-config}
6 : ${CC=gcc}
7 echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
8
9 # Make a temp directory in build tree.
10 TMPDIR=$(mktemp -d config.XXXXXX)
11 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
12
13 check_atm()
14 {
15 cat >$TMPDIR/atmtest.c <<EOF
16 #include <atm.h>
17 int main(int argc, char **argv) {
18 struct atm_qos qos;
19 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
20 return 0;
21 }
22 EOF
23 $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
24 if [ $? -eq 0 ]
25 then
26 echo "TC_CONFIG_ATM:=y" >>Config
27 echo yes
28 else
29 echo no
30 fi
31 rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest
32 }
33
34 check_xt()
35 {
36 #check if we have xtables from iptables >= 1.4.5.
37 cat >$TMPDIR/ipttest.c <<EOF
38 #include <xtables.h>
39 #include <linux/netfilter.h>
40 static struct xtables_globals test_globals = {
41 .option_offset = 0,
42 .program_name = "tc-ipt",
43 .program_version = XTABLES_VERSION,
44 .orig_opts = NULL,
45 .opts = NULL,
46 .exit_err = NULL,
47 };
48
49 int main(int argc, char **argv)
50 {
51 xtables_init_all(&test_globals, NFPROTO_IPV4);
52 return 0;
53 }
54
55 EOF
56
57 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
58 then
59 echo "TC_CONFIG_XT:=y" >>Config
60 echo "using xtables"
61 fi
62 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
63 }
64
65 check_xt_old()
66 {
67 # bail if previous XT checks has already succeded.
68 if grep TC_CONFIG_XT Config > /dev/null
69 then
70 return
71 fi
72
73 #check if we dont need our internal header ..
74 cat >$TMPDIR/ipttest.c <<EOF
75 #include <xtables.h>
76 char *lib_dir;
77 unsigned int global_option_offset = 0;
78 const char *program_version = XTABLES_VERSION;
79 const char *program_name = "tc-ipt";
80 struct afinfo afinfo = {
81 .libprefix = "libxt_",
82 };
83
84 void exit_error(enum exittype status, const char *msg, ...)
85 {
86 }
87
88 int main(int argc, char **argv) {
89
90 return 0;
91 }
92
93 EOF
94 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
95
96 if [ $? -eq 0 ]
97 then
98 echo "TC_CONFIG_XT_OLD:=y" >>Config
99 echo "using old xtables (no need for xt-internal.h)"
100 fi
101 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
102 }
103
104 check_xt_old_internal_h()
105 {
106 # bail if previous XT checks has already succeded.
107 if grep TC_CONFIG_XT Config > /dev/null
108 then
109 return
110 fi
111
112 #check if we need our own internal.h
113 cat >$TMPDIR/ipttest.c <<EOF
114 #include <xtables.h>
115 #include "xt-internal.h"
116 char *lib_dir;
117 unsigned int global_option_offset = 0;
118 const char *program_version = XTABLES_VERSION;
119 const char *program_name = "tc-ipt";
120 struct afinfo afinfo = {
121 .libprefix = "libxt_",
122 };
123
124 void exit_error(enum exittype status, const char *msg, ...)
125 {
126 }
127
128 int main(int argc, char **argv) {
129
130 return 0;
131 }
132
133 EOF
134 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
135
136 if [ $? -eq 0 ]
137 then
138 echo "using old xtables with xt-internal.h"
139 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
140 fi
141 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
142 }
143
144 check_ipt()
145 {
146 if ! grep TC_CONFIG_XT Config > /dev/null
147 then
148 echo "using iptables"
149 fi
150 }
151
152 check_ipt_lib_dir()
153 {
154 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
155 if [ -n "$IPT_LIB_DIR" ]; then
156 echo $IPT_LIB_DIR
157 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
158 return
159 fi
160
161 for dir in /lib /usr/lib /usr/local/lib
162 do
163 for file in $dir/{xtables,iptables}/lib*t_*so ; do
164 if [ -f $file ]; then
165 echo ${file%/*}
166 echo "IPT_LIB_DIR:=${file%/*}" >> Config
167 return
168 fi
169 done
170 done
171 echo "not found!"
172 }
173
174 check_setns()
175 {
176 cat >$TMPDIR/setnstest.c <<EOF
177 #include <sched.h>
178 int main(int argc, char **argv)
179 {
180 (void)setns(0,0);
181 return 0;
182 }
183 EOF
184 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
185 if [ $? -eq 0 ]
186 then
187 echo "IP_CONFIG_SETNS:=y" >>Config
188 echo "yes"
189 else
190 echo "no"
191 fi
192 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
193 }
194
195 check_ipset()
196 {
197 cat >$TMPDIR/ipsettest.c <<EOF
198 #include <linux/netfilter/ipset/ip_set.h>
199 #ifndef IP_SET_INVALID
200 #define IPSET_DIM_MAX 3
201 typedef unsigned short ip_set_id_t;
202 #endif
203 #include <linux/netfilter/xt_set.h>
204
205 struct xt_set_info info;
206 #if IPSET_PROTOCOL == 6
207 int main(void)
208 {
209 return IPSET_MAXNAMELEN;
210 }
211 #else
212 #error unknown ipset version
213 #endif
214 EOF
215
216 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
217 then
218 echo "TC_CONFIG_IPSET:=y" >>Config
219 echo "yes"
220 else
221 echo "no"
222 fi
223 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
224 }
225
226 echo "# Generated config based on" $INCLUDE >Config
227
228 echo "TC schedulers"
229
230 echo -n " ATM "
231 check_atm
232
233 echo -n " IPT "
234 check_xt
235 check_xt_old
236 check_xt_old_internal_h
237 check_ipt
238
239 echo -n " IPSET "
240 check_ipset
241
242 echo -n "iptables modules directory: "
243 check_ipt_lib_dir
244
245 echo -n "libc has setns: "
246 check_setns