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