osdl.net!shemminger | 449bf1f | 2004-06-25 21:14:22 +0000 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # This is not an autconf generated configure |
| 3 | # |
osdl.net!shemminger | 4b1bbd9 | 2004-08-09 16:35:28 +0000 | [diff] [blame] | 4 | INCLUDE=${1:-"$PWD/include"} |
osdl.net!shemminger | 449bf1f | 2004-06-25 21:14:22 +0000 | [diff] [blame] | 5 | |
Andreas Henriksson | 12ddfff | 2010-03-11 10:54:31 +0000 | [diff] [blame^] | 6 | TABLES= |
| 7 | |
Andreas Henriksson | 14743a7 | 2010-01-01 23:20:30 +0100 | [diff] [blame] | 8 | check_atm() |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 9 | { |
osdl.net!shemminger | c830d77 | 2004-07-02 17:47:53 +0000 | [diff] [blame] | 10 | cat >/tmp/atmtest.c <<EOF |
| 11 | #include <atm.h> |
| 12 | int 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 | } |
| 17 | EOF |
osdl.net!shemminger | 2979d52 | 2004-07-30 20:24:59 +0000 | [diff] [blame] | 18 | gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1 |
osdl.net!shemminger | c830d77 | 2004-07-02 17:47:53 +0000 | [diff] [blame] | 19 | if [ $? -eq 0 ] |
osdl.net!shemminger | 449bf1f | 2004-06-25 21:14:22 +0000 | [diff] [blame] | 20 | then |
osdl.net!shemminger | c830d77 | 2004-07-02 17:47:53 +0000 | [diff] [blame] | 21 | echo "TC_CONFIG_ATM:=y" >>Config |
osdl.net!shemminger | b9cb1c9 | 2004-07-30 22:27:50 +0000 | [diff] [blame] | 22 | echo yes |
osdl.net!shemminger | 449bf1f | 2004-06-25 21:14:22 +0000 | [diff] [blame] | 23 | else |
osdl.net!shemminger | b9cb1c9 | 2004-07-30 22:27:50 +0000 | [diff] [blame] | 24 | echo no |
osdl.net!shemminger | 449bf1f | 2004-06-25 21:14:22 +0000 | [diff] [blame] | 25 | fi |
osdl.net!shemminger | 2979d52 | 2004-07-30 20:24:59 +0000 | [diff] [blame] | 26 | rm -f /tmp/atmtest.c /tmp/atmtest |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 27 | } |
Jamal Hadi Salim | 63c7d26 | 2009-02-07 08:19:20 -0500 | [diff] [blame] | 28 | |
Andreas Henriksson | 14743a7 | 2010-01-01 23:20:30 +0100 | [diff] [blame] | 29 | check_xt() |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 30 | { |
Andreas Henriksson | a36ceb8 | 2009-12-02 16:11:50 +0100 | [diff] [blame] | 31 | #check if we have xtables from iptables >= 1.4.5. |
| 32 | cat >/tmp/ipttest.c <<EOF |
| 33 | #include <xtables.h> |
| 34 | #include <linux/netfilter.h> |
| 35 | static 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 | |
| 44 | int main(int argc, char **argv) |
| 45 | { |
| 46 | xtables_init_all(&test_globals, NFPROTO_IPV4); |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | EOF |
| 51 | |
| 52 | if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1 |
| 53 | then |
| 54 | echo "TC_CONFIG_XT:=y" >>Config |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 55 | echo "using xtables" |
| 56 | fi |
| 57 | rm -f /tmp/ipttest.c /tmp/ipttest |
| 58 | } |
| 59 | |
Andreas Henriksson | 14743a7 | 2010-01-01 23:20:30 +0100 | [diff] [blame] | 60 | check_xt_old() |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 61 | { |
| 62 | # bail if previous XT checks has already succeded. |
| 63 | if grep TC_CONFIG_XT Config > /dev/null |
| 64 | then |
| 65 | return |
Andreas Henriksson | a36ceb8 | 2009-12-02 16:11:50 +0100 | [diff] [blame] | 66 | fi |
| 67 | |
Jamal Hadi Salim | 63c7d26 | 2009-02-07 08:19:20 -0500 | [diff] [blame] | 68 | #check if we need dont our internal header .. |
| 69 | cat >/tmp/ipttest.c <<EOF |
| 70 | #include <xtables.h> |
| 71 | char *lib_dir; |
| 72 | unsigned int global_option_offset = 0; |
| 73 | const char *program_version = XTABLES_VERSION; |
| 74 | const char *program_name = "tc-ipt"; |
| 75 | struct afinfo afinfo = { |
| 76 | .libprefix = "libxt_", |
| 77 | }; |
| 78 | |
| 79 | void exit_error(enum exittype status, const char *msg, ...) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | int main(int argc, char **argv) { |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | EOF |
| 89 | gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1 |
| 90 | |
| 91 | if [ $? -eq 0 ] |
| 92 | then |
Andreas Henriksson | 80d689d | 2009-12-02 16:11:21 +0100 | [diff] [blame] | 93 | echo "TC_CONFIG_XT_OLD:=y" >>Config |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 94 | echo "using old xtables (no need for xt-internal.h)" |
| 95 | fi |
| 96 | rm -f /tmp/ipttest.c /tmp/ipttest |
| 97 | } |
| 98 | |
Andreas Henriksson | 14743a7 | 2010-01-01 23:20:30 +0100 | [diff] [blame] | 99 | check_xt_old_internal_h() |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 100 | { |
| 101 | # bail if previous XT checks has already succeded. |
| 102 | if grep TC_CONFIG_XT Config > /dev/null |
| 103 | then |
| 104 | return |
Jamal Hadi Salim | 63c7d26 | 2009-02-07 08:19:20 -0500 | [diff] [blame] | 105 | fi |
| 106 | |
| 107 | #check if we need our own internal.h |
| 108 | cat >/tmp/ipttest.c <<EOF |
| 109 | #include <xtables.h> |
| 110 | #include "xt-internal.h" |
| 111 | char *lib_dir; |
| 112 | unsigned int global_option_offset = 0; |
| 113 | const char *program_version = XTABLES_VERSION; |
| 114 | const char *program_name = "tc-ipt"; |
| 115 | struct afinfo afinfo = { |
| 116 | .libprefix = "libxt_", |
| 117 | }; |
| 118 | |
| 119 | void exit_error(enum exittype status, const char *msg, ...) |
| 120 | { |
| 121 | } |
| 122 | |
| 123 | int main(int argc, char **argv) { |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | EOF |
| 129 | gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1 |
| 130 | |
| 131 | if [ $? -eq 0 ] |
| 132 | then |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 133 | echo "using old xtables with xt-internal.h" |
Andreas Henriksson | 80d689d | 2009-12-02 16:11:21 +0100 | [diff] [blame] | 134 | echo "TC_CONFIG_XT_OLD_H:=y" >>Config |
Jamal Hadi Salim | 63c7d26 | 2009-02-07 08:19:20 -0500 | [diff] [blame] | 135 | fi |
| 136 | rm -f /tmp/ipttest.c /tmp/ipttest |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Andreas Henriksson | 14743a7 | 2010-01-01 23:20:30 +0100 | [diff] [blame] | 139 | check_ipt() |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 140 | { |
| 141 | if ! grep TC_CONFIG_XT Config > /dev/null |
| 142 | then |
| 143 | echo "using iptables" |
Andreas Henriksson | 12ddfff | 2010-03-11 10:54:31 +0000 | [diff] [blame^] | 144 | TABLES="iptables" |
| 145 | else |
| 146 | TABLES="xtables" |
Andreas Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 147 | fi |
| 148 | } |
| 149 | |
Andreas Henriksson | 12ddfff | 2010-03-11 10:54:31 +0000 | [diff] [blame^] | 150 | check_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 Henriksson | f1a0125 | 2009-12-02 05:12:30 +0000 | [diff] [blame] | 166 | echo "# Generated config based on" $INCLUDE >Config |
| 167 | |
| 168 | echo "TC schedulers" |
| 169 | |
| 170 | echo -n " ATM " |
| 171 | check_atm |
| 172 | |
| 173 | echo -n " IPT " |
| 174 | check_xt |
| 175 | check_xt_old |
| 176 | check_xt_old_internal_h |
| 177 | check_ipt |
| 178 | |
Andreas Henriksson | 12ddfff | 2010-03-11 10:54:31 +0000 | [diff] [blame^] | 179 | echo -n "iptables modules directory: " |
| 180 | check_ipt_lib_dir |