iproute2: simplify Makefile, patches and fix feature detection
authorTony Ambardar <itugrok@yahoo.com>
Sat, 24 Nov 2018 07:56:24 +0000 (23:56 -0800)
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Mon, 11 Feb 2019 20:18:48 +0000 (20:18 +0000)
Compile-based feature detection (e.g. xtables, ipset support) was broken
due to silent compilation errors in the configure script, caused by a
Makefile variable KERNEL_INCLUDE referring to kernel build headers. Use
userspace headers by setting the same "user_headers" kernel include path
as used for the iptables build.

Remove redundant or unused Build/Configure definitions from package
Makefile, including KERNEL_INCLUDE, LIBC_INCLUDE and DBM includes.

Don't pass LDFLAGS within MAKE_FLAGS as this interferes with LDFLAGS in
tc/Makefile and masks a link parameter ("-Wl,-export-dynamic"). Instead,
use standard TARGET_LDFLAGS.

Replace EXTRA_CCOPTS in MAKE_FLAGS with cleaner TARGET_CPPFLAGS, and also
drop now unneeded patch 150-extra-ccopts.patch.

Enable defining XT_LIB_DIR from Makefile, needed to set the iptables
modules directory to something other than /lib/xtables, and also add
libxtables dependency. Both are needed with working xtables detection.
Note that libxtables is also pulled in by iptables, firewall or luci, so
this change has no size impact in most cases.

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
package/network/utils/iproute2/Makefile
package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch [new file with mode: 0644]
package/network/utils/iproute2/patches/150-extra-ccopts.patch [deleted file]

index 188b5150ffb527a5fc17848f3db88d5c1a3c747e..e7fa6e479dfaa3a562ec906cf4bf6c28a32fdda1 100644 (file)
@@ -54,7 +54,7 @@ endef
 define Package/tc
 $(call Package/iproute2/Default)
   TITLE:=Traffic control utility
 define Package/tc
 $(call Package/iproute2/Default)
   TITLE:=Traffic control utility
-  DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libelf
+  DEPENDS:=+kmod-sched-core +libxtables +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
 endef
 
 define Package/genl
 endef
 
 define Package/genl
@@ -106,25 +106,21 @@ ifdef CONFIG_PACKAGE_rdma
 endif
 
 define Build/Configure
 endif
 
 define Build/Configure
-       $(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
-       $(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
-               $(PKG_BUILD_DIR)/Makefile
-       $(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
-               $(PKG_BUILD_DIR)/Makefile
        echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
                > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
 endef
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
        echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
                > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
 endef
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
 
 MAKE_FLAGS += \
 
 MAKE_FLAGS += \
-       EXTRA_CCOPTS="-I$(STAGING_DIR)/usr/include/libnl-tiny" \
-       KERNEL_INCLUDE="$(LINUX_DIR)/include" \
+       KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
        SHARED_LIBS="" \
        SHARED_LIBS="" \
-       LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \
        IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
        HAVE_MNL=$(HAVE_MNL) \
        IPT_LIB_DIR=/usr/lib/iptables \
        IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
        HAVE_MNL=$(HAVE_MNL) \
        IPT_LIB_DIR=/usr/lib/iptables \
+       XT_LIB_DIR=/usr/lib/iptables \
        FPIC="$(FPIC)"
 
 define Build/Compile
        FPIC="$(FPIC)"
 
 define Build/Compile
diff --git a/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch b/package/network/utils/iproute2/patches/115-add-config-xtlibdir.patch
new file mode 100644 (file)
index 0000000..6795be7
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/tc/Makefile
++++ b/tc/Makefile
+@@ -120,6 +120,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR
+ ifneq ($(IPT_LIB_DIR),)
+       CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
+ endif
++ifneq ($(XT_LIB_DIR),)
++      CFLAGS += -DXT_LIB_DIR=\"$(XT_LIB_DIR)\"
++endif
+ YACC := bison
+ LEX := flex
diff --git a/package/network/utils/iproute2/patches/150-extra-ccopts.patch b/package/network/utils/iproute2/patches/150-extra-ccopts.patch
deleted file mode 100644 (file)
index d036ba7..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/Makefile
-+++ b/Makefile
-@@ -54,7 +54,7 @@ HOSTCC ?= $(CC)
- DEFINES += -D_GNU_SOURCE
- # Turn on transparent support for LFS
- DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
--CCOPTS = -O2
-+CCOPTS = -O2 $(EXTRA_CCOPTS)
- WFLAGS := -Wall -Wstrict-prototypes  -Wmissing-prototypes
- WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2