• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2# This is not an autconf generated configure
3#
4INCLUDE=${1:-"$PWD/include"}
5
6TABLES=
7
8check_atm()
9{
10cat >/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
18gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
19if [ $? -eq 0 ]
20then
21    echo "TC_CONFIG_ATM:=y" >>Config
22    echo yes
23else
24    echo no
25fi
26rm -f /tmp/atmtest.c /tmp/atmtest
27}
28
29check_xt()
30{
31#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
55	echo "using xtables"
56fi
57rm -f /tmp/ipttest.c /tmp/ipttest
58}
59
60check_xt_old()
61{
62# bail if previous XT checks has already succeded.
63if grep TC_CONFIG_XT Config > /dev/null
64then
65	return
66fi
67
68#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
93	echo "TC_CONFIG_XT_OLD:=y" >>Config
94	echo "using old xtables (no need for xt-internal.h)"
95fi
96rm -f /tmp/ipttest.c /tmp/ipttest
97}
98
99check_xt_old_internal_h()
100{
101# bail if previous XT checks has already succeded.
102if grep TC_CONFIG_XT Config > /dev/null
103then
104	return
105fi
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
133	echo "using old xtables with xt-internal.h"
134	echo "TC_CONFIG_XT_OLD_H:=y" >>Config
135fi
136rm -f /tmp/ipttest.c /tmp/ipttest
137}
138
139check_ipt()
140{
141	if ! grep TC_CONFIG_XT Config > /dev/null
142	then
143		echo "using iptables"
144		TABLES="iptables"
145	else
146		TABLES="xtables"
147	fi
148}
149
150check_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
166echo "# 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
179echo -n "iptables modules directory: "
180check_ipt_lib_dir
181