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