blob: c3dacdba14ff3e9cd1c2d462c5e349d6f09b2b64 [file] [log] [blame]
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +00001#! /bin/bash
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -08002# This is not an autoconf generated configure
osdl.net!shemminger449bf1f2004-06-25 21:14:22 +00003#
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)
Mathias Krausec2f7d6c2012-09-01 20:55:29 +02008trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
Stephen Hemmingere557d1a2012-02-15 10:03:39 -08009
vadimk10ed8b72014-11-30 18:08:25 +020010check_prog()
11{
12 echo -n "$2"
13 command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> Config; echo "yes") || (echo "no"; return 1)
14}
15
16check_docs()
17{
18 if check_prog latex " latex: " HAVE_LATEX; then
19 check_prog pdflatex " pdflatex: " HAVE_PDFLATEX || echo " WARNING: no PDF docs can be built from LaTeX files"
20 check_prog sgml2latex " sgml2latex: " HAVE_SGML2LATEX || echo " WARNING: no LaTeX files can be build from SGML files"
21 else
22 echo " WARNING: no docs can be built from LaTeX files"
23 fi
24
25 check_prog sgml2html " sgml2html: " HAVE_SGML2HTML || echo " WARNING: no HTML docs can be built from SGML"
26}
27
Mike Frysinger601f60e2012-12-16 17:09:15 -050028check_toolchain()
29{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080030 : ${PKG_CONFIG:=pkg-config}
31 : ${AR=ar}
32 : ${CC=gcc}
Stephen Hemmingerae7b9a02012-12-19 16:01:39 -080033 echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080034 echo "AR:=${AR}" >>Config
35 echo "CC:=${CC}" >>Config
Mike Frysinger601f60e2012-12-16 17:09:15 -050036}
37
Andreas Henriksson14743a72010-01-01 23:20:30 +010038check_atm()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000039{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080040 cat >$TMPDIR/atmtest.c <<EOF
osdl.net!shemmingerc830d772004-07-02 17:47:53 +000041#include <atm.h>
42int main(int argc, char **argv) {
43 struct atm_qos qos;
44 (void) text2qos("aal5,ubr:sdu=9180,rx:none",&qos,0);
45 return 0;
46}
47EOF
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080048
49 $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
50 if [ $? -eq 0 ]
51 then
52 echo "TC_CONFIG_ATM:=y" >>Config
53 echo yes
54 else
55 echo no
56 fi
57 rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000058}
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050059
Andreas Henriksson14743a72010-01-01 23:20:30 +010060check_xt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000061{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080062 #check if we have xtables from iptables >= 1.4.5.
63 cat >$TMPDIR/ipttest.c <<EOF
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010064#include <xtables.h>
65#include <linux/netfilter.h>
66static struct xtables_globals test_globals = {
67 .option_offset = 0,
68 .program_name = "tc-ipt",
69 .program_version = XTABLES_VERSION,
70 .orig_opts = NULL,
71 .opts = NULL,
72 .exit_err = NULL,
73};
74
75int main(int argc, char **argv)
76{
77 xtables_init_all(&test_globals, NFPROTO_IPV4);
78 return 0;
79}
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010080EOF
81
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080082 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
83 $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
84 then
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010085 echo "TC_CONFIG_XT:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000086 echo "using xtables"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080087 fi
88 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000089}
90
Andreas Henriksson14743a72010-01-01 23:20:30 +010091check_xt_old()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000092{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080093 # bail if previous XT checks has already succeded.
94 if grep -q TC_CONFIG_XT Config
95 then
Andreas Henrikssonf1a01252009-12-02 05:12:30 +000096 return
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080097 fi
Andreas Henrikssona36ceb82009-12-02 16:11:50 +010098
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -080099 #check if we dont need our internal header ..
100 cat >$TMPDIR/ipttest.c <<EOF
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500101#include <xtables.h>
102char *lib_dir;
103unsigned int global_option_offset = 0;
104const char *program_version = XTABLES_VERSION;
105const char *program_name = "tc-ipt";
106struct afinfo afinfo = {
107 .libprefix = "libxt_",
108};
109
110void exit_error(enum exittype status, const char *msg, ...)
111{
112}
113
114int main(int argc, char **argv) {
115
116 return 0;
117}
118
119EOF
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500120
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800121 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
122 if [ $? -eq 0 ]
123 then
Andreas Henriksson80d689d2009-12-02 16:11:21 +0100124 echo "TC_CONFIG_XT_OLD:=y" >>Config
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000125 echo "using old xtables (no need for xt-internal.h)"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800126 fi
127 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000128}
129
Andreas Henriksson14743a72010-01-01 23:20:30 +0100130check_xt_old_internal_h()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000131{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800132 # bail if previous XT checks has already succeded.
133 if grep -q TC_CONFIG_XT Config
134 then
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000135 return
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800136 fi
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500137
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800138 #check if we need our own internal.h
139 cat >$TMPDIR/ipttest.c <<EOF
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500140#include <xtables.h>
141#include "xt-internal.h"
142char *lib_dir;
143unsigned int global_option_offset = 0;
144const char *program_version = XTABLES_VERSION;
145const char *program_name = "tc-ipt";
146struct afinfo afinfo = {
147 .libprefix = "libxt_",
148};
149
150void exit_error(enum exittype status, const char *msg, ...)
151{
152}
153
154int main(int argc, char **argv) {
155
156 return 0;
157}
158
159EOF
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800160 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -0500161
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800162 if [ $? -eq 0 ]
163 then
164 echo "using old xtables with xt-internal.h"
165 echo "TC_CONFIG_XT_OLD_H:=y" >>Config
166 fi
167 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000168}
169
Andreas Henriksson14743a72010-01-01 23:20:30 +0100170check_ipt()
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000171{
172 if ! grep TC_CONFIG_XT Config > /dev/null
173 then
174 echo "using iptables"
175 fi
176}
177
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000178check_ipt_lib_dir()
179{
Mike Frysingere4fc4ad2012-11-08 11:41:17 -0500180 IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
Li Weida7fbb22012-08-20 09:41:47 +0800181 if [ -n "$IPT_LIB_DIR" ]; then
182 echo $IPT_LIB_DIR
183 echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config
184 return
185 fi
186
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000187 for dir in /lib /usr/lib /usr/local/lib
188 do
Dan McGee44e743e2011-07-15 08:52:24 +0000189 for file in $dir/{xtables,iptables}/lib*t_*so ; do
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000190 if [ -f $file ]; then
Dan McGee44e743e2011-07-15 08:52:24 +0000191 echo ${file%/*}
192 echo "IPT_LIB_DIR:=${file%/*}" >> Config
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000193 return
194 fi
195 done
196 done
197 echo "not found!"
198}
199
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000200check_setns()
201{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800202 cat >$TMPDIR/setnstest.c <<EOF
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000203#include <sched.h>
204int main(int argc, char **argv)
205{
206 (void)setns(0,0);
207 return 0;
208}
209EOF
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800210 $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
211 if [ $? -eq 0 ]
212 then
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000213 echo "IP_CONFIG_SETNS:=y" >>Config
214 echo "yes"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800215 else
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000216 echo "no"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800217 fi
218 rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000219}
220
Florian Westphal81944112012-08-09 09:18:50 +0000221check_ipset()
222{
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800223 cat >$TMPDIR/ipsettest.c <<EOF
Florian Westphal81944112012-08-09 09:18:50 +0000224#include <linux/netfilter/ipset/ip_set.h>
225#ifndef IP_SET_INVALID
226#define IPSET_DIM_MAX 3
227typedef unsigned short ip_set_id_t;
228#endif
229#include <linux/netfilter/xt_set.h>
230
231struct xt_set_info info;
232#if IPSET_PROTOCOL == 6
233int main(void)
234{
235 return IPSET_MAXNAMELEN;
236}
237#else
238#error unknown ipset version
239#endif
240EOF
241
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800242 if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1
243 then
Florian Westphal81944112012-08-09 09:18:50 +0000244 echo "TC_CONFIG_IPSET:=y" >>Config
245 echo "yes"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800246 else
Florian Westphal81944112012-08-09 09:18:50 +0000247 echo "no"
Stephen Hemminger07a6f5e2012-12-18 09:20:13 -0800248 fi
249 rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
Florian Westphal81944112012-08-09 09:18:50 +0000250}
251
Richard Haines116ac922014-03-07 10:36:52 +0000252check_selinux()
253# SELinux is a compile time option in the ss utility
254{
255 if ${PKG_CONFIG} libselinux --exists
256 then
257 echo "HAVE_SELINUX:=y" >>Config
258 echo "yes"
259 else
260 echo "no"
261 fi
262}
263
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000264echo "# Generated config based on" $INCLUDE >Config
Mike Frysinger601f60e2012-12-16 17:09:15 -0500265check_toolchain
Andreas Henrikssonf1a01252009-12-02 05:12:30 +0000266
267echo "TC schedulers"
268
269echo -n " ATM "
270check_atm
271
272echo -n " IPT "
273check_xt
274check_xt_old
275check_xt_old_internal_h
276check_ipt
277
Florian Westphal81944112012-08-09 09:18:50 +0000278echo -n " IPSET "
279check_ipset
280
vadimk10ed8b72014-11-30 18:08:25 +0200281echo -n -e "\niptables modules directory: "
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000282check_ipt_lib_dir
Eric W. Biederman2e8a07f2011-07-15 14:26:59 +0000283
284echo -n "libc has setns: "
285check_setns
Richard Haines116ac922014-03-07 10:36:52 +0000286
287echo -n "SELinux support: "
288check_selinux
vadimk10ed8b72014-11-30 18:08:25 +0200289
290echo -e "\nDocs"
291check_docs