blob: db7cd6a8843a3392bbf466acd42c5e23d26555b1 [file] [log] [blame]
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +00001#! /bin/bash
2# This is not an autconf generated configure
3#
osdl.net!shemminger4b1bbd92004-08-09 16:35:28 +00004INCLUDE=${1:-"$PWD/include"}
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +00005
Stephen Hemmingere557d1a2012-02-15 10:03:39 -08006# Make a temp directory in build tree.
7TMPDIR=$(mktemp -d config.XXXXXX)
8trap 'status=$?; rm -rf $TMPDIRa; exit $status' EXIT HUP INT QUIT TERM
9
Andreas Henriksson14743a72010-01-01 23:20:30 +010010check_atm()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000011{
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080012cat >$TMPDIR/atmtest.c <<EOF
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000013#include <atm.h>
14int main(int argc, char **argv) {
15 struct atm_qos qos;
16 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
17 return 0;
18}
19EOF
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080020gcc -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000021if [ $? -eq 0 ]
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000022then
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000023 echo "TC_CONFIG_ATM:=y" >>Config
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000024 echo yes
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000025else
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000026 echo no
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000027fi
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080028rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000029}
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050030
Andreas Henriksson14743a72010-01-01 23:20:30 +010031check_xt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000032{
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010033#check if we have xtables from iptables >= 1.4.5.
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080034cat >$TMPDIR/ipttest.c <<EOF
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010035#include <xtables.h>
36#include <linux/netfilter.h>
37static struct xtables_globals test_globals = {
38 .option_offset = 0,
39 .program_name = "tc-ipt",
40 .program_version = XTABLES_VERSION,
41 .orig_opts = NULL,
42 .opts = NULL,
43 .exit_err = NULL,
44};
45
46int main(int argc, char **argv)
47{
48 xtables_init_all(&test_globals, NFPROTO_IPV4);
49 return 0;
50}
51
52EOF
53
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080054if gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL $(pkg-config xtables --cflags --libs) -ldl >/dev/null 2>&1
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010055then
56 echo "TC_CONFIG_XT:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000057 echo "using xtables"
58fi
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080059rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000060}
61
Andreas Henriksson14743a72010-01-01 23:20:30 +010062check_xt_old()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000063{
64# bail if previous XT checks has already succeded.
65if grep TC_CONFIG_XT Config > /dev/null
66then
67 return
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010068fi
69
Gilles Espinasse4f69c632011-07-10 05:45:37 +000070#check if we dont need our internal header ..
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080071cat >$TMPDIR/ipttest.c <<EOF
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050072#include <xtables.h>
73char *lib_dir;
74unsigned int global_option_offset = 0;
75const char *program_version = XTABLES_VERSION;
76const char *program_name = "tc-ipt";
77struct afinfo afinfo = {
78 .libprefix = "libxt_",
79};
80
81void exit_error(enum exittype status, const char *msg, ...)
82{
83}
84
85int main(int argc, char **argv) {
86
87 return 0;
88}
89
90EOF
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080091gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050092
93if [ $? -eq 0 ]
94then
Andreas Henriksson80d689d2009-12-02 16:11:21 +010095 echo "TC_CONFIG_XT_OLD:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000096 echo "using old xtables (no need for xt-internal.h)"
97fi
Stephen Hemmingere557d1a2012-02-15 10:03:39 -080098rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000099}
100
Andreas Henriksson14743a72010-01-01 23:20:30 +0100101check_xt_old_internal_h()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000102{
103# bail if previous XT checks has already succeded.
104if grep TC_CONFIG_XT Config > /dev/null
105then
106 return
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500107fi
108
109#check if we need our own internal.h
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800110cat >$TMPDIR/ipttest.c <<EOF
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500111#include <xtables.h>
112#include "xt-internal.h"
113char *lib_dir;
114unsigned int global_option_offset = 0;
115const char *program_version = XTABLES_VERSION;
116const char *program_name = "tc-ipt";
117struct afinfo afinfo = {
118 .libprefix = "libxt_",
119};
120
121void exit_error(enum exittype status, const char *msg, ...)
122{
123}
124
125int main(int argc, char **argv) {
126
127 return 0;
128}
129
130EOF
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800131gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500132
133if [ $? -eq 0 ]
134then
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000135 echo "using old xtables with xt-internal.h"
Andreas Henriksson80d689d2009-12-02 16:11:21 +0100136 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500137fi
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800138rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000139}
140
Andreas Henriksson14743a72010-01-01 23:20:30 +0100141check_ipt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000142{
143 if ! grep TC_CONFIG_XT Config > /dev/null
144 then
145 echo "using iptables"
146 fi
147}
148
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000149check_ipt_lib_dir()
150{
Li Weida7fbb22012-08-20 09:41:47 +0800151 IPT_LIB_DIR=$(pkg-config --variable=xtlibdir xtables)
152 if [ -n "$IPT_LIB_DIR" ]; then
153 echo $IPT_LIB_DIR
154 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
155 return
156 fi
157
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000158 for dir in /lib /usr/lib /usr/local/lib
159 do
Dan McGee44e743e2011-07-15 08:52:24 +0000160 for file in $dir/{xtables,iptables}/lib*t_*so ; do
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000161 if [ -f $file ]; then
Dan McGee44e743e2011-07-15 08:52:24 +0000162 echo ${file%/*}
163 echo "IPT_LIB_DIR:=${file%/*}" >> Config
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000164 return
165 fi
166 done
167 done
168 echo "not found!"
169}
170
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000171check_setns()
172{
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800173cat >$TMPDIR/setnstest.c <<EOF
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000174#include <sched.h>
175int main(int argc, char **argv)
176{
177 (void)setns(0,0);
178 return 0;
179}
180EOF
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800181gcc -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000182if [ $? -eq 0 ]
183then
184 echo "IP_CONFIG_SETNS:=y" >>Config
185 echo "yes"
186else
187 echo "no"
188fi
Stephen Hemmingere557d1a2012-02-15 10:03:39 -0800189rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000190}
191
Florian Westphal81944112012-08-09 09:18:50 +0000192check_ipset()
193{
194cat >$TMPDIR/ipsettest.c <<EOF
195#include <linux/netfilter/ipset/ip_set.h>
196#ifndef IP_SET_INVALID
197#define IPSET_DIM_MAX 3
198typedef unsigned short ip_set_id_t;
199#endif
200#include <linux/netfilter/xt_set.h>
201
202struct xt_set_info info;
203#if IPSET_PROTOCOL == 6
204int main(void)
205{
206 return IPSET_MAXNAMELEN;
207}
208#else
209#error unknown ipset version
210#endif
211EOF
212
213if gcc -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
214then
215 echo "TC_CONFIG_IPSET:=y" >>Config
216 echo "yes"
217else
218 echo "no"
219fi
220rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
221}
222
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000223echo "# Generated config based on" $INCLUDE >Config
224
225echo "TC schedulers"
226
227echo -n " ATM "
228check_atm
229
230echo -n " IPT "
231check_xt
232check_xt_old
233check_xt_old_internal_h
234check_ipt
235
Florian Westphal81944112012-08-09 09:18:50 +0000236echo -n " IPSET "
237check_ipset
238
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000239echo -n "iptables modules directory: "
240check_ipt_lib_dir
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000241
242echo -n "libc has setns: "
243check_setns