UAPI: Partition the header include path sets and add uapi/ header directories
authorDavid Howells <dhowells@redhat.com>
Tue, 2 Oct 2012 17:01:26 +0000 (18:01 +0100)
committerDavid Howells <dhowells@redhat.com>
Tue, 2 Oct 2012 17:01:26 +0000 (18:01 +0100)
Partition the header include path flags into two sets, one for kernelspace
builds and one for userspace builds.

Add the following directories to build after the ordinary include directories
so that #include will pick up the UAPI header directly if the kernel header
has been moved there.

The userspace set (represented by the USERINCLUDE make variable) contains:

-I $(srctree)/arch/$(hdr-arch)/include/uapi
-I arch/$(hdr-arch)/include/generated/uapi
-I $(srctree)/include/uapi
-I include/generated/uapi
-include $(srctree)/include/linux/kconfig.h

and the kernelspace set (represented by the LINUXINCLUDE make variable)
contains:

-I $(srctree)/arch/$(hdr-arch)/include
-I arch/$(hdr-arch)/include/generated
-I $(srctree)/include
-I include --- if not building in the source tree

plus everything in the USERINCLUDE set.

Then use USERINCLUDE in building the x86 boot code.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Dave Jones <davej@redhat.com>
Makefile
arch/cris/Makefile
arch/um/Makefile
arch/x86/boot/Makefile
arch/x86/boot/mkcpustr.c
arch/x86/include/asm/cpufeature.h
arch/x86/kernel/cpu/mkcapflags.pl

index 846dd7607854f3ad1a63eb2af2ebd42faf92e9b9..da1707c3904b53dc1374f04326cd65990090516a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -350,12 +350,22 @@ AFLAGS_KERNEL     =
 CFLAGS_GCOV    = -fprofile-arcs -ftest-coverage
 
 
+# Use USERINCLUDE when you must reference the UAPI directories only.
+USERINCLUDE    := \
+               -I$(srctree)/arch/$(hdr-arch)/include/uapi \
+               -Iarch/$(hdr-arch)/include/generated/uapi \
+               -I$(srctree)/include/uapi \
+               -Iinclude/generated/uapi \
+                -include $(srctree)/include/linux/kconfig.h
+
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
-LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
-                   -Iarch/$(hdr-arch)/include/generated -Iinclude \
-                   $(if $(KBUILD_SRC), -I$(srctree)/include) \
-                   -include $(srctree)/include/linux/kconfig.h
+LINUXINCLUDE    := \
+               -I$(srctree)/arch/$(hdr-arch)/include \
+               -Iarch/$(hdr-arch)/include/generated \
+               $(if $(KBUILD_SRC), -I$(srctree)/include) \
+               -Iinclude \
+               $(USERINCLUDE)
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
index 29c2ceb38a76dd05fb98e9728e53b2d0753df0df..39dc7d00083e10d393337a66bb0225052accf0cb 100644 (file)
@@ -23,7 +23,9 @@ mach-$(CONFIG_ETRAXFS) := fs
 
 ifneq ($(arch-y),)
 SARCH := arch-$(arch-y)
-inc := -Iarch/cris/include/$(SARCH)
+inc := -Iarch/cris/include/uapi/$(SARCH)
+inc += -Iarch/cris/include/$(SARCH)
+inc += -Iarch/cris/include/uapi/$(SARCH)/arch
 inc += -Iarch/cris/include/$(SARCH)/arch
 else
 SARCH :=
index 097091059aaaee32883d4a302457fcb4a630854f..133f7de2a13d5ade42c217c56c74604ae6a39a58 100644 (file)
@@ -66,7 +66,9 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
 
 KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
-                  -I$(HOST_DIR)/include/generated
+                  -I$(srctree)/$(HOST_DIR)/include/uapi \
+                  -I$(HOST_DIR)/include/generated \
+                  -I$(HOST_DIR)/include/generated/uapi
 
 # -Derrno=kernel_errno - This turns all kernel references to errno into
 # kernel_errno to separate them from the libc errno.  This allows -fno-common
index f7535bedc33f3b73ee6c0d0b276435ae4b9fb8be..ce03476d8c8f6668162af05ae0712be32917b131 100644 (file)
@@ -37,7 +37,7 @@ setup-y               += video-bios.o
 targets                += $(setup-y)
 hostprogs-y    := mkcpustr tools/build
 
-HOST_EXTRACFLAGS += -I$(srctree)/tools/include $(LINUXINCLUDE) \
+HOST_EXTRACFLAGS += -I$(srctree)/tools/include $(USERINCLUDE) \
                    -D__EXPORTED_HEADERS__
 
 $(obj)/cpu.o: $(obj)/cpustr.h
@@ -52,7 +52,7 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
 
 # How to compile the 16-bit code.  Note we always compile for -march=i386,
 # that way we can complain to the user if the CPU is insufficient.
-KBUILD_CFLAGS  := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
+KBUILD_CFLAGS  := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
                   -DDISABLE_BRANCH_PROFILING \
                   -Wall -Wstrict-prototypes \
                   -march=i386 -mregparm=3 \
index 919257f526f233ee1dee836bdd26c25c77076c3f..4579eff0ef4db19fcff2f6336f6f82ab9b5d6998 100644 (file)
@@ -15,6 +15,8 @@
 
 #include <stdio.h>
 
+#include "../include/asm/required-features.h"
+#include "../include/asm/cpufeature.h"
 #include "../kernel/cpu/capflags.c"
 
 int main(void)
index 16cae425d1f80fe40a6b1d6785b0d494a0566b8b..8c297aa53eef1cdcc8de35d058ae7b0b933f5dbb 100644 (file)
@@ -4,7 +4,9 @@
 #ifndef _ASM_X86_CPUFEATURE_H
 #define _ASM_X86_CPUFEATURE_H
 
+#ifndef _ASM_X86_REQUIRED_FEATURES_H
 #include <asm/required-features.h>
+#endif
 
 #define NCAPINTS       10      /* N 32-bit words worth of info */
 
index c7b3fe2d72e0f71b94577fde23622a8797eca941..091972ef49de830c32f7547753d9ad5f5ec01f01 100644 (file)
@@ -8,7 +8,10 @@
 open(IN, "< $in\0")   or die "$0: cannot open: $in: $!\n";
 open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
 
-print OUT "#include <asm/cpufeature.h>\n\n";
+print OUT "#ifndef _ASM_X86_CPUFEATURE_H\n";
+print OUT "#include <asm/cpufeature.h>\n";
+print OUT "#endif\n";
+print OUT "\n";
 print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
 
 %features = ();