San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # This is not an autconf generated configure |
| 3 | # |
| 4 | INCLUDE=${1:-"$PWD/include"} |
| 5 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 6 | TABLES= |
| 7 | |
| 8 | check_atm() |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [diff] [blame] | 9 | { |
| 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 |
| 18 | gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1 |
| 19 | if [ $? -eq 0 ] |
| 20 | then |
| 21 | echo "TC_CONFIG_ATM:=y" >>Config |
| 22 | echo yes |
| 23 | else |
| 24 | echo no |
| 25 | fi |
| 26 | rm -f /tmp/atmtest.c /tmp/atmtest |
| 27 | } |
| 28 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 29 | check_xt() |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [diff] [blame] | 30 | { |
| 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 |
| 55 | echo "using xtables" |
| 56 | fi |
| 57 | rm -f /tmp/ipttest.c /tmp/ipttest |
| 58 | } |
| 59 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 60 | check_xt_old() |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [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 |
| 66 | fi |
| 67 | |
| 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 |
| 93 | echo "TC_CONFIG_XT_OLD:=y" >>Config |
| 94 | echo "using old xtables (no need for xt-internal.h)" |
| 95 | fi |
| 96 | rm -f /tmp/ipttest.c /tmp/ipttest |
| 97 | } |
| 98 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 99 | check_xt_old_internal_h() |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [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 |
| 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 |
| 133 | echo "using old xtables with xt-internal.h" |
| 134 | echo "TC_CONFIG_XT_OLD_H:=y" >>Config |
| 135 | fi |
| 136 | rm -f /tmp/ipttest.c /tmp/ipttest |
| 137 | } |
| 138 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 139 | check_ipt() |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [diff] [blame] | 140 | { |
| 141 | if ! grep TC_CONFIG_XT Config > /dev/null |
| 142 | then |
| 143 | echo "using iptables" |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 144 | TABLES="iptables" |
| 145 | else |
| 146 | TABLES="xtables" |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [diff] [blame] | 147 | fi |
| 148 | } |
| 149 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [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 | |
San Mehat | dcfb7a7 | 2010-04-07 09:35:03 -0700 | [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 | |
Dmitry Shmidt | 1a441f4 | 2011-01-06 15:37:12 -0800 | [diff] [blame] | 179 | echo -n "iptables modules directory: " |
| 180 | check_ipt_lib_dir |