X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=configure;h=9470c1d4043e2c58dee6a50b5c594952ed6b08ca;hb=672acc723859290b94b753b8437d8cc2f0810174;hp=4fda7cba8f3fb38c5378b3a8a4a1de2a281769f2;hpb=a36ceb85d7ae6a9742c35417e80ae837ce9f146d;p=mirror_iproute2.git diff --git a/configure b/configure index 4fda7cba..9470c1d4 100755 --- a/configure +++ b/configure @@ -1,14 +1,43 @@ #! /bin/bash -# This is not an autconf generated configure +# This is not an autoconf generated configure # INCLUDE=${1:-"$PWD/include"} -echo "# Generated config based on" $INCLUDE >Config +# Make a temp directory in build tree. +TMPDIR=$(mktemp -d config.XXXXXX) +trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM -echo "TC schedulers" +check_prog() +{ + echo -n "$2" + command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> Config; echo "yes") || (echo "no"; return 1) +} -echo -n " ATM " -cat >/tmp/atmtest.c <>Config + echo "AR:=${AR}" >>Config + echo "CC:=${CC}" >>Config +} + +check_atm() +{ + cat >$TMPDIR/atmtest.c < int main(int argc, char **argv) { struct atm_qos qos; @@ -16,20 +45,22 @@ int main(int argc, char **argv) { return 0; } EOF -gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1 -if [ $? -eq 0 ] -then - echo "TC_CONFIG_ATM:=y" >>Config - echo yes -else - echo no -fi -rm -f /tmp/atmtest.c /tmp/atmtest -echo -n " IPT " + $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1 + if [ $? -eq 0 ] + then + echo "TC_CONFIG_ATM:=y" >>Config + echo yes + else + echo no + fi + rm -f $TMPDIR/atmtest.c $TMPDIR/atmtest +} -#check if we have xtables from iptables >= 1.4.5. -cat >/tmp/ipttest.c <= 1.4.5. + cat >$TMPDIR/ipttest.c < #include static struct xtables_globals test_globals = { @@ -46,17 +77,27 @@ int main(int argc, char **argv) xtables_init_all(&test_globals, NFPROTO_IPV4); return 0; } - EOF -if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1 -then + if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \ + $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1 + then echo "TC_CONFIG_XT:=y" >>Config - echo "using xtables instead of iptables" -fi + echo "using xtables" + fi + rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest +} + +check_xt_old() +{ + # bail if previous XT checks has already succeded. + if grep -q TC_CONFIG_XT Config + then + return + fi -#check if we need dont our internal header .. -cat >/tmp/ipttest.c <$TMPDIR/ipttest.c < char *lib_dir; unsigned int global_option_offset = 0; @@ -76,18 +117,26 @@ int main(int argc, char **argv) { } EOF -gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1 -if [ $? -eq 0 ] -then + $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1 + if [ $? -eq 0 ] + then echo "TC_CONFIG_XT_OLD:=y" >>Config - echo "using xtables seems no need for internal.h" -else - echo "failed test 2" -fi + echo "using old xtables (no need for xt-internal.h)" + fi + rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest +} + +check_xt_old_internal_h() +{ + # bail if previous XT checks has already succeded. + if grep -q TC_CONFIG_XT Config + then + return + fi -#check if we need our own internal.h -cat >/tmp/ipttest.c <$TMPDIR/ipttest.c < #include "xt-internal.h" char *lib_dir; @@ -108,14 +157,135 @@ int main(int argc, char **argv) { } EOF -gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1 + $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1 + + if [ $? -eq 0 ] + then + echo "using old xtables with xt-internal.h" + echo "TC_CONFIG_XT_OLD_H:=y" >>Config + fi + rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest +} + +check_ipt() +{ + if ! grep TC_CONFIG_XT Config > /dev/null + then + echo "using iptables" + fi +} + +check_ipt_lib_dir() +{ + IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables) + if [ -n "$IPT_LIB_DIR" ]; then + echo $IPT_LIB_DIR + echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> Config + return + fi + + for dir in /lib /usr/lib /usr/local/lib + do + for file in $dir/{xtables,iptables}/lib*t_*so ; do + if [ -f $file ]; then + echo ${file%/*} + echo "IPT_LIB_DIR:=${file%/*}" >> Config + return + fi + done + done + echo "not found!" +} + +check_setns() +{ + cat >$TMPDIR/setnstest.c < +int main(int argc, char **argv) +{ + (void)setns(0,0); + return 0; +} +EOF + $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1 + if [ $? -eq 0 ] + then + echo "IP_CONFIG_SETNS:=y" >>Config + echo "yes" + else + echo "no" + fi + rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest +} + +check_ipset() +{ + cat >$TMPDIR/ipsettest.c < +#ifndef IP_SET_INVALID +#define IPSET_DIM_MAX 3 +typedef unsigned short ip_set_id_t; +#endif +#include + +struct xt_set_info info; +#if IPSET_PROTOCOL == 6 +int main(void) +{ + return IPSET_MAXNAMELEN; +} +#else +#error unknown ipset version +#endif +EOF + + if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1 + then + echo "TC_CONFIG_IPSET:=y" >>Config + echo "yes" + else + echo "no" + fi + rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest +} + +check_selinux() +# SELinux is a compile time option in the ss utility +{ + if ${PKG_CONFIG} libselinux --exists + then + echo "HAVE_SELINUX:=y" >>Config + echo "yes" + else + echo "no" + fi +} + +echo "# Generated config based on" $INCLUDE >Config +check_toolchain + +echo "TC schedulers" + +echo -n " ATM " +check_atm + +echo -n " IPT " +check_xt +check_xt_old +check_xt_old_internal_h +check_ipt + +echo -n " IPSET " +check_ipset + +echo -n -e "\niptables modules directory: " +check_ipt_lib_dir + +echo -n "libc has setns: " +check_setns -if [ $? -eq 0 ] -then - echo "using xtables instead of iptables (need for internal.h)" - echo "TC_CONFIG_XT_OLD_H:=y" >>Config +echo -n "SELinux support: " +check_selinux -else - echo "failed test 3 using iptables" -fi -rm -f /tmp/ipttest.c /tmp/ipttest +echo -e "\nDocs" +check_docs