2 # This is not an autoconf generated configure
4 INCLUDE=${1:-"$PWD/include"}
6 # Make a temp directory in build tree.
7 TMPDIR=$(mktemp -d config.XXXXXX)
8 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
12 : ${PKG_CONFIG:=pkg-config}
15 echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
16 echo "AR:=${AR}" >>Config
17 echo "CC:=${CC}" >>Config
22 cat >$TMPDIR/atmtest.c <<EOF
24 int main(int argc, char **argv) {
26 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
31 $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
34 echo "TC_CONFIG_ATM:=y" >>Config
39 rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest
44 #check if we have xtables from iptables >= 1.4.5.
45 cat >$TMPDIR/ipttest.c <<EOF
47 #include <linux/netfilter.h>
48 static struct xtables_globals test_globals = {
50 .program_name = "tc-ipt",
51 .program_version = XTABLES_VERSION,
57 int main(int argc, char **argv)
59 xtables_init_all(&test_globals, NFPROTO_IPV4);
64 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
65 $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
67 echo "TC_CONFIG_XT:=y" >>Config
70 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
75 # bail if previous XT checks has already succeded.
76 if grep -q TC_CONFIG_XT Config
81 #check if we dont need our internal header ..
82 cat >$TMPDIR/ipttest.c <<EOF
85 unsigned int global_option_offset = 0;
86 const char *program_version = XTABLES_VERSION;
87 const char *program_name = "tc-ipt";
88 struct afinfo afinfo = {
89 .libprefix = "libxt_",
92 void exit_error(enum exittype status, const char *msg, ...)
96 int main(int argc, char **argv) {
103 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
106 echo "TC_CONFIG_XT_OLD:=y" >>Config
107 echo "using old xtables (no need for xt-internal.h)"
109 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
112 check_xt_old_internal_h()
114 # bail if previous XT checks has already succeded.
115 if grep -q TC_CONFIG_XT Config
120 #check if we need our own internal.h
121 cat >$TMPDIR/ipttest.c <<EOF
123 #include "xt-internal.h"
125 unsigned int global_option_offset = 0;
126 const char *program_version = XTABLES_VERSION;
127 const char *program_name = "tc-ipt";
128 struct afinfo afinfo = {
129 .libprefix = "libxt_",
132 void exit_error(enum exittype status, const char *msg, ...)
136 int main(int argc, char **argv) {
142 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
146 echo "using old xtables with xt-internal.h"
147 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
149 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
154 if ! grep TC_CONFIG_XT Config > /dev/null
156 echo "using iptables"
162 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
163 if [ -n "$IPT_LIB_DIR" ]; then
165 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
169 for dir in /lib /usr/lib /usr/local/lib
171 for file in $dir/{xtables,iptables}/lib*t_*so ; do
172 if [ -f $file ]; then
174 echo "IPT_LIB_DIR:=${file%/*}" >> Config
184 cat >$TMPDIR/setnstest.c <<EOF
186 int main(int argc, char **argv)
192 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
195 echo "IP_CONFIG_SETNS:=y" >>Config
200 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
205 cat >$TMPDIR/ipsettest.c <<EOF
206 #include <linux/netfilter/ipset/ip_set.h>
207 #ifndef IP_SET_INVALID
208 #define IPSET_DIM_MAX 3
209 typedef unsigned short ip_set_id_t;
211 #include <linux/netfilter/xt_set.h>
213 struct xt_set_info info;
214 #if IPSET_PROTOCOL == 6
217 return IPSET_MAXNAMELEN;
220 #error unknown ipset version
224 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
226 echo "TC_CONFIG_IPSET:=y" >>Config
231 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
234 echo "# Generated config based on" $INCLUDE >Config
245 check_xt_old_internal_h
251 echo -n "iptables modules directory: "
254 echo -n "libc has setns: "