2018-12-16 02:00:41 +08:00
|
|
|
#!/bin/sh
|
2017-11-25 04:21:35 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2012-12-19 01:20:13 +08:00
|
|
|
# This is not an autoconf generated configure
|
2020-11-23 21:11:57 +08:00
|
|
|
|
2021-05-31 17:47:39 +08:00
|
|
|
INCLUDE="$PWD/include"
|
2021-10-14 16:50:54 +08:00
|
|
|
PREFIX="/usr"
|
2021-10-14 16:50:55 +08:00
|
|
|
LIBDIR="\${prefix}/lib"
|
2023-09-14 01:58:25 +08:00
|
|
|
COLOR="never"
|
2004-06-26 05:14:22 +08:00
|
|
|
|
2017-08-11 08:05:03 +08:00
|
|
|
# Output file which is input to Makefile
|
|
|
|
CONFIG=config.mk
|
|
|
|
|
2012-02-16 02:03:39 +08:00
|
|
|
# Make a temp directory in build tree.
|
|
|
|
TMPDIR=$(mktemp -d config.XXXXXX)
|
2012-09-02 02:55:29 +08:00
|
|
|
trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
|
2012-02-16 02:03:39 +08:00
|
|
|
|
2012-12-17 06:09:15 +08:00
|
|
|
check_toolchain()
|
|
|
|
{
|
2012-12-19 01:20:13 +08:00
|
|
|
: ${PKG_CONFIG:=pkg-config}
|
|
|
|
: ${AR=ar}
|
|
|
|
: ${CC=gcc}
|
2020-01-09 03:57:05 +08:00
|
|
|
: ${YACC=bison}
|
2022-03-09 00:24:17 +08:00
|
|
|
echo "PKG_CONFIG:=${PKG_CONFIG}" >>$CONFIG
|
|
|
|
echo "AR:=${AR}" >>$CONFIG
|
|
|
|
echo "CC:=${CC}" >>$CONFIG
|
|
|
|
echo "YACC:=${YACC}" >>$CONFIG
|
2012-12-17 06:09:15 +08:00
|
|
|
}
|
|
|
|
|
2016-10-18 20:13:09 +08:00
|
|
|
check_xtables()
|
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ! ${PKG_CONFIG} xtables --exists; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
|
2016-10-18 20:13:09 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-01-02 06:20:30 +08:00
|
|
|
check_xt()
|
2009-12-02 13:12:30 +08:00
|
|
|
{
|
2012-12-19 01:20:13 +08:00
|
|
|
#check if we have xtables from iptables >= 1.4.5.
|
|
|
|
cat >$TMPDIR/ipttest.c <<EOF
|
2009-12-02 23:11:50 +08:00
|
|
|
#include <xtables.h>
|
|
|
|
#include <linux/netfilter.h>
|
|
|
|
static struct xtables_globals test_globals = {
|
|
|
|
.option_offset = 0,
|
|
|
|
.program_name = "tc-ipt",
|
|
|
|
.program_version = XTABLES_VERSION,
|
|
|
|
.orig_opts = NULL,
|
|
|
|
.opts = NULL,
|
|
|
|
.exit_err = NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
xtables_init_all(&test_globals, NFPROTO_IPV4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2012-12-19 01:20:13 +08:00
|
|
|
if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
|
2018-12-16 02:00:42 +08:00
|
|
|
$(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "TC_CONFIG_XT:=y" >>$CONFIG
|
2009-12-02 13:12:30 +08:00
|
|
|
echo "using xtables"
|
2012-12-19 01:20:13 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
|
2009-12-02 13:12:30 +08:00
|
|
|
}
|
|
|
|
|
2010-01-02 06:20:30 +08:00
|
|
|
check_xt_old()
|
2009-12-02 13:12:30 +08:00
|
|
|
{
|
2018-10-19 04:22:25 +08:00
|
|
|
# bail if previous XT checks has already succeeded.
|
2018-12-16 02:00:42 +08:00
|
|
|
grep -q TC_CONFIG_XT $CONFIG && return
|
2009-12-02 23:11:50 +08:00
|
|
|
|
2018-10-19 04:22:25 +08:00
|
|
|
#check if we don't need our internal header ..
|
2012-12-19 01:20:13 +08:00
|
|
|
cat >$TMPDIR/ipttest.c <<EOF
|
2009-02-07 21:19:20 +08:00
|
|
|
#include <xtables.h>
|
|
|
|
char *lib_dir;
|
|
|
|
unsigned int global_option_offset = 0;
|
|
|
|
const char *program_version = XTABLES_VERSION;
|
|
|
|
const char *program_name = "tc-ipt";
|
|
|
|
struct afinfo afinfo = {
|
|
|
|
.libprefix = "libxt_",
|
|
|
|
};
|
|
|
|
|
|
|
|
void exit_error(enum exittype status, const char *msg, ...)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "TC_CONFIG_XT_OLD:=y" >>$CONFIG
|
2009-12-02 13:12:30 +08:00
|
|
|
echo "using old xtables (no need for xt-internal.h)"
|
2012-12-19 01:20:13 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
|
2009-12-02 13:12:30 +08:00
|
|
|
}
|
|
|
|
|
2010-01-02 06:20:30 +08:00
|
|
|
check_xt_old_internal_h()
|
2009-12-02 13:12:30 +08:00
|
|
|
{
|
2018-10-19 04:22:25 +08:00
|
|
|
# bail if previous XT checks has already succeeded.
|
2019-01-08 06:37:15 +08:00
|
|
|
grep -q TC_CONFIG_XT $CONFIG && return
|
2009-02-07 21:19:20 +08:00
|
|
|
|
2012-12-19 01:20:13 +08:00
|
|
|
#check if we need our own internal.h
|
|
|
|
cat >$TMPDIR/ipttest.c <<EOF
|
2009-02-07 21:19:20 +08:00
|
|
|
#include <xtables.h>
|
|
|
|
#include "xt-internal.h"
|
|
|
|
char *lib_dir;
|
|
|
|
unsigned int global_option_offset = 0;
|
|
|
|
const char *program_version = XTABLES_VERSION;
|
|
|
|
const char *program_name = "tc-ipt";
|
|
|
|
struct afinfo afinfo = {
|
|
|
|
.libprefix = "libxt_",
|
|
|
|
};
|
|
|
|
|
|
|
|
void exit_error(enum exittype status, const char *msg, ...)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1; then
|
2012-12-19 01:20:13 +08:00
|
|
|
echo "using old xtables with xt-internal.h"
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "TC_CONFIG_XT_OLD_H:=y" >>$CONFIG
|
2012-12-19 01:20:13 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
|
2009-12-02 13:12:30 +08:00
|
|
|
}
|
|
|
|
|
2021-10-14 16:50:55 +08:00
|
|
|
check_lib_dir()
|
|
|
|
{
|
|
|
|
LIBDIR=$(echo $LIBDIR | sed "s|\${prefix}|$PREFIX|")
|
|
|
|
|
|
|
|
echo -n "lib directory: "
|
|
|
|
echo "$LIBDIR"
|
|
|
|
echo "LIBDIR:=$LIBDIR" >> $CONFIG
|
|
|
|
}
|
|
|
|
|
2010-01-02 06:20:30 +08:00
|
|
|
check_ipt()
|
2009-12-02 13:12:30 +08:00
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
|
2009-12-02 13:12:30 +08:00
|
|
|
echo "using iptables"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-03-11 18:54:31 +08:00
|
|
|
check_ipt_lib_dir()
|
|
|
|
{
|
2012-11-09 00:41:17 +08:00
|
|
|
IPT_LIB_DIR=$(${PKG_CONFIG} --variable=xtlibdir xtables)
|
2012-08-20 09:41:47 +08:00
|
|
|
if [ -n "$IPT_LIB_DIR" ]; then
|
|
|
|
echo $IPT_LIB_DIR
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "IPT_LIB_DIR:=$IPT_LIB_DIR" >> $CONFIG
|
2012-08-20 09:41:47 +08:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-12-16 02:00:42 +08:00
|
|
|
for dir in /lib /usr/lib /usr/local/lib; do
|
2018-12-16 02:00:41 +08:00
|
|
|
for file in "xtables" "iptables"; do
|
|
|
|
file="$dir/$file/lib*t_*so"
|
2010-03-11 18:54:31 +08:00
|
|
|
if [ -f $file ]; then
|
2011-07-15 16:52:24 +08:00
|
|
|
echo ${file%/*}
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "IPT_LIB_DIR:=${file%/*}" >> $CONFIG
|
2010-03-11 18:54:31 +08:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
echo "not found!"
|
|
|
|
}
|
|
|
|
|
2011-07-15 22:26:59 +08:00
|
|
|
check_setns()
|
|
|
|
{
|
2012-12-19 01:20:13 +08:00
|
|
|
cat >$TMPDIR/setnstest.c <<EOF
|
2022-08-11 13:34:40 +08:00
|
|
|
#define _GNU_SOURCE
|
2011-07-15 22:26:59 +08:00
|
|
|
#include <sched.h>
|
2015-03-07 14:30:58 +08:00
|
|
|
int main(int argc, char **argv)
|
2011-07-15 22:26:59 +08:00
|
|
|
{
|
|
|
|
(void)setns(0,0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "IP_CONFIG_SETNS:=y" >>$CONFIG
|
2011-07-15 22:26:59 +08:00
|
|
|
echo "yes"
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
|
2012-12-19 01:20:13 +08:00
|
|
|
else
|
2011-07-15 22:26:59 +08:00
|
|
|
echo "no"
|
2012-12-19 01:20:13 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
|
2011-07-15 22:26:59 +08:00
|
|
|
}
|
|
|
|
|
2021-05-08 14:49:26 +08:00
|
|
|
check_name_to_handle_at()
|
|
|
|
{
|
|
|
|
cat >$TMPDIR/name_to_handle_at_test.c <<EOF
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct file_handle *fhp;
|
|
|
|
int mount_id, flags, dirfd;
|
|
|
|
char *pathname;
|
|
|
|
name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
if $CC -I$INCLUDE -o $TMPDIR/name_to_handle_at_test $TMPDIR/name_to_handle_at_test.c >/dev/null 2>&1; then
|
|
|
|
echo "yes"
|
|
|
|
echo "CFLAGS += -DHAVE_HANDLE_AT" >>$CONFIG
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/name_to_handle_at_test.c $TMPDIR/name_to_handle_at_test
|
|
|
|
}
|
|
|
|
|
2012-08-09 17:18:50 +08:00
|
|
|
check_ipset()
|
|
|
|
{
|
2012-12-19 01:20:13 +08:00
|
|
|
cat >$TMPDIR/ipsettest.c <<EOF
|
2012-08-09 17:18:50 +08:00
|
|
|
#include <linux/netfilter/ipset/ip_set.h>
|
|
|
|
#ifndef IP_SET_INVALID
|
|
|
|
#define IPSET_DIM_MAX 3
|
|
|
|
typedef unsigned short ip_set_id_t;
|
|
|
|
#endif
|
|
|
|
#include <linux/netfilter/xt_set.h>
|
|
|
|
|
|
|
|
struct xt_set_info info;
|
2020-07-07 15:58:33 +08:00
|
|
|
#if IPSET_PROTOCOL == 6 || IPSET_PROTOCOL == 7
|
2012-08-09 17:18:50 +08:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return IPSET_MAXNAMELEN;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#error unknown ipset version
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE -o $TMPDIR/ipsettest $TMPDIR/ipsettest.c >/dev/null 2>&1; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "TC_CONFIG_IPSET:=y" >>$CONFIG
|
2012-08-09 17:18:50 +08:00
|
|
|
echo "yes"
|
2012-12-19 01:20:13 +08:00
|
|
|
else
|
2012-08-09 17:18:50 +08:00
|
|
|
echo "no"
|
2012-12-19 01:20:13 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/ipsettest.c $TMPDIR/ipsettest
|
2012-08-09 17:18:50 +08:00
|
|
|
}
|
|
|
|
|
2015-03-17 02:37:41 +08:00
|
|
|
check_elf()
|
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ${PKG_CONFIG} libelf --exists; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "HAVE_ELF:=y" >>$CONFIG
|
2015-03-17 02:37:41 +08:00
|
|
|
echo "yes"
|
2017-08-11 08:05:03 +08:00
|
|
|
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'CFLAGS += -DHAVE_ELF' "$(${PKG_CONFIG} libelf --cflags)" >> $CONFIG
|
|
|
|
echo 'LDLIBS += ' "$(${PKG_CONFIG} libelf --libs)" >>$CONFIG
|
2015-03-17 02:37:41 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-11-23 21:11:57 +08:00
|
|
|
have_libbpf_basic()
|
|
|
|
{
|
|
|
|
cat >$TMPDIR/libbpf_test.c <<EOF
|
|
|
|
#include <bpf/libbpf.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
bpf_program__set_autoload(NULL, false);
|
|
|
|
bpf_map__ifindex(NULL);
|
|
|
|
bpf_map__set_pin_path(NULL, NULL);
|
|
|
|
bpf_object__open_file(NULL, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
$CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
|
|
|
local ret=$?
|
|
|
|
|
|
|
|
rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
have_libbpf_sec_name()
|
|
|
|
{
|
|
|
|
cat >$TMPDIR/libbpf_sec_test.c <<EOF
|
|
|
|
#include <bpf/libbpf.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
void *ptr;
|
|
|
|
bpf_program__section_name(NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
$CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
|
|
|
local ret=$?
|
|
|
|
|
|
|
|
rm -f $TMPDIR/libbpf_sec_test.c $TMPDIR/libbpf_sec_test
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
|
|
|
check_force_libbpf_on()
|
|
|
|
{
|
|
|
|
# if set LIBBPF_FORCE=on but no libbpf support, just exist the config
|
|
|
|
# process to make sure we don't build without libbpf.
|
|
|
|
if [ "$LIBBPF_FORCE" = on ]; then
|
|
|
|
echo " LIBBPF_FORCE=on set, but couldn't find a usable libbpf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_libbpf()
|
|
|
|
{
|
|
|
|
# if set LIBBPF_FORCE=off, disable libbpf entirely
|
|
|
|
if [ "$LIBBPF_FORCE" = off ]; then
|
|
|
|
echo "no"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then
|
|
|
|
echo "no"
|
|
|
|
check_force_libbpf_on
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $(uname -m) = x86_64 ]; then
|
|
|
|
local LIBBPF_LIBDIR="${LIBBPF_DIR}/usr/lib64"
|
|
|
|
else
|
|
|
|
local LIBBPF_LIBDIR="${LIBBPF_DIR}/usr/lib"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$LIBBPF_DIR" ]; then
|
|
|
|
LIBBPF_CFLAGS="-I${LIBBPF_DIR}/usr/include"
|
|
|
|
LIBBPF_LDLIBS="${LIBBPF_LIBDIR}/libbpf.a -lz -lelf"
|
|
|
|
LIBBPF_VERSION=$(PKG_CONFIG_LIBDIR=${LIBBPF_LIBDIR}/pkgconfig ${PKG_CONFIG} libbpf --modversion)
|
|
|
|
else
|
|
|
|
LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags)
|
|
|
|
LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs)
|
|
|
|
LIBBPF_VERSION=$(${PKG_CONFIG} libbpf --modversion)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! have_libbpf_basic; then
|
|
|
|
echo "no"
|
|
|
|
echo " libbpf version $LIBBPF_VERSION is too low, please update it to at least 0.1.0"
|
|
|
|
check_force_libbpf_on
|
|
|
|
return
|
|
|
|
else
|
|
|
|
echo "HAVE_LIBBPF:=y" >> $CONFIG
|
|
|
|
echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG
|
|
|
|
echo "CFLAGS += -DLIBBPF_VERSION=\\\"$LIBBPF_VERSION\\\"" >> $CONFIG
|
|
|
|
echo 'LDLIBS += ' $LIBBPF_LDLIBS >> $CONFIG
|
|
|
|
|
|
|
|
if [ -z "$LIBBPF_DIR" ]; then
|
|
|
|
echo "CFLAGS += -DLIBBPF_DYNAMIC" >> $CONFIG
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# bpf_program__title() is deprecated since libbpf 0.2.0, use
|
|
|
|
# bpf_program__section_name() instead if we support
|
|
|
|
if have_libbpf_sec_name; then
|
|
|
|
echo "HAVE_LIBBPF_SECTION_NAME:=y" >> $CONFIG
|
|
|
|
echo 'CFLAGS += -DHAVE_LIBBPF_SECTION_NAME ' >> $CONFIG
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "yes"
|
|
|
|
echo " libbpf version $LIBBPF_VERSION"
|
|
|
|
}
|
|
|
|
|
2014-03-07 18:36:52 +08:00
|
|
|
check_selinux()
|
|
|
|
# SELinux is a compile time option in the ss utility
|
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ${PKG_CONFIG} libselinux --exists; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "HAVE_SELINUX:=y" >>$CONFIG
|
2014-03-07 18:36:52 +08:00
|
|
|
echo "yes"
|
2017-08-11 08:05:03 +08:00
|
|
|
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'LDLIBS +=' "$(${PKG_CONFIG} --libs libselinux)" >>$CONFIG
|
|
|
|
echo 'CFLAGS += -DHAVE_SELINUX' "$(${PKG_CONFIG} --cflags libselinux)" >>$CONFIG
|
2014-03-07 18:36:52 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-17 02:52:13 +08:00
|
|
|
check_tirpc()
|
|
|
|
{
|
|
|
|
if ${PKG_CONFIG} libtirpc --exists; then
|
|
|
|
echo "HAVE_RPC:=y" >>$CONFIG
|
|
|
|
echo "yes"
|
|
|
|
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'LDLIBS +=' "$(${PKG_CONFIG} --libs libtirpc)" >>$CONFIG
|
|
|
|
echo 'CFLAGS += -DHAVE_RPC' "$(${PKG_CONFIG} --cflags libtirpc)" >>$CONFIG
|
2022-03-17 02:52:13 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-05-29 18:27:41 +08:00
|
|
|
check_mnl()
|
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ${PKG_CONFIG} libmnl --exists; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "HAVE_MNL:=y" >>$CONFIG
|
2015-09-19 00:17:13 +08:00
|
|
|
echo "yes"
|
2017-08-11 08:05:03 +08:00
|
|
|
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'CFLAGS += -DHAVE_LIBMNL' "$(${PKG_CONFIG} libmnl --cflags)" >>$CONFIG
|
|
|
|
echo 'LDLIBS +=' "$(${PKG_CONFIG} libmnl --libs)" >> $CONFIG
|
2015-05-29 18:27:41 +08:00
|
|
|
else
|
2015-09-19 00:17:13 +08:00
|
|
|
echo "no"
|
2015-05-29 18:27:41 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-09-19 00:17:13 +08:00
|
|
|
check_berkeley_db()
|
|
|
|
{
|
|
|
|
cat >$TMPDIR/dbtest.c <<EOF
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <db_185.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
dbopen("/tmp/xxx_test_db.db", O_CREAT|O_RDWR, 0644, DB_HASH, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE -o $TMPDIR/dbtest $TMPDIR/dbtest.c -ldb >/dev/null 2>&1; then
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "HAVE_BERKELEY_DB:=y" >>$CONFIG
|
2015-09-19 00:17:13 +08:00
|
|
|
echo "yes"
|
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/dbtest.c $TMPDIR/dbtest
|
|
|
|
}
|
|
|
|
|
2017-10-09 13:49:44 +08:00
|
|
|
check_strlcpy()
|
|
|
|
{
|
|
|
|
cat >$TMPDIR/strtest.c <<EOF
|
|
|
|
#include <string.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
char dst[10];
|
|
|
|
strlcpy(dst, "test", sizeof(dst));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2018-12-16 02:00:42 +08:00
|
|
|
if $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1; then
|
2017-10-09 13:49:44 +08:00
|
|
|
echo "no"
|
|
|
|
else
|
2018-12-16 02:00:42 +08:00
|
|
|
if ${PKG_CONFIG} libbsd --exists; then
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'CFLAGS += -DHAVE_LIBBSD' "$(${PKG_CONFIG} libbsd --cflags)" >>$CONFIG
|
|
|
|
echo 'LDLIBS +=' "$(${PKG_CONFIG} libbsd --libs)" >> $CONFIG
|
2018-11-01 02:00:11 +08:00
|
|
|
echo "no"
|
|
|
|
else
|
|
|
|
echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
|
|
|
|
echo "yes"
|
|
|
|
fi
|
2017-10-09 13:49:44 +08:00
|
|
|
fi
|
|
|
|
rm -f $TMPDIR/strtest.c $TMPDIR/strtest
|
|
|
|
}
|
|
|
|
|
2018-03-28 01:48:55 +08:00
|
|
|
check_cap()
|
|
|
|
{
|
2018-12-16 02:00:42 +08:00
|
|
|
if ${PKG_CONFIG} libcap --exists; then
|
2018-03-28 01:48:55 +08:00
|
|
|
echo "HAVE_CAP:=y" >>$CONFIG
|
|
|
|
echo "yes"
|
|
|
|
|
2023-12-29 14:00:09 +08:00
|
|
|
echo 'CFLAGS += -DHAVE_LIBCAP' "$(${PKG_CONFIG} libcap --cflags)" >>$CONFIG
|
|
|
|
echo 'LDLIBS +=' "$(${PKG_CONFIG} libcap --libs)" >> $CONFIG
|
2018-03-28 01:48:55 +08:00
|
|
|
else
|
|
|
|
echo "no"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-09-14 01:58:25 +08:00
|
|
|
check_color()
|
|
|
|
{
|
|
|
|
case "$COLOR" in
|
|
|
|
never)
|
|
|
|
echo 'CONF_COLOR:=COLOR_OPT_NEVER' >> $CONFIG
|
|
|
|
echo 'never'
|
|
|
|
;;
|
|
|
|
auto)
|
|
|
|
echo 'CONF_COLOR:=COLOR_OPT_AUTO' >> $CONFIG
|
|
|
|
echo 'auto'
|
|
|
|
;;
|
|
|
|
always)
|
|
|
|
echo 'CONF_COLOR:=COLOR_OPT_ALWAYS' >> $CONFIG
|
|
|
|
echo 'always'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2016-05-25 06:04:49 +08:00
|
|
|
quiet_config()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
# user can control verbosity similar to kernel builds (e.g., V=1)
|
|
|
|
ifeq ("\$(origin V)", "command line")
|
|
|
|
VERBOSE = \$(V)
|
|
|
|
endif
|
|
|
|
ifndef VERBOSE
|
|
|
|
VERBOSE = 0
|
|
|
|
endif
|
|
|
|
ifeq (\$(VERBOSE),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (\$(VERBOSE), 0)
|
|
|
|
QUIET_CC = @echo ' CC '\$@;
|
|
|
|
QUIET_AR = @echo ' AR '\$@;
|
|
|
|
QUIET_LINK = @echo ' LINK '\$@;
|
|
|
|
QUIET_YACC = @echo ' YACC '\$@;
|
|
|
|
QUIET_LEX = @echo ' LEX '\$@;
|
|
|
|
endif
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2021-05-31 17:47:39 +08:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: $0 [OPTIONS]
|
2023-09-14 01:58:25 +08:00
|
|
|
--color <never|auto|always> Default color output configuration. Available options:
|
|
|
|
never: color output is disabled (default)
|
|
|
|
auto: color output is enabled if stdout is a terminal
|
|
|
|
always: color output is enabled regardless of stdout state
|
2021-10-14 16:50:52 +08:00
|
|
|
--include_dir <dir> Path to iproute2 include dir
|
2021-10-14 16:50:55 +08:00
|
|
|
--libdir <dir> Path to iproute2 lib dir
|
2021-10-14 16:50:52 +08:00
|
|
|
--libbpf_dir <dir> Path to libbpf DESTDIR
|
|
|
|
--libbpf_force <on|off> Enable/disable libbpf by force. Available options:
|
|
|
|
on: require link against libbpf, quit config if no libbpf support
|
|
|
|
off: disable libbpf probing
|
2021-10-14 16:50:54 +08:00
|
|
|
--prefix <dir> Path prefix of the lib files to install
|
2021-10-14 16:50:52 +08:00
|
|
|
-h | --help Show this usage info
|
2021-05-31 17:47:39 +08:00
|
|
|
EOF
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compat with the old INCLUDE path setting method.
|
|
|
|
if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then
|
|
|
|
INCLUDE="$1"
|
|
|
|
else
|
2021-10-14 16:50:52 +08:00
|
|
|
while [ "$#" -gt 0 ]; do
|
2021-05-31 17:47:39 +08:00
|
|
|
case "$1" in
|
2023-09-14 01:58:25 +08:00
|
|
|
--color)
|
|
|
|
shift
|
|
|
|
COLOR="$1" ;;
|
|
|
|
--color=*)
|
|
|
|
COLOR="${1#*=}" ;;
|
2021-05-31 17:47:39 +08:00
|
|
|
--include_dir)
|
2021-10-14 16:50:49 +08:00
|
|
|
shift
|
2021-10-14 16:50:52 +08:00
|
|
|
INCLUDE="$1" ;;
|
2021-10-14 16:50:53 +08:00
|
|
|
--include_dir=*)
|
|
|
|
INCLUDE="${1#*=}" ;;
|
2021-10-14 16:50:55 +08:00
|
|
|
--libdir)
|
|
|
|
shift
|
|
|
|
LIBDIR="$1" ;;
|
|
|
|
--libdir=*)
|
|
|
|
LIBDIR="${1#*=}" ;;
|
2021-05-31 17:47:40 +08:00
|
|
|
--libbpf_dir)
|
2021-10-14 16:50:50 +08:00
|
|
|
shift
|
2021-10-14 16:50:52 +08:00
|
|
|
LIBBPF_DIR="$1" ;;
|
2021-10-14 16:50:53 +08:00
|
|
|
--libbpf_dir=*)
|
|
|
|
LIBBPF_DIR="${1#*=}" ;;
|
2021-05-31 17:47:40 +08:00
|
|
|
--libbpf_force)
|
2021-10-14 16:50:52 +08:00
|
|
|
shift
|
|
|
|
LIBBPF_FORCE="$1" ;;
|
2021-10-14 16:50:53 +08:00
|
|
|
--libbpf_force=*)
|
|
|
|
LIBBPF_FORCE="${1#*=}" ;;
|
2021-10-14 16:50:54 +08:00
|
|
|
--prefix)
|
|
|
|
shift
|
|
|
|
PREFIX="$1" ;;
|
|
|
|
--prefix=*)
|
|
|
|
PREFIX="${1#*=}" ;;
|
2021-05-31 17:47:39 +08:00
|
|
|
-h | --help)
|
|
|
|
usage 0 ;;
|
2021-10-14 16:50:51 +08:00
|
|
|
--*)
|
2021-10-14 16:50:52 +08:00
|
|
|
;;
|
2021-05-31 17:47:39 +08:00
|
|
|
*)
|
2021-10-14 16:50:51 +08:00
|
|
|
usage 1 ;;
|
2021-05-31 17:47:39 +08:00
|
|
|
esac
|
2021-10-14 16:50:52 +08:00
|
|
|
[ "$#" -gt 0 ] && shift
|
2021-05-31 17:47:39 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2023-09-14 01:58:25 +08:00
|
|
|
case "$COLOR" in
|
|
|
|
never) ;;
|
|
|
|
auto) ;;
|
|
|
|
always) ;;
|
|
|
|
*) usage 1 ;;
|
|
|
|
esac
|
2021-10-14 16:50:49 +08:00
|
|
|
[ -d "$INCLUDE" ] || usage 1
|
2021-10-14 16:50:50 +08:00
|
|
|
if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
|
|
|
|
[ -d "$LIBBPF_DIR" ] || usage 1
|
|
|
|
fi
|
2021-10-14 16:50:52 +08:00
|
|
|
if [ "${LIBBPF_FORCE-unused}" != "unused" ]; then
|
|
|
|
if [ "$LIBBPF_FORCE" != 'on' ] && [ "$LIBBPF_FORCE" != 'off' ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
fi
|
2021-10-14 16:50:54 +08:00
|
|
|
[ -z "$PREFIX" ] && usage 1
|
2021-10-14 16:50:55 +08:00
|
|
|
[ -z "$LIBDIR" ] && usage 1
|
2021-10-14 16:50:49 +08:00
|
|
|
|
2017-08-11 08:05:03 +08:00
|
|
|
echo "# Generated config based on" $INCLUDE >$CONFIG
|
|
|
|
quiet_config >> $CONFIG
|
2016-05-25 06:04:49 +08:00
|
|
|
|
2012-12-17 06:09:15 +08:00
|
|
|
check_toolchain
|
2009-12-02 13:12:30 +08:00
|
|
|
|
|
|
|
echo "TC schedulers"
|
|
|
|
|
2016-10-18 20:13:09 +08:00
|
|
|
check_xtables
|
2018-12-16 02:00:42 +08:00
|
|
|
if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
|
2016-10-18 20:13:09 +08:00
|
|
|
echo -n " IPT "
|
|
|
|
check_xt
|
|
|
|
check_xt_old
|
|
|
|
check_xt_old_internal_h
|
|
|
|
check_ipt
|
2009-12-02 13:12:30 +08:00
|
|
|
|
2016-10-18 20:13:09 +08:00
|
|
|
echo -n " IPSET "
|
|
|
|
check_ipset
|
|
|
|
fi
|
2012-08-09 17:18:50 +08:00
|
|
|
|
2015-06-26 03:10:22 +08:00
|
|
|
echo
|
2021-10-14 16:50:55 +08:00
|
|
|
check_lib_dir
|
2018-12-16 02:00:42 +08:00
|
|
|
if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
|
2016-10-18 20:13:09 +08:00
|
|
|
echo -n "iptables modules directory: "
|
|
|
|
check_ipt_lib_dir
|
|
|
|
fi
|
2011-07-15 22:26:59 +08:00
|
|
|
|
|
|
|
echo -n "libc has setns: "
|
|
|
|
check_setns
|
2014-03-07 18:36:52 +08:00
|
|
|
|
2021-05-08 14:49:26 +08:00
|
|
|
echo -n "libc has name_to_handle_at: "
|
|
|
|
check_name_to_handle_at
|
|
|
|
|
2014-03-07 18:36:52 +08:00
|
|
|
echo -n "SELinux support: "
|
|
|
|
check_selinux
|
2014-12-01 00:08:25 +08:00
|
|
|
|
2022-03-17 02:52:13 +08:00
|
|
|
echo -n "libtirpc support: "
|
|
|
|
check_tirpc
|
|
|
|
|
2020-11-23 21:11:57 +08:00
|
|
|
echo -n "libbpf support: "
|
|
|
|
check_libbpf
|
|
|
|
|
2015-03-17 02:37:41 +08:00
|
|
|
echo -n "ELF support: "
|
|
|
|
check_elf
|
|
|
|
|
2015-05-29 18:27:41 +08:00
|
|
|
echo -n "libmnl support: "
|
|
|
|
check_mnl
|
|
|
|
|
2015-09-19 00:17:13 +08:00
|
|
|
echo -n "Berkeley DB: "
|
|
|
|
check_berkeley_db
|
|
|
|
|
2017-10-09 13:49:44 +08:00
|
|
|
echo -n "need for strlcpy: "
|
|
|
|
check_strlcpy
|
|
|
|
|
2018-03-28 01:48:55 +08:00
|
|
|
echo -n "libcap support: "
|
|
|
|
check_cap
|
|
|
|
|
2023-09-14 01:58:25 +08:00
|
|
|
echo -n "color output: "
|
|
|
|
check_color
|
|
|
|
|
2017-08-11 08:05:03 +08:00
|
|
|
echo >> $CONFIG
|
|
|
|
echo "%.o: %.c" >> $CONFIG
|
2018-11-02 20:35:44 +08:00
|
|
|
echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG
|