aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/kbuild/makefiles.txt36
-rw-r--r--Makefile16
-rw-r--r--scripts/Makefile.asm-generic23
-rw-r--r--scripts/Makefile.headersinst10
5 files changed, 81 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 5d56a3fd0de..9dacde0a4b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
57include/config 57include/config
58include/linux/version.h 58include/linux/version.h
59include/generated 59include/generated
60arch/*/include/generated
60 61
61# stgit generated dirs 62# stgit generated dirs
62patches-* 63patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 40e082bb8c5..835b64acf0b 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
40 --- 6.6 Commands useful for building a boot image 40 --- 6.6 Commands useful for building a boot image
41 --- 6.7 Custom kbuild commands 41 --- 6.7 Custom kbuild commands
42 --- 6.8 Preprocessing linker scripts 42 --- 6.8 Preprocessing linker scripts
43 --- 6.9 Generic header files
43 44
44 === 7 Kbuild syntax for exported headers 45 === 7 Kbuild syntax for exported headers
45 --- 7.1 header-y 46 --- 7.1 header-y
46 --- 7.2 objhdr-y 47 --- 7.2 objhdr-y
47 --- 7.3 destination-y 48 --- 7.3 destination-y
49 --- 7.4 generic-y
48 50
49 === 8 Kbuild Variables 51 === 8 Kbuild Variables
50 === 9 Makefile language 52 === 9 Makefile language
@@ -1214,6 +1216,14 @@ When kbuild executes, the following steps are followed (roughly):
1214 The kbuild infrastructure for *lds file are used in several 1216 The kbuild infrastructure for *lds file are used in several
1215 architecture-specific files. 1217 architecture-specific files.
1216 1218
1219--- 6.9 Generic header files
1220
1221 The directory include/asm-generic contains the header files
1222 that may be shared between individual architectures.
1223 The recommended approach how to use a generic header file is
1224 to list the file in the Kbuild file.
1225 See "7.4 generic-y" for further info on syntax etc.
1226
1217=== 7 Kbuild syntax for exported headers 1227=== 7 Kbuild syntax for exported headers
1218 1228
1219The kernel include a set of headers that is exported to userspace. 1229The kernel include a set of headers that is exported to userspace.
@@ -1270,6 +1280,32 @@ See subsequent chapter for the syntax of the Kbuild file.
1270 In the example above all exported headers in the Kbuild file 1280 In the example above all exported headers in the Kbuild file
1271 will be located in the directory "include/linux" when exported. 1281 will be located in the directory "include/linux" when exported.
1272 1282
1283 --- 7.4 generic-y
1284
1285 If an architecture uses a verbatim copy of a header from
1286 include/asm-generic then this is listed in the file
1287 arch/$(ARCH)/include/asm/Kbuild like this:
1288
1289 Example:
1290 #arch/x86/include/asm/Kbuild
1291 generic-y += termios.h
1292 generic-y += rtc.h
1293
1294 During the prepare phase of the build a wrapper include
1295 file is generated in the directory:
1296
1297 arch/$(ARCH)/include/generated/asm
1298
1299 When a header is exported where the architecture uses
1300 the generic header a similar wrapper is generated as part
1301 of the set of exported headers in the directory:
1302
1303 usr/include/asm
1304
1305 The generated wrapper will in both cases look like the following:
1306
1307 Example: termios.h
1308 #include <asm-generic/termios.h>
1273 1309
1274=== 8 Kbuild Variables 1310=== 8 Kbuild Variables
1275 1311
diff --git a/Makefile b/Makefile
index d43429f4ced..e509cc70496 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
349 349
350# Use LINUXINCLUDE when you must reference the include/ directory. 350# Use LINUXINCLUDE when you must reference the include/ directory.
351# Needed to be compatible with the O= option 351# Needed to be compatible with the O= option
352LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \ 352LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
353 -Iarch/$(hdr-arch)/include/generated -Iinclude \
353 $(if $(KBUILD_SRC), -I$(srctree)/include) \ 354 $(if $(KBUILD_SRC), -I$(srctree)/include) \
354 -include include/generated/autoconf.h 355 -include include/generated/autoconf.h
355 356
@@ -417,6 +418,12 @@ ifneq ($(KBUILD_SRC),)
417 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 418 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
418endif 419endif
419 420
421# Support for using generic headers in asm-generic
422PHONY += asm-generic
423asm-generic:
424 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
425 obj=arch/$(SRCARCH)/include/generated/asm
426
420# To make sure we do not include .config for any of the *config targets 427# To make sure we do not include .config for any of the *config targets
421# catch them early, and hand them over to scripts/kconfig/Makefile 428# catch them early, and hand them over to scripts/kconfig/Makefile
422# It is allowed to specify more targets when calling make, including 429# It is allowed to specify more targets when calling make, including
@@ -954,7 +961,7 @@ ifneq ($(KBUILD_SRC),)
954endif 961endif
955 962
956# prepare2 creates a makefile if using a separate output directory 963# prepare2 creates a makefile if using a separate output directory
957prepare2: prepare3 outputmakefile 964prepare2: prepare3 outputmakefile asm-generic
958 965
959prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \ 966prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
960 include/config/auto.conf 967 include/config/auto.conf
@@ -1028,7 +1035,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
1028hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm) 1035hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
1029 1036
1030PHONY += __headers 1037PHONY += __headers
1031__headers: include/linux/version.h scripts_basic FORCE 1038__headers: include/linux/version.h scripts_basic asm-generic FORCE
1032 $(Q)$(MAKE) $(build)=scripts build_unifdef 1039 $(Q)$(MAKE) $(build)=scripts build_unifdef
1033 1040
1034PHONY += headers_install_all 1041PHONY += headers_install_all
@@ -1143,7 +1150,8 @@ CLEAN_FILES += vmlinux System.map \
1143 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map 1150 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
1144 1151
1145# Directories & files removed with 'make mrproper' 1152# Directories & files removed with 'make mrproper'
1146MRPROPER_DIRS += include/config usr/include include/generated 1153MRPROPER_DIRS += include/config usr/include include/generated \
1154 arch/*/include/generated
1147MRPROPER_FILES += .config .config.old .version .old_version \ 1155MRPROPER_FILES += .config .config.old .version .old_version \
1148 include/linux/version.h \ 1156 include/linux/version.h \
1149 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS 1157 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
new file mode 100644
index 00000000000..a687cb697e3
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
1# include/asm-generic contains a lot of files that are used
2# verbatim by several architectures.
3#
4# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
5# and for each file listed in this file with generic-y creates
6# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
7
8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
9include $(kbuild-file)
10
11include scripts/Kbuild.include
12
13# Create output directory if not already present
14_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
15
16quiet_cmd_wrap = WRAP $@
17cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
18
19all: $(patsubst %, $(obj)/%, $(generic-y))
20
21$(obj)/%.h:
22 $(call cmd,wrap)
23
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87f5c0..a57f5bd5a13 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
27install-file := $(install)/.install 27install-file := $(install)/.install
28check-file := $(install)/.check 28check-file := $(install)/.check
29 29
30# generic-y list all files an architecture uses from asm-generic
31# Use this to build a list of headers which require a wrapper
32wrapper-files := $(filter $(header-y), $(generic-y))
33
30# all headers files for this dir 34# all headers files for this dir
31all-files := $(header-y) $(objhdr-y) 35header-y := $(filter-out $(generic-y), $(header-y))
36all-files := $(header-y) $(objhdr-y) $(wrapper-files)
32input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ 37input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
33 $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) 38 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
34output-files := $(addprefix $(install)/, $(all-files)) 39output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
47 cmd_install = \ 52 cmd_install = \
48 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ 53 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
49 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ 54 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
55 for F in $(wrapper-files); do \
56 echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
57 done; \
50 touch $@ 58 touch $@
51 59
52quiet_cmd_remove = REMOVE $(unwanted) 60quiet_cmd_remove = REMOVE $(unwanted)