blob: 0795df85166a3ec6a16b722ae4063345d4892943 [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
Andreas Henriksson14743a72010-01-01 23:20:30 +01006check_atm()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +00007{
osdl.net!shemmingerc830d772004-07-02 17:47:53 +00008cat >/tmp/atmtest.c <<EOF
9#include <atm.h>
10int main(int argc, char **argv) {
11 struct atm_qos qos;
12 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
13 return 0;
14}
15EOF
osdl.net!shemminger2979d522004-07-30 20:24:59 +000016gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000017if [ $? -eq 0 ]
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000018then
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000019 echo "TC_CONFIG_ATM:=y" >>Config
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000020 echo yes
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000021else
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000022 echo no
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000023fi
osdl.net!shemminger2979d522004-07-30 20:24:59 +000024rm -f /tmp/atmtest.c /tmp/atmtest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000025}
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050026
Andreas Henriksson14743a72010-01-01 23:20:30 +010027check_xt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000028{
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010029#check if we have xtables from iptables >= 1.4.5.
30cat >/tmp/ipttest.c <<EOF
31#include <xtables.h>
32#include <linux/netfilter.h>
33static struct xtables_globals test_globals = {
34 .option_offset = 0,
35 .program_name = "tc-ipt",
36 .program_version = XTABLES_VERSION,
37 .orig_opts = NULL,
38 .opts = NULL,
39 .exit_err = NULL,
40};
41
42int main(int argc, char **argv)
43{
44 xtables_init_all(&test_globals, NFPROTO_IPV4);
45 return 0;
46}
47
48EOF
49
50if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1
51then
52 echo "TC_CONFIG_XT:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000053 echo "using xtables"
54fi
55rm -f /tmp/ipttest.c /tmp/ipttest
56}
57
Andreas Henriksson14743a72010-01-01 23:20:30 +010058check_xt_old()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000059{
60# bail if previous XT checks has already succeded.
61if grep TC_CONFIG_XT Config > /dev/null
62then
63 return
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010064fi
65
Gilles Espinasse4f69c632011-07-10 05:45:37 +000066#check if we dont need our internal header ..
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050067cat >/tmp/ipttest.c <<EOF
68#include <xtables.h>
69char *lib_dir;
70unsigned int global_option_offset = 0;
71const char *program_version = XTABLES_VERSION;
72const char *program_name = "tc-ipt";
73struct afinfo afinfo = {
74 .libprefix = "libxt_",
75};
76
77void exit_error(enum exittype status, const char *msg, ...)
78{
79}
80
81int main(int argc, char **argv) {
82
83 return 0;
84}
85
86EOF
87gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
88
89if [ $? -eq 0 ]
90then
Andreas Henriksson80d689d2009-12-02 16:11:21 +010091 echo "TC_CONFIG_XT_OLD:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000092 echo "using old xtables (no need for xt-internal.h)"
93fi
94rm -f /tmp/ipttest.c /tmp/ipttest
95}
96
Andreas Henriksson14743a72010-01-01 23:20:30 +010097check_xt_old_internal_h()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000098{
99# bail if previous XT checks has already succeded.
100if grep TC_CONFIG_XT Config > /dev/null
101then
102 return
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500103fi
104
105#check if we need our own internal.h
106cat >/tmp/ipttest.c <<EOF
107#include <xtables.h>
108#include "xt-internal.h"
109char *lib_dir;
110unsigned int global_option_offset = 0;
111const char *program_version = XTABLES_VERSION;
112const char *program_name = "tc-ipt";
113struct afinfo afinfo = {
114 .libprefix = "libxt_",
115};
116
117void exit_error(enum exittype status, const char *msg, ...)
118{
119}
120
121int main(int argc, char **argv) {
122
123 return 0;
124}
125
126EOF
127gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
128
129if [ $? -eq 0 ]
130then
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000131 echo "using old xtables with xt-internal.h"
Andreas Henriksson80d689d2009-12-02 16:11:21 +0100132 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500133fi
134rm -f /tmp/ipttest.c /tmp/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000135}
136
Andreas Henriksson14743a72010-01-01 23:20:30 +0100137check_ipt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000138{
139 if ! grep TC_CONFIG_XT Config > /dev/null
140 then
141 echo "using iptables"
142 fi
143}
144
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000145check_ipt_lib_dir()
146{
147 IPT_LIB_DIR=""
148 for dir in /lib /usr/lib /usr/local/lib
149 do
Dan McGee44e743e2011-07-15 08:52:24 +0000150 for file in $dir/{xtables,iptables}/lib*t_*so ; do
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000151 if [ -f $file ]; then
Dan McGee44e743e2011-07-15 08:52:24 +0000152 echo ${file%/*}
153 echo "IPT_LIB_DIR:=${file%/*}" >> Config
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000154 return
155 fi
156 done
157 done
158 echo "not found!"
159}
160
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000161echo "# Generated config based on" $INCLUDE >Config
162
163echo "TC schedulers"
164
165echo -n " ATM "
166check_atm
167
168echo -n " IPT "
169check_xt
170check_xt_old
171check_xt_old_internal_h
172check_ipt
173
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000174echo -n "iptables modules directory: "
175check_ipt_lib_dir