blob: 600fa96cefc56a40ddf6122852469586e5ac49bb [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 Henriksson12ddfff2010-03-11 10:54:31 +00006TABLES=
7
Andreas Henriksson14743a72010-01-01 23:20:30 +01008check_atm()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +00009{
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000010cat >/tmp/atmtest.c <<EOF
11#include <atm.h>
12int main(int argc, char **argv) {
13 struct atm_qos qos;
14 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
15 return 0;
16}
17EOF
osdl.net!shemminger2979d522004-07-30 20:24:59 +000018gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000019if [ $? -eq 0 ]
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000020then
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000021 echo "TC_CONFIG_ATM:=y" >>Config
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000022 echo yes
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000023else
osdl.net!shemmingerb9cb1c92004-07-30 22:27:50 +000024 echo no
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +000025fi
osdl.net!shemminger2979d522004-07-30 20:24:59 +000026rm -f /tmp/atmtest.c /tmp/atmtest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000027}
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050028
Andreas Henriksson14743a72010-01-01 23:20:30 +010029check_xt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000030{
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010031#check if we have xtables from iptables >= 1.4.5.
32cat >/tmp/ipttest.c <<EOF
33#include <xtables.h>
34#include <linux/netfilter.h>
35static struct xtables_globals test_globals = {
36 .option_offset = 0,
37 .program_name = "tc-ipt",
38 .program_version = XTABLES_VERSION,
39 .orig_opts = NULL,
40 .opts = NULL,
41 .exit_err = NULL,
42};
43
44int main(int argc, char **argv)
45{
46 xtables_init_all(&test_globals, NFPROTO_IPV4);
47 return 0;
48}
49
50EOF
51
52if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1
53then
54 echo "TC_CONFIG_XT:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000055 echo "using xtables"
56fi
57rm -f /tmp/ipttest.c /tmp/ipttest
58}
59
Andreas Henriksson14743a72010-01-01 23:20:30 +010060check_xt_old()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000061{
62# bail if previous XT checks has already succeded.
63if grep TC_CONFIG_XT Config > /dev/null
64then
65 return
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010066fi
67
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050068#check if we need dont our internal header ..
69cat >/tmp/ipttest.c <<EOF
70#include <xtables.h>
71char *lib_dir;
72unsigned int global_option_offset = 0;
73const char *program_version = XTABLES_VERSION;
74const char *program_name = "tc-ipt";
75struct afinfo afinfo = {
76 .libprefix = "libxt_",
77};
78
79void exit_error(enum exittype status, const char *msg, ...)
80{
81}
82
83int main(int argc, char **argv) {
84
85 return 0;
86}
87
88EOF
89gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
90
91if [ $? -eq 0 ]
92then
Andreas Henriksson80d689d2009-12-02 16:11:21 +010093 echo "TC_CONFIG_XT_OLD:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000094 echo "using old xtables (no need for xt-internal.h)"
95fi
96rm -f /tmp/ipttest.c /tmp/ipttest
97}
98
Andreas Henriksson14743a72010-01-01 23:20:30 +010099check_xt_old_internal_h()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000100{
101# bail if previous XT checks has already succeded.
102if grep TC_CONFIG_XT Config > /dev/null
103then
104 return
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500105fi
106
107#check if we need our own internal.h
108cat >/tmp/ipttest.c <<EOF
109#include <xtables.h>
110#include "xt-internal.h"
111char *lib_dir;
112unsigned int global_option_offset = 0;
113const char *program_version = XTABLES_VERSION;
114const char *program_name = "tc-ipt";
115struct afinfo afinfo = {
116 .libprefix = "libxt_",
117};
118
119void exit_error(enum exittype status, const char *msg, ...)
120{
121}
122
123int main(int argc, char **argv) {
124
125 return 0;
126}
127
128EOF
129gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
130
131if [ $? -eq 0 ]
132then
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000133 echo "using old xtables with xt-internal.h"
Andreas Henriksson80d689d2009-12-02 16:11:21 +0100134 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500135fi
136rm -f /tmp/ipttest.c /tmp/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000137}
138
Andreas Henriksson14743a72010-01-01 23:20:30 +0100139check_ipt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000140{
141 if ! grep TC_CONFIG_XT Config > /dev/null
142 then
143 echo "using iptables"
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000144 TABLES="iptables"
145 else
146 TABLES="xtables"
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000147 fi
148}
149
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000150check_ipt_lib_dir()
151{
152 IPT_LIB_DIR=""
153 for dir in /lib /usr/lib /usr/local/lib
154 do
155 for file in $dir/$TABLES/lib*t_*so ; do
156 if [ -f $file ]; then
157 echo $dir/$TABLES
158 echo "IPT_LIB_DIR:=$dir/$TABLES" >> Config
159 return
160 fi
161 done
162 done
163 echo "not found!"
164}
165
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000166echo "# Generated config based on" $INCLUDE >Config
167
168echo "TC schedulers"
169
170echo -n " ATM "
171check_atm
172
173echo -n " IPT "
174check_xt
175check_xt_old
176check_xt_old_internal_h
177check_ipt
178
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000179echo -n "iptables modules directory: "
180check_ipt_lib_dir