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