]> git.proxmox.com Git - mirror_iproute2.git/blob - configure
fix whitespace
[mirror_iproute2.git] / configure
1 #! /bin/bash
2 # This is not an autoconf 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_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
16 check_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
28 check_toolchain()
29 {
30 : ${PKG_CONFIG:=pkg-config}
31 : ${AR=ar}
32 : ${CC=gcc}
33 echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
34 echo "AR:=${AR}" >>Config
35 echo "CC:=${CC}" >>Config
36 }
37
38 check_atm()
39 {
40 cat >$TMPDIR/atmtest.c <<EOF
41 #include <atm.h>
42 int 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 }
47 EOF
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
58 }
59
60 check_xt()
61 {
62 #check if we have xtables from iptables >= 1.4.5.
63 cat >$TMPDIR/ipttest.c <<EOF
64 #include <xtables.h>
65 #include <linux/netfilter.h>
66 static 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
75 int main(int argc, char **argv)
76 {
77 xtables_init_all(&test_globals, NFPROTO_IPV4);
78 return 0;
79 }
80 EOF
81
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
85 echo "TC_CONFIG_XT:=y" >>Config
86 echo "using xtables"
87 fi
88 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
89 }
90
91 check_xt_old()
92 {
93 # bail if previous XT checks has already succeded.
94 if grep -q TC_CONFIG_XT Config
95 then
96 return
97 fi
98
99 #check if we dont need our internal header ..
100 cat >$TMPDIR/ipttest.c <<EOF
101 #include <xtables.h>
102 char *lib_dir;
103 unsigned int global_option_offset = 0;
104 const char *program_version = XTABLES_VERSION;
105 const char *program_name = "tc-ipt";
106 struct afinfo afinfo = {
107 .libprefix = "libxt_",
108 };
109
110 void exit_error(enum exittype status, const char *msg, ...)
111 {
112 }
113
114 int main(int argc, char **argv) {
115
116 return 0;
117 }
118
119 EOF
120
121 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
122 if [ $? -eq 0 ]
123 then
124 echo "TC_CONFIG_XT_OLD:=y" >>Config
125 echo "using old xtables (no need for xt-internal.h)"
126 fi
127 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
128 }
129
130 check_xt_old_internal_h()
131 {
132 # bail if previous XT checks has already succeded.
133 if grep -q TC_CONFIG_XT Config
134 then
135 return
136 fi
137
138 #check if we need our own internal.h
139 cat >$TMPDIR/ipttest.c <<EOF
140 #include <xtables.h>
141 #include "xt-internal.h"
142 char *lib_dir;
143 unsigned int global_option_offset = 0;
144 const char *program_version = XTABLES_VERSION;
145 const char *program_name = "tc-ipt";
146 struct afinfo afinfo = {
147 .libprefix = "libxt_",
148 };
149
150 void exit_error(enum exittype status, const char *msg, ...)
151 {
152 }
153
154 int main(int argc, char **argv) {
155
156 return 0;
157 }
158
159 EOF
160 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
161
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
168 }
169
170 check_ipt()
171 {
172 if ! grep TC_CONFIG_XT Config > /dev/null
173 then
174 echo "using iptables"
175 fi
176 }
177
178 check_ipt_lib_dir()
179 {
180 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
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
187 for dir in /lib /usr/lib /usr/local/lib
188 do
189 for file in $dir/{xtables,iptables}/lib*t_*so ; do
190 if [ -f $file ]; then
191 echo ${file%/*}
192 echo "IPT_LIB_DIR:=${file%/*}" >> Config
193 return
194 fi
195 done
196 done
197 echo "not found!"
198 }
199
200 check_setns()
201 {
202 cat >$TMPDIR/setnstest.c <<EOF
203 #include <sched.h>
204 int main(int argc, char **argv)
205 {
206 (void)setns(0,0);
207 return 0;
208 }
209 EOF
210 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
211 if [ $? -eq 0 ]
212 then
213 echo "IP_CONFIG_SETNS:=y" >>Config
214 echo "yes"
215 else
216 echo "no"
217 fi
218 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
219 }
220
221 check_ipset()
222 {
223 cat >$TMPDIR/ipsettest.c <<EOF
224 #include <linux/netfilter/ipset/ip_set.h>
225 #ifndef IP_SET_INVALID
226 #define IPSET_DIM_MAX 3
227 typedef unsigned short ip_set_id_t;
228 #endif
229 #include <linux/netfilter/xt_set.h>
230
231 struct xt_set_info info;
232 #if IPSET_PROTOCOL == 6
233 int main(void)
234 {
235 return IPSET_MAXNAMELEN;
236 }
237 #else
238 #error unknown ipset version
239 #endif
240 EOF
241
242 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
243 then
244 echo "TC_CONFIG_IPSET:=y" >>Config
245 echo "yes"
246 else
247 echo "no"
248 fi
249 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
250 }
251
252 check_selinux()
253 # SELinux is a compile time option in the ss utility
254 {
255 if ${PKG_CONFIG} libselinux --exists
256 then
257 echo "HAVE_SELINUX:=y" >>Config
258 echo "yes"
259 else
260 echo "no"
261 fi
262 }
263
264 echo "# Generated config based on" $INCLUDE >Config
265 check_toolchain
266
267 echo "TC schedulers"
268
269 echo -n " ATM "
270 check_atm
271
272 echo -n " IPT "
273 check_xt
274 check_xt_old
275 check_xt_old_internal_h
276 check_ipt
277
278 echo -n " IPSET "
279 check_ipset
280
281 echo -n -e "\niptables modules directory: "
282 check_ipt_lib_dir
283
284 echo -n "libc has setns: "
285 check_setns
286
287 echo -n "SELinux support: "
288 check_selinux
289
290 echo -e "\nDocs"
291 check_docs