[patch] 2.4.12 optionally prevent kbuild reading /usr/include

Keith Owens (kaos@ocs.com.au)
Tue, 16 Oct 2001 17:17:45 +1000


A few bits of kernel code are incorrectly reading from /usr/include,
giving different results on different distributions. kbuild 2.5 will
prevent this, all include files must be in the kernel tree. The patch
below (for 2.4.12 but fits 2.4.13-pre3) defines kbuild_2_4_nostdinc.
Linus, please add to 2.4.13-prex.

The various maintainers can optionally check that their code is not
reading from outside the kernel, see the comments in the patch. I
strongly recommend that maintainers check their code now, even if it is
only on their own machine. There is no need to patch the sub Makefiles
in Linus's tree, as long as the code has been tested.

Based on a suggestion by Christoph Hellwig.

Index: 12.1/Makefile
--- 12.1/Makefile Thu, 11 Oct 2001 20:11:18 +1000 kaos (linux-2.4/T/c/50_Makefile 1.1.2.15.1.2.2.25.2.2.1.17.1.4.1.29.1.4 644)
+++ 12.1(w)/Makefile Tue, 16 Oct 2001 17:08:15 +1000 kaos (linux-2.4/T/c/50_Makefile 1.1.2.15.1.2.2.25.2.2.1.17.1.4.1.29.1.4 644)
@@ -240,6 +240,16 @@ MRPROPER_DIRS = \

include arch/$(ARCH)/Makefile

+# Optional cflags for kbuild 2.4, to prevent individual files or an entire
+# directory including files from outside the kernel. To control an individual
+# file, use CFLAGS_foo.o += $(kbuild_2_4_nostdinc), to control an entire
+# directory use EXTRA_CFLAGS += $(kbuild_2_4_nostdinc). In kbuild 2.5 the
+# default is to forbid includes from outside the kernel tree, you can use this
+# variable in kbuild 2.4 to ensure that your code is clean before 2.5. KAO.
+
+kbuild_2_4_nostdinc := -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
+export kbuild_2_4_nostdinc
+
export CPPFLAGS CFLAGS AFLAGS

export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/