Skip to content

Commit abbf159

Browse files
committed
UAPI: Partition the header include path sets and add uapi/ header directories
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 <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Acked-by: Dave Jones <[email protected]>
1 parent a1ce392 commit abbf159

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

Makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,22 @@ AFLAGS_KERNEL =
350350
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
351351

352352

353+
# Use USERINCLUDE when you must reference the UAPI directories only.
354+
USERINCLUDE := \
355+
-I$(srctree)/arch/$(hdr-arch)/include/uapi \
356+
-Iarch/$(hdr-arch)/include/generated/uapi \
357+
-I$(srctree)/include/uapi \
358+
-Iinclude/generated/uapi \
359+
-include $(srctree)/include/linux/kconfig.h
360+
353361
# Use LINUXINCLUDE when you must reference the include/ directory.
354362
# Needed to be compatible with the O= option
355-
LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
356-
-Iarch/$(hdr-arch)/include/generated -Iinclude \
357-
$(if $(KBUILD_SRC), -I$(srctree)/include) \
358-
-include $(srctree)/include/linux/kconfig.h
363+
LINUXINCLUDE := \
364+
-I$(srctree)/arch/$(hdr-arch)/include \
365+
-Iarch/$(hdr-arch)/include/generated \
366+
$(if $(KBUILD_SRC), -I$(srctree)/include) \
367+
-Iinclude \
368+
$(USERINCLUDE)
359369

360370
KBUILD_CPPFLAGS := -D__KERNEL__
361371

arch/cris/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ mach-$(CONFIG_ETRAXFS) := fs
2323

2424
ifneq ($(arch-y),)
2525
SARCH := arch-$(arch-y)
26-
inc := -Iarch/cris/include/$(SARCH)
26+
inc := -Iarch/cris/include/uapi/$(SARCH)
27+
inc += -Iarch/cris/include/$(SARCH)
28+
inc += -Iarch/cris/include/uapi/$(SARCH)/arch
2729
inc += -Iarch/cris/include/$(SARCH)/arch
2830
else
2931
SARCH :=

arch/um/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
6666
include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
6767

6868
KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
69-
-I$(HOST_DIR)/include/generated
69+
-I$(srctree)/$(HOST_DIR)/include/uapi \
70+
-I$(HOST_DIR)/include/generated \
71+
-I$(HOST_DIR)/include/generated/uapi
7072

7173
# -Derrno=kernel_errno - This turns all kernel references to errno into
7274
# kernel_errno to separate them from the libc errno. This allows -fno-common

arch/x86/boot/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ setup-y += video-bios.o
3737
targets += $(setup-y)
3838
hostprogs-y := mkcpustr tools/build
3939

40-
HOST_EXTRACFLAGS += -I$(srctree)/tools/include $(LINUXINCLUDE) \
40+
HOST_EXTRACFLAGS += -I$(srctree)/tools/include $(USERINCLUDE) \
4141
-D__EXPORTED_HEADERS__
4242

4343
$(obj)/cpu.o: $(obj)/cpustr.h
@@ -52,7 +52,7 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
5252

5353
# How to compile the 16-bit code. Note we always compile for -march=i386,
5454
# that way we can complain to the user if the CPU is insufficient.
55-
KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
55+
KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
5656
-DDISABLE_BRANCH_PROFILING \
5757
-Wall -Wstrict-prototypes \
5858
-march=i386 -mregparm=3 \

arch/x86/boot/mkcpustr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include <stdio.h>
1717

18+
#include "../include/asm/required-features.h"
19+
#include "../include/asm/cpufeature.h"
1820
#include "../kernel/cpu/capflags.c"
1921

2022
int main(void)

arch/x86/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#ifndef _ASM_X86_CPUFEATURE_H
55
#define _ASM_X86_CPUFEATURE_H
66

7+
#ifndef _ASM_X86_REQUIRED_FEATURES_H
78
#include <asm/required-features.h>
9+
#endif
810

911
#define NCAPINTS 10 /* N 32-bit words worth of info */
1012

arch/x86/kernel/cpu/mkcapflags.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n";
99
open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
1010

11-
print OUT "#include <asm/cpufeature.h>\n\n";
11+
print OUT "#ifndef _ASM_X86_CPUFEATURE_H\n";
12+
print OUT "#include <asm/cpufeature.h>\n";
13+
print OUT "#endif\n";
14+
print OUT "\n";
1215
print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
1316

1417
%features = ();

0 commit comments

Comments
 (0)