Skip to contentSkip to conversation

Change default KERNEL_DIR location and add KBUILD_OUTPUT

PATCH Applied Sven Wegener 2 participants 6 messages Jul 14, 2007 – Jul 15, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
Index: Makefile
===================================================================
@@ -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
#1 lore raw
Quoted 4 lines · Sven Wegener

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.

Good point.

Quoted 3 lines

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.

What do we need KBUILD_OUTPUT for? Just the source tree should be enough.

#2 lore raw
Quoted 6 lines · Patrick McHardy
Quoted 4 lines · Sven Wegener

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.

Quoted 7 lines

Good point.

Quoted 3 lines

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.

What do we need KBUILD_OUTPUT for? 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

#3 lore raw
Quoted 5 lines · Sven Wegener
Quoted 1 line · Patrick McHardy

What do we need KBUILD_OUTPUT for? 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.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?

I don't see why not. A short comment in the Makefile explaining the situation would be nice though.

#4 lore raw
Quoted 2 lines · Patrick McHardy

I don't see why not. A short comment in the Makefile explaining the situation would be nice though.

Updated patch attached.

Makefile +8 -2
Index: Makefile
===================================================================
@@ -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
#5 lore raw
Quoted 8 lines · Sven Wegener
Quoted 3 lines · Patrick McHardy

I don't see why not. A short comment in the Makefile explaining the situation would be nice though.

Updated patch attached.

Applied, thanks Sven.