Change default KERNEL_DIR location and add KBUILD_OUTPUT
PATCH 1/1 Change default KERNEL_DIR location and add KBUILD_OUTPUT
Setting KERNEL_DIR to the build symlink in /lib/modules is wrong. The build symlink points to the location of generated object files and the extension tests use KERNEL_DIR to check the availability of certain source files. The tests will fail, if build and source point to different locations. Change KERNEL_DIR from build to source and introduce KBUILD_OUTPUT for the build symink.
Makefile +5 -2
@@ -12,8 +12,11 @@ TOPLEVEL_INCLUDED=YES ifndef KERNEL_DIR -KERNEL_DIR="/lib/modules/$(shell uname -r)/build" +KERNEL_DIR="/lib/modules/$(shell uname -r)/source" endif +ifndef KBUILD_OUTPUT +KBUILD_OUTPUT="/lib/modules/$(shell uname -r)/build" +endif IPTABLES_VERSION:=1.3.8 OLD_IPTABLES_VERSION:=1.3.7
@@ -37,7 +40,7 @@ endif COPT_FLAGS:=-O2 -CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG +CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KBUILD_OUTPUT)/include -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG ifdef NO_SHARED_LIBS CFLAGS += -DNO_SHARED_LIBS=1
Quoted 4 lines · Sven Wegener
Setting
KERNEL_DIRto the build symlink in/lib/modulesis wrong. The build symlink points to the location of generated object files and the extension tests useKERNEL_DIRto check the availability of certain source files.
Good point.
Quoted 3 lines
The tests will fail, if build and source point to different locations. Change
KERNEL_DIRfrom build to source and introduceKBUILD_OUTPUTfor the build symink.
What do we need KBUILD_OUTPUT for? Just the source tree should be enough.
Quoted 6 lines · Patrick McHardy
Quoted 4 lines · Sven Wegener
Setting
KERNEL_DIRto the build symlink in/lib/modulesis wrong. The build symlink points to the location of generated object files and the extension tests useKERNEL_DIRto check the availability of certain source files.
Quoted 7 lines
Good point.
Quoted 3 lines
The tests will fail, if build and source point to different locations. Change
KERNEL_DIRfrom build to source and introduceKBUILD_OUTPUTfor the build symink.What do we need
KBUILD_OUTPUTfor? Just the source tree should be enough.
For current kernels, true. Older kernels (before 2006-04-26) and the whole 2.6.16.y series have a bug where include/linux/netfilter_ipv4.h includes linux/config.h which includes linux/autoconf.h which is placed into KBUILD_OUTPUT. Just changing KERNEL_DIR from build to source should be enough for recent kernels. For older kernels building the iptables package will fail with "linux/autoconf.h: No such file or directory" unless we add the KBUILD_OUTPUT bit. That's why I added it. Do we want to have this workaround here?
Sven
Quoted 5 lines · Sven Wegener
Quoted 1 line · Patrick McHardy
What do we need
KBUILD_OUTPUTfor? Just the source tree should be enough.
Quoted 8 lines
For current kernels, true. Older kernels (before 2006-04-26) and the whole 2.6.16.y series have a bug where
include/linux/netfilter_ipv4.hincludeslinux/config.hwhich includeslinux/autoconf.hwhich is placed intoKBUILD_OUTPUT. Just changingKERNEL_DIRfrom build to source should be enough for recent kernels. For older kernels building the iptables package will fail with "linux/autoconf.h: No such file or directory" unless we add theKBUILD_OUTPUTbit. That's why I added it. Do we want to have this workaround here?
I don't see why not. A short comment in the Makefile explaining the situation would be nice though.
Quoted 2 lines · Patrick McHardy
I don't see why not. A short comment in the
Makefileexplaining the situation would be nice though.
Updated patch attached.
Makefile +8 -2
@@ -11,9 +11,15 @@ # Standard part of Makefile for topdir. TOPLEVEL_INCLUDED=YES +# For recent kernels we only need the source in KERNEL_DIR to build. Older +# kernels have a bug, where linux/netfilter_ipv4.h includes linux/config.h, +# which includes linux/autoconf.h, which is placed into KBUILD_OUTPUT. ifndef KERNEL_DIR -KERNEL_DIR="/lib/modules/$(shell uname -r)/build" +KERNEL_DIR="/lib/modules/$(shell uname -r)/source" endif +ifndef KBUILD_OUTPUT +KBUILD_OUTPUT="/lib/modules/$(shell uname -r)/build" +endif IPTABLES_VERSION:=1.3.8 OLD_IPTABLES_VERSION:=1.3.7
@@ -37,7 +43,7 @@ endif COPT_FLAGS:=-O2 -CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG +CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KBUILD_OUTPUT)/include -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG ifdef NO_SHARED_LIBS CFLAGS += -DNO_SHARED_LIBS=1
Patrick McHardy
AppliedQuoted 8 lines · Sven Wegener
Quoted 3 lines · Patrick McHardy
I don't see why not. A short comment in the
Makefileexplaining the situation would be nice though.Updated patch attached.
Applied, thanks Sven.