* [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-09 19:29 ` Sam Ravnborg
2011-01-09 20:31 ` Arnd Bergmann
` (3 subsequent siblings)
4 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 19:29 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
From 1c33973f2e4a099eadfb1a37cd3a28a3c8d3202f Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 19:45:40 +0100
Subject: [PATCH 1/2] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although is used a different method.
The patch includes several improvements from Arnd Bergmann.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 15 +++++++++++----
| 18 +++++++++++++++---
scripts/asm-generic.sh | 33 +++++++++++++++++++++++++++++++++
5 files changed, 96 insertions(+), 7 deletions(-)
create mode 100644 scripts/asm-generic.sh
diff --git a/.gitignore b/.gitignore
index 8faa6c0..e3cfd57 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 0ef00bd..bc79a3d 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1194,6 +1196,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1250,6 +1260,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index 74b2555..263eb65 100644
--- a/Makefile
+++ b/Makefile
@@ -344,7 +344,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -411,6 +412,11 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -942,7 +948,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1016,7 +1022,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts scripts/unifdef
PHONY += headers_install_all
@@ -1131,7 +1137,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
Module.symvers tags TAGS cscope*
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..7960b19 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
include $(kbuild-file)
_dst := $(if $(destination-y),$(destination-y),$(_dst))
+_src := $(srctree)/$(obj)
include scripts/Kbuild.include
@@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
-input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
+input-files := $(addprefix $(_src)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+
output-files := $(addprefix $(install)/, $(all-files))
# Work out what needs to be removed
@@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
+
quiet_cmd_remove = REMOVE $(unwanted)
cmd_remove = rm -f $(unwanted-file)
@@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
@:
targets += $(install-file)
-$(install-file): scripts/headers_install.pl $(input-files) FORCE
+$(install-file): scripts/headers_install.pl \
+ $(input-files) FORCE
$(if $(unwanted),$(call cmd,remove),)
$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
$(call if_changed,install)
diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
new file mode 100644
index 0000000..d28127f
--- /dev/null
+++ b/scripts/asm-generic.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y create
+# a small wrapper file in arch/$(ARCH)/include/generated/
+
+# read list of header files form Kbuild
+# The file has make syntax which looks like this:
+#
+# generic-y += <filename>
+
+srcdir=${srctree}/arch/$1/include/asm
+gendir=arch/$1/include/generated/asm
+
+# Read the list of files (note that the list uses make syntax)
+files=$( cat ${srcdir}/Kbuild | \
+ grep -v ^# | grep generic-y | cut -d '=' -f 2)
+
+mkdir -p ${gendir}
+
+# create include files for each file used form asm-generic
+for F in ${files}; do
+ if [ -f ${srcdir}/$F ]; then
+ echo "ERROR: ${srcdir}/$F exists"
+ echo "$F is also listed as generic-y in ${srcdir}/Kbuild"
+ echo "Did you forget to remove the file?"
+ exit 1
+ fi
+ echo "#include <asm-generic/$F>" > ${gendir}/$F
+done
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 19:29 ` Sam Ravnborg
@ 2011-01-09 20:31 ` Arnd Bergmann
2011-01-09 20:31 ` Arnd Bergmann
2011-01-09 21:24 ` Sam Ravnborg
2011-01-10 13:14 ` Guan Xuetao
` (2 subsequent siblings)
4 siblings, 2 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 20:31 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
Looks almost perfect to me now.
I was about to reply with Reviewed-by, but then it occurred to me
that scripts/asm-generic.sh is really much more complicated
than doing the same in Makefile syntax.
You already create the wrapper files during headers-install, so why
not also create them from make, where we already have access to the
file lists in a convenient format.
Or is there a problem getting at stuff defined in the Kbuild files
from the prepare stage?
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 20:31 ` Arnd Bergmann
@ 2011-01-09 20:31 ` Arnd Bergmann
2011-01-09 21:24 ` Sam Ravnborg
1 sibling, 0 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 20:31 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
Looks almost perfect to me now.
I was about to reply with Reviewed-by, but then it occurred to me
that scripts/asm-generic.sh is really much more complicated
than doing the same in Makefile syntax.
You already create the wrapper files during headers-install, so why
not also create them from make, where we already have access to the
file lists in a convenient format.
Or is there a problem getting at stuff defined in the Kbuild files
from the prepare stage?
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 20:31 ` Arnd Bergmann
2011-01-09 20:31 ` Arnd Bergmann
@ 2011-01-09 21:24 ` Sam Ravnborg
2011-01-09 21:24 ` Sam Ravnborg
1 sibling, 1 reply; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 21:24 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Sun, Jan 09, 2011 at 09:31:27PM +0100, Arnd Bergmann wrote:
> > There is an increasing amount of header files
> > shared between individual architectures in asm-generic.
> > To avoid a lot of dummy wrapper files that just
> > include the corresponding file in asm-generic provide
> > some basic support in kbuild for this.
>
> Looks almost perfect to me now.
>
> I was about to reply with Reviewed-by, but then it occurred to me
> that scripts/asm-generic.sh is really much more complicated
> than doing the same in Makefile syntax.
>
> You already create the wrapper files during headers-install, so why
> not also create them from make, where we already have access to the
> file lists in a convenient format.
>
> Or is there a problem getting at stuff defined in the Kbuild files
> from the prepare stage?
My main issue it that I wanted to offload functionality
from the top-level Makefile.
It contains too much weird stuff already.
I considered writing asm-generic.sh as a small
Makefile but decided for a shell script because there
are more people confident in shell scripts than in Makefile syntax.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 21:24 ` Sam Ravnborg
@ 2011-01-09 21:24 ` Sam Ravnborg
0 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 21:24 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Sun, Jan 09, 2011 at 09:31:27PM +0100, Arnd Bergmann wrote:
> > There is an increasing amount of header files
> > shared between individual architectures in asm-generic.
> > To avoid a lot of dummy wrapper files that just
> > include the corresponding file in asm-generic provide
> > some basic support in kbuild for this.
>
> Looks almost perfect to me now.
>
> I was about to reply with Reviewed-by, but then it occurred to me
> that scripts/asm-generic.sh is really much more complicated
> than doing the same in Makefile syntax.
>
> You already create the wrapper files during headers-install, so why
> not also create them from make, where we already have access to the
> file lists in a convenient format.
>
> Or is there a problem getting at stuff defined in the Kbuild files
> from the prepare stage?
My main issue it that I wanted to offload functionality
from the top-level Makefile.
It contains too much weird stuff already.
I considered writing asm-generic.sh as a small
Makefile but decided for a shell script because there
are more people confident in shell scripts than in Makefile syntax.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 19:29 ` Sam Ravnborg
2011-01-09 20:31 ` Arnd Bergmann
@ 2011-01-10 13:14 ` Guan Xuetao
2011-01-10 13:14 ` Guan Xuetao
2011-01-10 16:26 ` Sam Ravnborg
2011-01-10 13:31 ` Guan Xuetao
2011-01-13 16:14 ` Michal Marek
4 siblings, 2 replies; 58+ messages in thread
From: Guan Xuetao @ 2011-01-10 13:14 UTC (permalink / raw)
To: 'Sam Ravnborg', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd
> -----Original Message-----
> From: linux-arch-owner@vger.kernel.org [mailto:linux-arch-owner@vger.kernel.org] On Behalf Of Sam Ravnborg
> Sent: Monday, January 10, 2011 3:29 AM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 1c33973f2e4a099eadfb1a37cd3a28a3c8d3202f Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sun, 9 Jan 2011 19:45:40 +0100
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although is used a different method.
>
> The patch includes several improvements from Arnd Bergmann.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> .gitignore | 1 +
> Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
> Makefile | 15 +++++++++++----
> scripts/Makefile.headersinst | 18 +++++++++++++++---
> scripts/asm-generic.sh | 33 +++++++++++++++++++++++++++++++++
> 5 files changed, 96 insertions(+), 7 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/.gitignore b/.gitignore
> index 8faa6c0..e3cfd57 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -56,6 +56,7 @@ modules.builtin
> include/config
> include/linux/version.h
> include/generated
> +arch/*/include/generated
>
> # stgit generated dirs
> patches-*
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 0ef00bd..bc79a3d 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
> --- 6.6 Commands useful for building a boot image
> --- 6.7 Custom kbuild commands
> --- 6.8 Preprocessing linker scripts
> + --- 6.9 Generic header files
>
> === 7 Kbuild syntax for exported headers
> --- 7.1 header-y
> --- 7.2 objhdr-y
> --- 7.3 destination-y
> + --- 7.4 generic-y
>
> === 8 Kbuild Variables
> === 9 Makefile language
> @@ -1194,6 +1196,14 @@ When kbuild executes, the following steps are followed (roughly):
> The kbuild infrastructure for *lds file are used in several
> architecture-specific files.
>
> +--- 6.9 Generic header files
> +
> + The directory include/asm-generic contains the header files
> + that may be shared between individual architectures.
> + The recommended approach how to use a generic header file is
> + to list the file in the Kbuild file.
> + See "7.4 generic-y" for further info on syntax etc.
> +
> === 7 Kbuild syntax for exported headers
>
> The kernel include a set of headers that is exported to userspace.
> @@ -1250,6 +1260,32 @@ See subsequent chapter for the syntax of the Kbuild file.
> In the example above all exported headers in the Kbuild file
> will be located in the directory "include/linux" when exported.
>
> + --- 7.4 generic-y
> +
> + If an architecture uses a verbatim copy of a header from
> + include/asm-generic then this is listed in the file
> + arch/$(ARCH)/include/asm/Kbuild like this:
> +
> + Example:
> + #arch/x86/include/asm/Kbuild
> + generic-y += termios.h
> + generic-y += rtc.h
> +
> + During the prepare phase of the build a wrapper include
> + file is generated in the directory:
> +
> + arch/$(ARCH)/include/generated/asm
IMHO, the directory could be include/generated/asm
> +
> + When a header is exported where the architecture uses
> + the generic header a similar wrapper is generated as part
> + of the set of exported headers in the directory:
> +
> + usr/include/asm
> +
> + The generated wrapper will in both cases look like the following:
> +
> + Example: termios.h
> + #include <asm-generic/termios.h>
>
> === 8 Kbuild Variables
>
> diff --git a/Makefile b/Makefile
> index 74b2555..263eb65 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -344,7 +344,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -include include/generated/autoconf.h
>
> @@ -411,6 +412,11 @@ ifneq ($(KBUILD_SRC),)
> $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
> endif
>
> +# Support for using generic headers in asm-generic
> +PHONY += asm-generic
> +asm-generic:
> + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
> +
> # To make sure we do not include .config for any of the *config targets
> # catch them early, and hand them over to scripts/kconfig/Makefile
> # It is allowed to specify more targets when calling make, including
> @@ -942,7 +948,7 @@ ifneq ($(KBUILD_SRC),)
> endif
>
> # prepare2 creates a makefile if using a separate output directory
> -prepare2: prepare3 outputmakefile
> +prepare2: prepare3 outputmakefile asm-generic
>
> prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
> include/config/auto.conf
> @@ -1016,7 +1022,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
> hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
>
> PHONY += __headers
> -__headers: include/linux/version.h scripts_basic FORCE
> +__headers: include/linux/version.h scripts_basic asm-generic FORCE
> $(Q)$(MAKE) $(build)=scripts scripts/unifdef
>
> PHONY += headers_install_all
> @@ -1131,7 +1137,8 @@ CLEAN_FILES += vmlinux System.map \
> .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
>
> # Directories & files removed with 'make mrproper'
> -MRPROPER_DIRS += include/config usr/include include/generated
> +MRPROPER_DIRS += include/config usr/include include/generated \
> + arch/*/include/generated
> MRPROPER_FILES += .config .config.old .version .old_version \
> include/linux/version.h \
> Module.symvers tags TAGS cscope*
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..7960b19 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
> include $(kbuild-file)
>
> _dst := $(if $(destination-y),$(destination-y),$(_dst))
> +_src := $(srctree)/$(obj)
>
> include scripts/Kbuild.include
>
> @@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
> install-file := $(install)/.install
> check-file := $(install)/.check
>
> +# generic-y list all files an architecture uses from asm-generic
> +# Use this to build a list of headers which require a wrapper
> +wrapper-files := $(filter $(header-y), $(generic-y))
> +
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> -input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> +header-y := $(filter-out $(generic-y), $(header-y))
> +all-files := $(header-y) $(objhdr-y) $(wrapper-files)
> +input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> cmd_install = \
> $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> + for F in $(wrapper-files); do \
> + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> + done; \
> touch $@
>
> +
Empty line.
> quiet_cmd_remove = REMOVE $(unwanted)
> cmd_remove = rm -f $(unwanted-file)
>
> @@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
> @:
>
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) FORCE
> $(if $(unwanted),$(call cmd,remove),)
> $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
> $(call if_changed,install)
> diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> new file mode 100644
> index 0000000..d28127f
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +#
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y create
> +# a small wrapper file in arch/$(ARCH)/include/generated/
> +
> +# read list of header files form Kbuild
> +# The file has make syntax which looks like this:
> +#
> +# generic-y += <filename>
> +
> +srcdir=${srctree}/arch/$1/include/asm
> +gendir=arch/$1/include/generated/asm
> +
> +# Read the list of files (note that the list uses make syntax)
> +files=$( cat ${srcdir}/Kbuild | \
> + grep -v ^# | grep generic-y | cut -d '=' -f 2)
> +
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + if [ -f ${srcdir}/$F ]; then
> + echo "ERROR: ${srcdir}/$F exists"
> + echo "$F is also listed as generic-y in ${srcdir}/Kbuild"
> + echo "Did you forget to remove the file?"
> + exit 1
> + fi
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-10 13:14 ` Guan Xuetao
@ 2011-01-10 13:14 ` Guan Xuetao
2011-01-10 16:26 ` Sam Ravnborg
1 sibling, 0 replies; 58+ messages in thread
From: Guan Xuetao @ 2011-01-10 13:14 UTC (permalink / raw)
To: 'Sam Ravnborg', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd Bergmann',
'Michal Marek'
> -----Original Message-----
> From: linux-arch-owner@vger.kernel.org [mailto:linux-arch-owner@vger.kernel.org] On Behalf Of Sam Ravnborg
> Sent: Monday, January 10, 2011 3:29 AM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 1c33973f2e4a099eadfb1a37cd3a28a3c8d3202f Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sun, 9 Jan 2011 19:45:40 +0100
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although is used a different method.
>
> The patch includes several improvements from Arnd Bergmann.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> .gitignore | 1 +
> Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
> Makefile | 15 +++++++++++----
> scripts/Makefile.headersinst | 18 +++++++++++++++---
> scripts/asm-generic.sh | 33 +++++++++++++++++++++++++++++++++
> 5 files changed, 96 insertions(+), 7 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/.gitignore b/.gitignore
> index 8faa6c0..e3cfd57 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -56,6 +56,7 @@ modules.builtin
> include/config
> include/linux/version.h
> include/generated
> +arch/*/include/generated
>
> # stgit generated dirs
> patches-*
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 0ef00bd..bc79a3d 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
> --- 6.6 Commands useful for building a boot image
> --- 6.7 Custom kbuild commands
> --- 6.8 Preprocessing linker scripts
> + --- 6.9 Generic header files
>
> === 7 Kbuild syntax for exported headers
> --- 7.1 header-y
> --- 7.2 objhdr-y
> --- 7.3 destination-y
> + --- 7.4 generic-y
>
> === 8 Kbuild Variables
> === 9 Makefile language
> @@ -1194,6 +1196,14 @@ When kbuild executes, the following steps are followed (roughly):
> The kbuild infrastructure for *lds file are used in several
> architecture-specific files.
>
> +--- 6.9 Generic header files
> +
> + The directory include/asm-generic contains the header files
> + that may be shared between individual architectures.
> + The recommended approach how to use a generic header file is
> + to list the file in the Kbuild file.
> + See "7.4 generic-y" for further info on syntax etc.
> +
> === 7 Kbuild syntax for exported headers
>
> The kernel include a set of headers that is exported to userspace.
> @@ -1250,6 +1260,32 @@ See subsequent chapter for the syntax of the Kbuild file.
> In the example above all exported headers in the Kbuild file
> will be located in the directory "include/linux" when exported.
>
> + --- 7.4 generic-y
> +
> + If an architecture uses a verbatim copy of a header from
> + include/asm-generic then this is listed in the file
> + arch/$(ARCH)/include/asm/Kbuild like this:
> +
> + Example:
> + #arch/x86/include/asm/Kbuild
> + generic-y += termios.h
> + generic-y += rtc.h
> +
> + During the prepare phase of the build a wrapper include
> + file is generated in the directory:
> +
> + arch/$(ARCH)/include/generated/asm
IMHO, the directory could be include/generated/asm
> +
> + When a header is exported where the architecture uses
> + the generic header a similar wrapper is generated as part
> + of the set of exported headers in the directory:
> +
> + usr/include/asm
> +
> + The generated wrapper will in both cases look like the following:
> +
> + Example: termios.h
> + #include <asm-generic/termios.h>
>
> === 8 Kbuild Variables
>
> diff --git a/Makefile b/Makefile
> index 74b2555..263eb65 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -344,7 +344,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -include include/generated/autoconf.h
>
> @@ -411,6 +412,11 @@ ifneq ($(KBUILD_SRC),)
> $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
> endif
>
> +# Support for using generic headers in asm-generic
> +PHONY += asm-generic
> +asm-generic:
> + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
> +
> # To make sure we do not include .config for any of the *config targets
> # catch them early, and hand them over to scripts/kconfig/Makefile
> # It is allowed to specify more targets when calling make, including
> @@ -942,7 +948,7 @@ ifneq ($(KBUILD_SRC),)
> endif
>
> # prepare2 creates a makefile if using a separate output directory
> -prepare2: prepare3 outputmakefile
> +prepare2: prepare3 outputmakefile asm-generic
>
> prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
> include/config/auto.conf
> @@ -1016,7 +1022,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
> hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
>
> PHONY += __headers
> -__headers: include/linux/version.h scripts_basic FORCE
> +__headers: include/linux/version.h scripts_basic asm-generic FORCE
> $(Q)$(MAKE) $(build)=scripts scripts/unifdef
>
> PHONY += headers_install_all
> @@ -1131,7 +1137,8 @@ CLEAN_FILES += vmlinux System.map \
> .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
>
> # Directories & files removed with 'make mrproper'
> -MRPROPER_DIRS += include/config usr/include include/generated
> +MRPROPER_DIRS += include/config usr/include include/generated \
> + arch/*/include/generated
> MRPROPER_FILES += .config .config.old .version .old_version \
> include/linux/version.h \
> Module.symvers tags TAGS cscope*
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..7960b19 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
> include $(kbuild-file)
>
> _dst := $(if $(destination-y),$(destination-y),$(_dst))
> +_src := $(srctree)/$(obj)
>
> include scripts/Kbuild.include
>
> @@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
> install-file := $(install)/.install
> check-file := $(install)/.check
>
> +# generic-y list all files an architecture uses from asm-generic
> +# Use this to build a list of headers which require a wrapper
> +wrapper-files := $(filter $(header-y), $(generic-y))
> +
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> -input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> +header-y := $(filter-out $(generic-y), $(header-y))
> +all-files := $(header-y) $(objhdr-y) $(wrapper-files)
> +input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> cmd_install = \
> $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> + for F in $(wrapper-files); do \
> + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> + done; \
> touch $@
>
> +
Empty line.
> quiet_cmd_remove = REMOVE $(unwanted)
> cmd_remove = rm -f $(unwanted-file)
>
> @@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
> @:
>
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) FORCE
> $(if $(unwanted),$(call cmd,remove),)
> $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
> $(call if_changed,install)
> diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> new file mode 100644
> index 0000000..d28127f
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +#
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y create
> +# a small wrapper file in arch/$(ARCH)/include/generated/
> +
> +# read list of header files form Kbuild
> +# The file has make syntax which looks like this:
> +#
> +# generic-y += <filename>
> +
> +srcdir=${srctree}/arch/$1/include/asm
> +gendir=arch/$1/include/generated/asm
> +
> +# Read the list of files (note that the list uses make syntax)
> +files=$( cat ${srcdir}/Kbuild | \
> + grep -v ^# | grep generic-y | cut -d '=' -f 2)
> +
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + if [ -f ${srcdir}/$F ]; then
> + echo "ERROR: ${srcdir}/$F exists"
> + echo "$F is also listed as generic-y in ${srcdir}/Kbuild"
> + echo "Did you forget to remove the file?"
> + exit 1
> + fi
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-10 13:14 ` Guan Xuetao
2011-01-10 13:14 ` Guan Xuetao
@ 2011-01-10 16:26 ` Sam Ravnborg
2011-01-10 16:26 ` Sam Ravnborg
2011-01-11 1:39 ` Guan Xuetao
1 sibling, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-10 16:26 UTC (permalink / raw)
To: Guan Xuetao
Cc: 'lkml', 'linux-kbuild', 'linux arch',
'Arnd Bergmann', 'Michal Marek'
Hi Guan (I will try to spell you name correct fom now on!)
> > + During the prepare phase of the build a wrapper include
> > + file is generated in the directory:
> > +
> > + arch/$(ARCH)/include/generated/asm
> IMHO, the directory could be include/generated/asm
We have moved all the arch specific files away from include/*
which is why I invented arch/$(ARCH)/include/generated.
I was actually considering:
arch/$(ARCH)/generated.
But using include/generated just seems wrong.
> >
> > # Work out what needs to be removed
> > @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> > cmd_install = \
> > $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> > $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> > + for F in $(wrapper-files); do \
> > + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> > + done; \
> > touch $@
> >
> > +
> Empty line.
>
Will fix.
As noticed in another mail the patchset has the same issue with rebuilding.
This will likewise be included in next version.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-10 16:26 ` Sam Ravnborg
@ 2011-01-10 16:26 ` Sam Ravnborg
2011-01-11 1:39 ` Guan Xuetao
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-10 16:26 UTC (permalink / raw)
To: Guan Xuetao
Cc: 'lkml', 'linux-kbuild', 'linux arch',
'Arnd Bergmann', 'Michal Marek'
Hi Guan (I will try to spell you name correct fom now on!)
> > + During the prepare phase of the build a wrapper include
> > + file is generated in the directory:
> > +
> > + arch/$(ARCH)/include/generated/asm
> IMHO, the directory could be include/generated/asm
We have moved all the arch specific files away from include/*
which is why I invented arch/$(ARCH)/include/generated.
I was actually considering:
arch/$(ARCH)/generated.
But using include/generated just seems wrong.
> >
> > # Work out what needs to be removed
> > @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> > cmd_install = \
> > $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> > $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> > + for F in $(wrapper-files); do \
> > + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> > + done; \
> > touch $@
> >
> > +
> Empty line.
>
Will fix.
As noticed in another mail the patchset has the same issue with rebuilding.
This will likewise be included in next version.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-10 16:26 ` Sam Ravnborg
2011-01-10 16:26 ` Sam Ravnborg
@ 2011-01-11 1:39 ` Guan Xuetao
1 sibling, 0 replies; 58+ messages in thread
From: Guan Xuetao @ 2011-01-11 1:39 UTC (permalink / raw)
To: 'Sam Ravnborg'
Cc: 'lkml', 'linux-kbuild', 'linux arch',
'Arnd Bergmann', 'Michal Marek'
> -----Original Message-----
> From: Sam Ravnborg [mailto:sam@ravnborg.org]
> Sent: Tuesday, January 11, 2011 12:27 AM
> To: Guan Xuetao
> Cc: 'lkml'; 'linux-kbuild'; 'linux arch'; 'Arnd Bergmann'; 'Michal Marek'
> Subject: Re: [PATCH 1/2] kbuild: asm-generic support
>
> Hi Guan (I will try to spell you name correct fom now on!)
Thanks.
>
> > > + During the prepare phase of the build a wrapper include
> > > + file is generated in the directory:
> > > +
> > > + arch/$(ARCH)/include/generated/asm
> > IMHO, the directory could be include/generated/asm
>
> We have moved all the arch specific files away from include/*
> which is why I invented arch/$(ARCH)/include/generated.
>
> I was actually considering:
>
> arch/$(ARCH)/generated.
>
> But using include/generated just seems wrong.
The generated headers is just the wrapper of asm-generic headers, so it's
more the interface than the arch specific files.
Using include/generated avoids two generated header dirs, and simplifies
the thought and handler.
Guan Xuetao
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
` (2 preceding siblings ...)
2011-01-10 13:14 ` Guan Xuetao
@ 2011-01-10 13:31 ` Guan Xuetao
2011-01-10 13:31 ` Guan Xuetao
2011-01-13 16:14 ` Michal Marek
4 siblings, 1 reply; 58+ messages in thread
From: Guan Xuetao @ 2011-01-10 13:31 UTC (permalink / raw)
To: 'Sam Ravnborg', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd
Sam:
There is a big problem in previous patch set.
When re-compile kernel image, almost all source files will be re-compiled since
arch/*/include/generated/asm/* being re-created.
So I add a judgment before auto-generation, as following:
commit 03e63f75b37a4d6e5668bc07ae385a174efd6e8c
Author: GuanXuetao <gxt@mprc.pku.edu.cn>
Date: Sun Jan 9 22:35:24 2011 +0800
unicore32: adjust auto-generated asm-generic headers method
solve the problem:
former method will re-generate headers each compile processing
attention for new method:
when add new auto-generated asm-generic header
"make mrproper" is needed first
diff --git a/arch/unicore32/Makefile b/arch/unicore32/Makefile
index 0be046d..de1ce7d 100644
--- a/arch/unicore32/Makefile
+++ b/arch/unicore32/Makefile
@@ -76,11 +76,13 @@ ASM_GENERIC_HEADERS += ucontext.h unaligned.h user.h
ASM_GENERIC_HEADERS += vga.h
ASM_GENERIC_HEADERS += xor.h
-%.h:
+archprepare:
+ifneq ($(ASM_GENERATED_DIR), $(wildcard $(ASM_GENERATED_DIR)))
$(Q)mkdir -p $(ASM_GENERATED_DIR)/asm
- $(Q)echo '#include <asm-generic/$(notdir $@)>' > $(ASM_GENERATED_DIR)/asm/$@
-
-archprepare: $(ASM_GENERIC_HEADERS)
+ $(Q)$(foreach a, $(ASM_GENERIC_HEADERS), \
+ echo '#include <asm-generic/$a>' \
+ > $(ASM_GENERATED_DIR)/asm/$a; )
+endif
boot := arch/unicore32/boot
> -----Original Message-----
> From: Sam Ravnborg [mailto:sam@ravnborg.org]
> Sent: Monday, January 10, 2011 3:29 AM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 1c33973f2e4a099eadfb1a37cd3a28a3c8d3202f Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sun, 9 Jan 2011 19:45:40 +0100
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although is used a different method.
>
> The patch includes several improvements from Arnd Bergmann.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> .gitignore | 1 +
> Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
> Makefile | 15 +++++++++++----
> scripts/Makefile.headersinst | 18 +++++++++++++++---
> scripts/asm-generic.sh | 33 +++++++++++++++++++++++++++++++++
> 5 files changed, 96 insertions(+), 7 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/.gitignore b/.gitignore
> index 8faa6c0..e3cfd57 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -56,6 +56,7 @@ modules.builtin
> include/config
> include/linux/version.h
> include/generated
> +arch/*/include/generated
>
> # stgit generated dirs
> patches-*
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 0ef00bd..bc79a3d 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
> --- 6.6 Commands useful for building a boot image
> --- 6.7 Custom kbuild commands
> --- 6.8 Preprocessing linker scripts
> + --- 6.9 Generic header files
>
> === 7 Kbuild syntax for exported headers
> --- 7.1 header-y
> --- 7.2 objhdr-y
> --- 7.3 destination-y
> + --- 7.4 generic-y
>
> === 8 Kbuild Variables
> === 9 Makefile language
> @@ -1194,6 +1196,14 @@ When kbuild executes, the following steps are followed (roughly):
> The kbuild infrastructure for *lds file are used in several
> architecture-specific files.
>
> +--- 6.9 Generic header files
> +
> + The directory include/asm-generic contains the header files
> + that may be shared between individual architectures.
> + The recommended approach how to use a generic header file is
> + to list the file in the Kbuild file.
> + See "7.4 generic-y" for further info on syntax etc.
> +
> === 7 Kbuild syntax for exported headers
>
> The kernel include a set of headers that is exported to userspace.
> @@ -1250,6 +1260,32 @@ See subsequent chapter for the syntax of the Kbuild file.
> In the example above all exported headers in the Kbuild file
> will be located in the directory "include/linux" when exported.
>
> + --- 7.4 generic-y
> +
> + If an architecture uses a verbatim copy of a header from
> + include/asm-generic then this is listed in the file
> + arch/$(ARCH)/include/asm/Kbuild like this:
> +
> + Example:
> + #arch/x86/include/asm/Kbuild
> + generic-y += termios.h
> + generic-y += rtc.h
> +
> + During the prepare phase of the build a wrapper include
> + file is generated in the directory:
> +
> + arch/$(ARCH)/include/generated/asm
> +
> + When a header is exported where the architecture uses
> + the generic header a similar wrapper is generated as part
> + of the set of exported headers in the directory:
> +
> + usr/include/asm
> +
> + The generated wrapper will in both cases look like the following:
> +
> + Example: termios.h
> + #include <asm-generic/termios.h>
>
> === 8 Kbuild Variables
>
> diff --git a/Makefile b/Makefile
> index 74b2555..263eb65 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -344,7 +344,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -include include/generated/autoconf.h
>
> @@ -411,6 +412,11 @@ ifneq ($(KBUILD_SRC),)
> $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
> endif
>
> +# Support for using generic headers in asm-generic
> +PHONY += asm-generic
> +asm-generic:
> + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
> +
> # To make sure we do not include .config for any of the *config targets
> # catch them early, and hand them over to scripts/kconfig/Makefile
> # It is allowed to specify more targets when calling make, including
> @@ -942,7 +948,7 @@ ifneq ($(KBUILD_SRC),)
> endif
>
> # prepare2 creates a makefile if using a separate output directory
> -prepare2: prepare3 outputmakefile
> +prepare2: prepare3 outputmakefile asm-generic
>
> prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
> include/config/auto.conf
> @@ -1016,7 +1022,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
> hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
>
> PHONY += __headers
> -__headers: include/linux/version.h scripts_basic FORCE
> +__headers: include/linux/version.h scripts_basic asm-generic FORCE
> $(Q)$(MAKE) $(build)=scripts scripts/unifdef
>
> PHONY += headers_install_all
> @@ -1131,7 +1137,8 @@ CLEAN_FILES += vmlinux System.map \
> .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
>
> # Directories & files removed with 'make mrproper'
> -MRPROPER_DIRS += include/config usr/include include/generated
> +MRPROPER_DIRS += include/config usr/include include/generated \
> + arch/*/include/generated
> MRPROPER_FILES += .config .config.old .version .old_version \
> include/linux/version.h \
> Module.symvers tags TAGS cscope*
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..7960b19 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
> include $(kbuild-file)
>
> _dst := $(if $(destination-y),$(destination-y),$(_dst))
> +_src := $(srctree)/$(obj)
>
> include scripts/Kbuild.include
>
> @@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
> install-file := $(install)/.install
> check-file := $(install)/.check
>
> +# generic-y list all files an architecture uses from asm-generic
> +# Use this to build a list of headers which require a wrapper
> +wrapper-files := $(filter $(header-y), $(generic-y))
> +
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> -input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> +header-y := $(filter-out $(generic-y), $(header-y))
> +all-files := $(header-y) $(objhdr-y) $(wrapper-files)
> +input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> cmd_install = \
> $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> + for F in $(wrapper-files); do \
> + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> + done; \
> touch $@
>
> +
> quiet_cmd_remove = REMOVE $(unwanted)
> cmd_remove = rm -f $(unwanted-file)
>
> @@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
> @:
>
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) FORCE
> $(if $(unwanted),$(call cmd,remove),)
> $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
> $(call if_changed,install)
> diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> new file mode 100644
> index 0000000..d28127f
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +#
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y create
> +# a small wrapper file in arch/$(ARCH)/include/generated/
> +
> +# read list of header files form Kbuild
> +# The file has make syntax which looks like this:
> +#
> +# generic-y += <filename>
> +
> +srcdir=${srctree}/arch/$1/include/asm
> +gendir=arch/$1/include/generated/asm
> +
> +# Read the list of files (note that the list uses make syntax)
> +files=$( cat ${srcdir}/Kbuild | \
> + grep -v ^# | grep generic-y | cut -d '=' -f 2)
> +
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + if [ -f ${srcdir}/$F ]; then
> + echo "ERROR: ${srcdir}/$F exists"
> + echo "$F is also listed as generic-y in ${srcdir}/Kbuild"
> + echo "Did you forget to remove the file?"
> + exit 1
> + fi
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-10 13:31 ` Guan Xuetao
@ 2011-01-10 13:31 ` Guan Xuetao
0 siblings, 0 replies; 58+ messages in thread
From: Guan Xuetao @ 2011-01-10 13:31 UTC (permalink / raw)
To: 'Sam Ravnborg', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd Bergmann',
'Michal Marek'
Sam:
There is a big problem in previous patch set.
When re-compile kernel image, almost all source files will be re-compiled since
arch/*/include/generated/asm/* being re-created.
So I add a judgment before auto-generation, as following:
commit 03e63f75b37a4d6e5668bc07ae385a174efd6e8c
Author: GuanXuetao <gxt@mprc.pku.edu.cn>
Date: Sun Jan 9 22:35:24 2011 +0800
unicore32: adjust auto-generated asm-generic headers method
solve the problem:
former method will re-generate headers each compile processing
attention for new method:
when add new auto-generated asm-generic header
"make mrproper" is needed first
diff --git a/arch/unicore32/Makefile b/arch/unicore32/Makefile
index 0be046d..de1ce7d 100644
--- a/arch/unicore32/Makefile
+++ b/arch/unicore32/Makefile
@@ -76,11 +76,13 @@ ASM_GENERIC_HEADERS += ucontext.h unaligned.h user.h
ASM_GENERIC_HEADERS += vga.h
ASM_GENERIC_HEADERS += xor.h
-%.h:
+archprepare:
+ifneq ($(ASM_GENERATED_DIR), $(wildcard $(ASM_GENERATED_DIR)))
$(Q)mkdir -p $(ASM_GENERATED_DIR)/asm
- $(Q)echo '#include <asm-generic/$(notdir $@)>' > $(ASM_GENERATED_DIR)/asm/$@
-
-archprepare: $(ASM_GENERIC_HEADERS)
+ $(Q)$(foreach a, $(ASM_GENERIC_HEADERS), \
+ echo '#include <asm-generic/$a>' \
+ > $(ASM_GENERATED_DIR)/asm/$a; )
+endif
boot := arch/unicore32/boot
> -----Original Message-----
> From: Sam Ravnborg [mailto:sam@ravnborg.org]
> Sent: Monday, January 10, 2011 3:29 AM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 1c33973f2e4a099eadfb1a37cd3a28a3c8d3202f Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sun, 9 Jan 2011 19:45:40 +0100
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although is used a different method.
>
> The patch includes several improvements from Arnd Bergmann.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> .gitignore | 1 +
> Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
> Makefile | 15 +++++++++++----
> scripts/Makefile.headersinst | 18 +++++++++++++++---
> scripts/asm-generic.sh | 33 +++++++++++++++++++++++++++++++++
> 5 files changed, 96 insertions(+), 7 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/.gitignore b/.gitignore
> index 8faa6c0..e3cfd57 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -56,6 +56,7 @@ modules.builtin
> include/config
> include/linux/version.h
> include/generated
> +arch/*/include/generated
>
> # stgit generated dirs
> patches-*
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 0ef00bd..bc79a3d 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
> --- 6.6 Commands useful for building a boot image
> --- 6.7 Custom kbuild commands
> --- 6.8 Preprocessing linker scripts
> + --- 6.9 Generic header files
>
> === 7 Kbuild syntax for exported headers
> --- 7.1 header-y
> --- 7.2 objhdr-y
> --- 7.3 destination-y
> + --- 7.4 generic-y
>
> === 8 Kbuild Variables
> === 9 Makefile language
> @@ -1194,6 +1196,14 @@ When kbuild executes, the following steps are followed (roughly):
> The kbuild infrastructure for *lds file are used in several
> architecture-specific files.
>
> +--- 6.9 Generic header files
> +
> + The directory include/asm-generic contains the header files
> + that may be shared between individual architectures.
> + The recommended approach how to use a generic header file is
> + to list the file in the Kbuild file.
> + See "7.4 generic-y" for further info on syntax etc.
> +
> === 7 Kbuild syntax for exported headers
>
> The kernel include a set of headers that is exported to userspace.
> @@ -1250,6 +1260,32 @@ See subsequent chapter for the syntax of the Kbuild file.
> In the example above all exported headers in the Kbuild file
> will be located in the directory "include/linux" when exported.
>
> + --- 7.4 generic-y
> +
> + If an architecture uses a verbatim copy of a header from
> + include/asm-generic then this is listed in the file
> + arch/$(ARCH)/include/asm/Kbuild like this:
> +
> + Example:
> + #arch/x86/include/asm/Kbuild
> + generic-y += termios.h
> + generic-y += rtc.h
> +
> + During the prepare phase of the build a wrapper include
> + file is generated in the directory:
> +
> + arch/$(ARCH)/include/generated/asm
> +
> + When a header is exported where the architecture uses
> + the generic header a similar wrapper is generated as part
> + of the set of exported headers in the directory:
> +
> + usr/include/asm
> +
> + The generated wrapper will in both cases look like the following:
> +
> + Example: termios.h
> + #include <asm-generic/termios.h>
>
> === 8 Kbuild Variables
>
> diff --git a/Makefile b/Makefile
> index 74b2555..263eb65 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -344,7 +344,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -include include/generated/autoconf.h
>
> @@ -411,6 +412,11 @@ ifneq ($(KBUILD_SRC),)
> $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
> endif
>
> +# Support for using generic headers in asm-generic
> +PHONY += asm-generic
> +asm-generic:
> + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
> +
> # To make sure we do not include .config for any of the *config targets
> # catch them early, and hand them over to scripts/kconfig/Makefile
> # It is allowed to specify more targets when calling make, including
> @@ -942,7 +948,7 @@ ifneq ($(KBUILD_SRC),)
> endif
>
> # prepare2 creates a makefile if using a separate output directory
> -prepare2: prepare3 outputmakefile
> +prepare2: prepare3 outputmakefile asm-generic
>
> prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
> include/config/auto.conf
> @@ -1016,7 +1022,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
> hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
>
> PHONY += __headers
> -__headers: include/linux/version.h scripts_basic FORCE
> +__headers: include/linux/version.h scripts_basic asm-generic FORCE
> $(Q)$(MAKE) $(build)=scripts scripts/unifdef
>
> PHONY += headers_install_all
> @@ -1131,7 +1137,8 @@ CLEAN_FILES += vmlinux System.map \
> .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
>
> # Directories & files removed with 'make mrproper'
> -MRPROPER_DIRS += include/config usr/include include/generated
> +MRPROPER_DIRS += include/config usr/include include/generated \
> + arch/*/include/generated
> MRPROPER_FILES += .config .config.old .version .old_version \
> include/linux/version.h \
> Module.symvers tags TAGS cscope*
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..7960b19 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
> include $(kbuild-file)
>
> _dst := $(if $(destination-y),$(destination-y),$(_dst))
> +_src := $(srctree)/$(obj)
>
> include scripts/Kbuild.include
>
> @@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
> install-file := $(install)/.install
> check-file := $(install)/.check
>
> +# generic-y list all files an architecture uses from asm-generic
> +# Use this to build a list of headers which require a wrapper
> +wrapper-files := $(filter $(header-y), $(generic-y))
> +
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> -input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> +header-y := $(filter-out $(generic-y), $(header-y))
> +all-files := $(header-y) $(objhdr-y) $(wrapper-files)
> +input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> cmd_install = \
> $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> + for F in $(wrapper-files); do \
> + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> + done; \
> touch $@
>
> +
> quiet_cmd_remove = REMOVE $(unwanted)
> cmd_remove = rm -f $(unwanted-file)
>
> @@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
> @:
>
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) FORCE
> $(if $(unwanted),$(call cmd,remove),)
> $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
> $(call if_changed,install)
> diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> new file mode 100644
> index 0000000..d28127f
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +#
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y create
> +# a small wrapper file in arch/$(ARCH)/include/generated/
> +
> +# read list of header files form Kbuild
> +# The file has make syntax which looks like this:
> +#
> +# generic-y += <filename>
> +
> +srcdir=${srctree}/arch/$1/include/asm
> +gendir=arch/$1/include/generated/asm
> +
> +# Read the list of files (note that the list uses make syntax)
> +files=$( cat ${srcdir}/Kbuild | \
> + grep -v ^# | grep generic-y | cut -d '=' -f 2)
> +
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + if [ -f ${srcdir}/$F ]; then
> + echo "ERROR: ${srcdir}/$F exists"
> + echo "$F is also listed as generic-y in ${srcdir}/Kbuild"
> + echo "Did you forget to remove the file?"
> + exit 1
> + fi
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
` (3 preceding siblings ...)
2011-01-10 13:31 ` Guan Xuetao
@ 2011-01-13 16:14 ` Michal Marek
2011-01-13 17:01 ` Sam Ravnborg
4 siblings, 1 reply; 58+ messages in thread
From: Michal Marek @ 2011-01-13 16:14 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
On 9.1.2011 20:29, Sam Ravnborg wrote:
> diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> new file mode 100644
> index 0000000..d28127f
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +#
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y create
> +# a small wrapper file in arch/$(ARCH)/include/generated/
> +
> +# read list of header files form Kbuild
> +# The file has make syntax which looks like this:
> +#
> +# generic-y += <filename>
> +
> +srcdir=${srctree}/arch/$1/include/asm
> +gendir=arch/$1/include/generated/asm
> +
> +# Read the list of files (note that the list uses make syntax)
> +files=$( cat ${srcdir}/Kbuild | \
> + grep -v ^# | grep generic-y | cut -d '=' -f 2)
Now that the list of required generic headers is in a Kbuild file, it
would be better to let make parse it, instead of enforcing one way to
construct the list (it is the preferred way, but C files that do not
conform to Documentation/CodingStyle are not rejected by the compiler
either). I will post a patch when I'm back online in the evening.
Michal
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-13 16:14 ` Michal Marek
@ 2011-01-13 17:01 ` Sam Ravnborg
2011-01-13 17:01 ` Sam Ravnborg
2011-01-14 14:43 ` Michal Marek
0 siblings, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-13 17:01 UTC (permalink / raw)
To: Michal Marek; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
On Thu, Jan 13, 2011 at 05:14:05PM +0100, Michal Marek wrote:
> On 9.1.2011 20:29, Sam Ravnborg wrote:
> > diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> > new file mode 100644
> > index 0000000..d28127f
> > --- /dev/null
> > +++ b/scripts/asm-generic.sh
> > @@ -0,0 +1,33 @@
> > +#!/bin/sh
> > +#
> > +# include/asm-generic contains a lot of files that are used
> > +# verbatim by several architectures.
> > +#
> > +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> > +# and for each file listed in this file with generic-y create
> > +# a small wrapper file in arch/$(ARCH)/include/generated/
> > +
> > +# read list of header files form Kbuild
> > +# The file has make syntax which looks like this:
> > +#
> > +# generic-y += <filename>
> > +
> > +srcdir=${srctree}/arch/$1/include/asm
> > +gendir=arch/$1/include/generated/asm
> > +
> > +# Read the list of files (note that the list uses make syntax)
> > +files=$( cat ${srcdir}/Kbuild | \
> > + grep -v ^# | grep generic-y | cut -d '=' -f 2)
>
> Now that the list of required generic headers is in a Kbuild file, it
> would be better to let make parse it, instead of enforcing one way to
> construct the list (it is the preferred way, but C files that do not
> conform to Documentation/CodingStyle are not rejected by the compiler
> either). I will post a patch when I'm back online in the evening.
Would be great!
Guan also pointed out a less than minor issue...
I overwrite the files each time so that I force a rebuild.
If you do not find time then I will update the
patch during the weekend.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-13 17:01 ` Sam Ravnborg
@ 2011-01-13 17:01 ` Sam Ravnborg
2011-01-14 14:43 ` Michal Marek
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-13 17:01 UTC (permalink / raw)
To: Michal Marek; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
On Thu, Jan 13, 2011 at 05:14:05PM +0100, Michal Marek wrote:
> On 9.1.2011 20:29, Sam Ravnborg wrote:
> > diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> > new file mode 100644
> > index 0000000..d28127f
> > --- /dev/null
> > +++ b/scripts/asm-generic.sh
> > @@ -0,0 +1,33 @@
> > +#!/bin/sh
> > +#
> > +# include/asm-generic contains a lot of files that are used
> > +# verbatim by several architectures.
> > +#
> > +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> > +# and for each file listed in this file with generic-y create
> > +# a small wrapper file in arch/$(ARCH)/include/generated/
> > +
> > +# read list of header files form Kbuild
> > +# The file has make syntax which looks like this:
> > +#
> > +# generic-y += <filename>
> > +
> > +srcdir=${srctree}/arch/$1/include/asm
> > +gendir=arch/$1/include/generated/asm
> > +
> > +# Read the list of files (note that the list uses make syntax)
> > +files=$( cat ${srcdir}/Kbuild | \
> > + grep -v ^# | grep generic-y | cut -d '=' -f 2)
>
> Now that the list of required generic headers is in a Kbuild file, it
> would be better to let make parse it, instead of enforcing one way to
> construct the list (it is the preferred way, but C files that do not
> conform to Documentation/CodingStyle are not rejected by the compiler
> either). I will post a patch when I'm back online in the evening.
Would be great!
Guan also pointed out a less than minor issue...
I overwrite the files each time so that I force a rebuild.
If you do not find time then I will update the
patch during the weekend.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-13 17:01 ` Sam Ravnborg
2011-01-13 17:01 ` Sam Ravnborg
@ 2011-01-14 14:43 ` Michal Marek
2011-04-22 15:53 ` [PATCH v3] " Sam Ravnborg
1 sibling, 1 reply; 58+ messages in thread
From: Michal Marek @ 2011-01-14 14:43 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
On Thu, Jan 13, 2011 at 06:01:31PM +0100, Sam Ravnborg wrote:
> On Thu, Jan 13, 2011 at 05:14:05PM +0100, Michal Marek wrote:
> > On 9.1.2011 20:29, Sam Ravnborg wrote:
> > > diff --git a/scripts/asm-generic.sh b/scripts/asm-generic.sh
> > > new file mode 100644
> > > index 0000000..d28127f
> > > --- /dev/null
> > > +++ b/scripts/asm-generic.sh
> > > @@ -0,0 +1,33 @@
> > > +#!/bin/sh
> > > +#
> > > +# include/asm-generic contains a lot of files that are used
> > > +# verbatim by several architectures.
> > > +#
> > > +# This scripts read the file arch/$(ARCH)/include/asm/Kbuild
> > > +# and for each file listed in this file with generic-y create
> > > +# a small wrapper file in arch/$(ARCH)/include/generated/
> > > +
> > > +# read list of header files form Kbuild
> > > +# The file has make syntax which looks like this:
> > > +#
> > > +# generic-y += <filename>
> > > +
> > > +srcdir=${srctree}/arch/$1/include/asm
> > > +gendir=arch/$1/include/generated/asm
> > > +
> > > +# Read the list of files (note that the list uses make syntax)
> > > +files=$( cat ${srcdir}/Kbuild | \
> > > + grep -v ^# | grep generic-y | cut -d '=' -f 2)
> >
> > Now that the list of required generic headers is in a Kbuild file, it
> > would be better to let make parse it, instead of enforcing one way to
> > construct the list (it is the preferred way, but C files that do not
> > conform to Documentation/CodingStyle are not rejected by the compiler
> > either). I will post a patch when I'm back online in the evening.
> Would be great!
>
> Guan also pointed out a less than minor issue...
> I overwrite the files each time so that I force a rebuild.
Hi,
this should do the trick (the deletion of scripts/asm-generic.sh is left
out for brevity). I initially wanted to use this also from
Makefile.headersinst, but there we only want to export headers listed in
header-y, so I gave up on this idea.
Michal
diff --git a/Makefile b/Makefile
index 5a29426..6ede051 100644
--- a/Makefile
+++ b/Makefile
@@ -416,7 +416,7 @@ endif
# Support for using generic headers in asm-generic
PHONY += asm-generic
asm-generic:
- $(Q)$(CONFIG_SHELL) $(srctree)/scripts/asm-generic.sh $(SRCARCH)
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
new file mode 100644
index 0000000..b4f2547
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,26 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+
+ifneq ($(KBUILD_SRC),)
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+endif
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH v3] kbuild: asm-generic support
2011-01-14 14:43 ` Michal Marek
@ 2011-04-22 15:53 ` Sam Ravnborg
2011-04-22 15:53 ` Sam Ravnborg
2011-04-25 1:29 ` Guan Xuetao
0 siblings, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-22 15:53 UTC (permalink / raw)
To: Michal Marek; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
From 34d0b72a343dd63c1c1b049e4ba6931f0dbcbc3f Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Hi Mikael.
It took me a while to get back to this.
I used your Makefile.asm-generic almost verbatim.
Only change was that we always need to create the output directory.
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 15 +++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 18 +++++++++++++++---
5 files changed, 86 insertions(+), 7 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..30b3852 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,11 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +953,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1027,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1142,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..7960b19 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
include $(kbuild-file)
_dst := $(if $(destination-y),$(destination-y),$(_dst))
+_src := $(srctree)/$(obj)
include scripts/Kbuild.include
@@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
-input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
+input-files := $(addprefix $(_src)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+
output-files := $(addprefix $(install)/, $(all-files))
# Work out what needs to be removed
@@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
+
quiet_cmd_remove = REMOVE $(unwanted)
cmd_remove = rm -f $(unwanted-file)
@@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
@:
targets += $(install-file)
-$(install-file): scripts/headers_install.pl $(input-files) FORCE
+$(install-file): scripts/headers_install.pl \
+ $(input-files) FORCE
$(if $(unwanted),$(call cmd,remove),)
$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
$(call if_changed,install)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH v3] kbuild: asm-generic support
2011-04-22 15:53 ` [PATCH v3] " Sam Ravnborg
@ 2011-04-22 15:53 ` Sam Ravnborg
2011-04-25 1:29 ` Guan Xuetao
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-22 15:53 UTC (permalink / raw)
To: Michal Marek; +Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
From 34d0b72a343dd63c1c1b049e4ba6931f0dbcbc3f Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Hi Mikael.
It took me a while to get back to this.
I used your Makefile.asm-generic almost verbatim.
Only change was that we always need to create the output directory.
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 15 +++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 18 +++++++++++++++---
5 files changed, 86 insertions(+), 7 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..30b3852 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,11 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +953,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1027,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1142,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..7960b19 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
include $(kbuild-file)
_dst := $(if $(destination-y),$(destination-y),$(_dst))
+_src := $(srctree)/$(obj)
include scripts/Kbuild.include
@@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
-input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
+input-files := $(addprefix $(_src)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+
output-files := $(addprefix $(install)/, $(all-files))
# Work out what needs to be removed
@@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
+
quiet_cmd_remove = REMOVE $(unwanted)
cmd_remove = rm -f $(unwanted-file)
@@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
@:
targets += $(install-file)
-$(install-file): scripts/headers_install.pl $(input-files) FORCE
+$(install-file): scripts/headers_install.pl \
+ $(input-files) FORCE
$(if $(unwanted),$(call cmd,remove),)
$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
$(call if_changed,install)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* RE: [PATCH v3] kbuild: asm-generic support
2011-04-22 15:53 ` [PATCH v3] " Sam Ravnborg
2011-04-22 15:53 ` Sam Ravnborg
@ 2011-04-25 1:29 ` Guan Xuetao
2011-04-27 19:42 ` Sam Ravnborg
1 sibling, 1 reply; 58+ messages in thread
From: Guan Xuetao @ 2011-04-25 1:29 UTC (permalink / raw)
To: 'Sam Ravnborg', 'Michal Marek'
Cc: 'lkml', 'linux-kbuild', 'linux arch',
'Arnd Bergmann', 'Guan Xuetao'
> -----Original Message-----
> From: Sam Ravnborg [mailto:sam@ravnborg.org]
> Sent: Friday, April 22, 2011 11:54 PM
> To: Michal Marek
> Cc: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao
> Subject: [PATCH v3] kbuild: asm-generic support
>
> >From 34d0b72a343dd63c1c1b049e4ba6931f0dbcbc3f Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Fri, 22 Apr 2011 14:45:13 +0200
> Subject: [PATCH] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although a different method is used.
>
> The patch includes several improvements from Arnd Bergmann.
> Michael Marek contributed Makefile.asm-generic.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
>
> Hi Mikael.
>
> It took me a while to get back to this.
> I used your Makefile.asm-generic almost verbatim.
>
> Only change was that we always need to create the output directory.
>
> Sam
>
> .gitignore | 1 +
> Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
> Makefile | 15 +++++++++++----
> scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
> scripts/Makefile.headersinst | 18 +++++++++++++++---
> 5 files changed, 86 insertions(+), 7 deletions(-)
> create mode 100644 scripts/Makefile.asm-generic
>
> diff --git a/.gitignore b/.gitignore
> index 5d56a3f..9dacde0 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -57,6 +57,7 @@ modules.builtin
> include/config
> include/linux/version.h
> include/generated
> +arch/*/include/generated
>
> # stgit generated dirs
> patches-*
> diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
> index 5d145bb..7f2b8e7 100644
> --- a/Documentation/kbuild/makefiles.txt
> +++ b/Documentation/kbuild/makefiles.txt
> @@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
> --- 6.6 Commands useful for building a boot image
> --- 6.7 Custom kbuild commands
> --- 6.8 Preprocessing linker scripts
> + --- 6.9 Generic header files
>
> === 7 Kbuild syntax for exported headers
> --- 7.1 header-y
> --- 7.2 objhdr-y
> --- 7.3 destination-y
> + --- 7.4 generic-y
>
> === 8 Kbuild Variables
> === 9 Makefile language
> @@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
> The kbuild infrastructure for *lds file are used in several
> architecture-specific files.
>
> +--- 6.9 Generic header files
> +
> + The directory include/asm-generic contains the header files
> + that may be shared between individual architectures.
> + The recommended approach how to use a generic header file is
> + to list the file in the Kbuild file.
> + See "7.4 generic-y" for further info on syntax etc.
> +
> === 7 Kbuild syntax for exported headers
>
> The kernel include a set of headers that is exported to userspace.
> @@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
> In the example above all exported headers in the Kbuild file
> will be located in the directory "include/linux" when exported.
>
> + --- 7.4 generic-y
> +
> + If an architecture uses a verbatim copy of a header from
> + include/asm-generic then this is listed in the file
> + arch/$(ARCH)/include/asm/Kbuild like this:
> +
> + Example:
> + #arch/x86/include/asm/Kbuild
> + generic-y += termios.h
> + generic-y += rtc.h
> +
> + During the prepare phase of the build a wrapper include
> + file is generated in the directory:
> +
> + arch/$(ARCH)/include/generated/asm
> +
> + When a header is exported where the architecture uses
> + the generic header a similar wrapper is generated as part
> + of the set of exported headers in the directory:
> +
> + usr/include/asm
> +
> + The generated wrapper will in both cases look like the following:
> +
> + Example: termios.h
> + #include <asm-generic/termios.h>
>
> === 8 Kbuild Variables
>
> diff --git a/Makefile b/Makefile
> index b967b96..30b3852 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hdr-arch)/include/generated -Iinclude \
I think $(srctree) is necessary before new include-dir.
> $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -include include/generated/autoconf.h
>
> @@ -416,6 +417,11 @@ ifneq ($(KBUILD_SRC),)
> $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
> endif
>
> +# Support for using generic headers in asm-generic
> +PHONY += asm-generic
> +asm-generic:
> + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
Too long
> +
> # To make sure we do not include .config for any of the *config targets
> # catch them early, and hand them over to scripts/kconfig/Makefile
> # It is allowed to specify more targets when calling make, including
> @@ -947,7 +953,7 @@ ifneq ($(KBUILD_SRC),)
> endif
>
> # prepare2 creates a makefile if using a separate output directory
> -prepare2: prepare3 outputmakefile
> +prepare2: prepare3 outputmakefile asm-generic
>
> prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
> include/config/auto.conf
> @@ -1021,7 +1027,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
> hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
>
> PHONY += __headers
> -__headers: include/linux/version.h scripts_basic FORCE
> +__headers: include/linux/version.h scripts_basic asm-generic FORCE
> $(Q)$(MAKE) $(build)=scripts build_unifdef
>
> PHONY += headers_install_all
> @@ -1136,7 +1142,8 @@ CLEAN_FILES += vmlinux System.map \
> .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
>
> # Directories & files removed with 'make mrproper'
> -MRPROPER_DIRS += include/config usr/include include/generated
> +MRPROPER_DIRS += include/config usr/include include/generated \
> + arch/*/include/generated
> MRPROPER_FILES += .config .config.old .version .old_version \
> include/linux/version.h \
> 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 0000000..a687cb6
> --- /dev/null
> +++ b/scripts/Makefile.asm-generic
> @@ -0,0 +1,23 @@
> +# include/asm-generic contains a lot of files that are used
> +# verbatim by several architectures.
> +#
> +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
> +# and for each file listed in this file with generic-y creates
> +# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
> +
> +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
> +include $(kbuild-file)
> +
> +include scripts/Kbuild.include
> +
> +# Create output directory if not already present
> +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
> +
> +quiet_cmd_wrap = WRAP $@
> +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
> +
> +all: $(patsubst %, $(obj)/%, $(generic-y))
> +
> +$(obj)/%.h:
> + $(call cmd,wrap)
> +
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..7960b19 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -14,6 +14,7 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
> include $(kbuild-file)
>
> _dst := $(if $(destination-y),$(destination-y),$(_dst))
> +_src := $(srctree)/$(obj)
_src is only used one time
>
> include scripts/Kbuild.include
>
> @@ -27,10 +28,16 @@ header-y := $(filter-out %/, $(header-y))
> install-file := $(install)/.install
> check-file := $(install)/.check
>
> +# generic-y list all files an architecture uses from asm-generic
> +# Use this to build a list of headers which require a wrapper
> +wrapper-files := $(filter $(header-y), $(generic-y))
> +
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> -input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> +header-y := $(filter-out $(generic-y), $(header-y))
> +all-files := $(header-y) $(objhdr-y) $(wrapper-files)
> +input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +
Additional empty line
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -47,8 +54,12 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
> cmd_install = \
> $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
> $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
> + for F in $(wrapper-files); do \
> + echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
> + done; \
> touch $@
>
> +
Additional empty line
> quiet_cmd_remove = REMOVE $(unwanted)
> cmd_remove = rm -f $(unwanted-file)
>
> @@ -69,7 +80,8 @@ __headersinst: $(subdirs) $(install-file)
> @:
>
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) FORCE
The same content
> $(if $(unwanted),$(call cmd,remove),)
> $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
> $(call if_changed,install)
> --
> 1.6.0.6
I have tested on UniCore32, and it works well.
Thanks Sam.
Guan Xuetao
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH v3] kbuild: asm-generic support
2011-04-25 1:29 ` Guan Xuetao
@ 2011-04-27 19:42 ` Sam Ravnborg
2011-04-27 19:42 ` Sam Ravnborg
2011-04-27 19:46 ` [PATCH v4] " Sam Ravnborg
0 siblings, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 19:42 UTC (permalink / raw)
To: Guan Xuetao
Cc: 'Michal Marek', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd Bergmann',
'Guan Xuetao'
> > @@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
> >
> > # Use LINUXINCLUDE when you must reference the include/ directory.
> > # Needed to be compatible with the O= option
> > -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> > +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> > + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> I think $(srctree) is necessary before new include-dir.
>
The generated files are located in objtree - because they
are generated. So $(srctree) would be wrong here.
> > +PHONY += asm-generic
> > +asm-generic:
> > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
> Too long
fixed
> > _dst := $(if $(destination-y),$(destination-y),$(_dst))
> > +_src := $(srctree)/$(obj)
> _src is only used one time
fixed
> > +
> Additional empty line
fixed
> > + done; \
> > touch $@
> >
> > +
> Additional empty line
fixed
> > targets += $(install-file)
> > -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> > +$(install-file): scripts/headers_install.pl \
> > + $(input-files) FORCE
> The same content
fixed
> I have tested on UniCore32, and it works well.
I take this as "Acked-by" and "Tested-by".
Thanks for feedback - new version to be posted shortly.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH v3] kbuild: asm-generic support
2011-04-27 19:42 ` Sam Ravnborg
@ 2011-04-27 19:42 ` Sam Ravnborg
2011-04-27 19:46 ` [PATCH v4] " Sam Ravnborg
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 19:42 UTC (permalink / raw)
To: Guan Xuetao
Cc: 'Michal Marek', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd Bergmann',
'Guan Xuetao'
> > @@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
> >
> > # Use LINUXINCLUDE when you must reference the include/ directory.
> > # Needed to be compatible with the O= option
> > -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> > +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> > + -Iarch/$(hdr-arch)/include/generated -Iinclude \
> I think $(srctree) is necessary before new include-dir.
>
The generated files are located in objtree - because they
are generated. So $(srctree) would be wrong here.
> > +PHONY += asm-generic
> > +asm-generic:
> > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm
> Too long
fixed
> > _dst := $(if $(destination-y),$(destination-y),$(_dst))
> > +_src := $(srctree)/$(obj)
> _src is only used one time
fixed
> > +
> Additional empty line
fixed
> > + done; \
> > touch $@
> >
> > +
> Additional empty line
fixed
> > targets += $(install-file)
> > -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> > +$(install-file): scripts/headers_install.pl \
> > + $(input-files) FORCE
> The same content
fixed
> I have tested on UniCore32, and it works well.
I take this as "Acked-by" and "Tested-by".
Thanks for feedback - new version to be posted shortly.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PATCH v4] kbuild: asm-generic support
2011-04-27 19:42 ` Sam Ravnborg
2011-04-27 19:42 ` Sam Ravnborg
@ 2011-04-27 19:46 ` Sam Ravnborg
2011-04-27 19:46 ` Sam Ravnborg
2011-04-27 19:52 ` Arnd Bergmann
1 sibling, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 19:46 UTC (permalink / raw)
To: Guan Xuetao
Cc: 'Michal Marek', 'lkml', 'linux-kbuild',
'linux arch', 'Arnd Bergmann',
'Guan Xuetao'
From 8546953f0c87d6b1c37c25df73511780c86ad89d Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Changes v3 => v4
Addressed feedback from Guan:
- drop empty lines
- fix line-too-long
- add his Tested-by, Acked-by tags
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 16 ++++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 10 +++++++++-
5 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..9c67453 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,12 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
+ obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +954,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1028,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1143,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..a57f5bd 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
quiet_cmd_remove = REMOVE $(unwanted)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH v4] kbuild: asm-generic support
2011-04-27 19:46 ` [PATCH v4] " Sam Ravnborg
@ 2011-04-27 19:46 ` Sam Ravnborg
2011-04-27 19:52 ` Arnd Bergmann
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 19:46 UTC (permalink / raw)
To: Guan Xuetao, Michal Marek
Cc: 'lkml', 'linux-kbuild', 'linux arch',
'Arnd Bergmann', 'Guan Xuetao'
From 8546953f0c87d6b1c37c25df73511780c86ad89d Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Changes v3 => v4
Addressed feedback from Guan:
- drop empty lines
- fix line-too-long
- add his Tested-by, Acked-by tags
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 16 ++++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 10 +++++++++-
5 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..9c67453 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,12 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
+ obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +954,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1028,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1143,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..a57f5bd 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
quiet_cmd_remove = REMOVE $(unwanted)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH v4] kbuild: asm-generic support
2011-04-27 19:46 ` [PATCH v4] " Sam Ravnborg
2011-04-27 19:46 ` Sam Ravnborg
@ 2011-04-27 19:52 ` Arnd Bergmann
2011-04-27 19:52 ` Arnd Bergmann
2011-04-27 20:29 ` [PATCH v5] " Sam Ravnborg
1 sibling, 2 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-04-27 19:52 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Guan Xuetao, Michal Marek, 'lkml', 'linux-kbuild',
'linux arch', 'Guan Xuetao', Remis Lima Baima
On Wednesday 27 April 2011 21:46:47 Sam Ravnborg wrote:
> From 8546953f0c87d6b1c37c25df73511780c86ad89d Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Fri, 22 Apr 2011 14:45:13 +0200
> Subject: [PATCH] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although a different method is used.
>
> The patch includes several improvements from Arnd Bergmann.
> Michael Marek contributed Makefile.asm-generic.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
I'm glad to see this finally happen.
Maybe you can mention Remis Baima in the changelog as well,
he did an earlier implementation back in the days when some
architectures were still using include/asm-${ARCH}, which IIRC
did not get merged because of the complexity associated with
that.
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH v4] kbuild: asm-generic support
2011-04-27 19:52 ` Arnd Bergmann
@ 2011-04-27 19:52 ` Arnd Bergmann
2011-04-27 20:29 ` [PATCH v5] " Sam Ravnborg
1 sibling, 0 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-04-27 19:52 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Guan Xuetao, Michal Marek, 'lkml', 'linux-kbuild',
'linux arch', 'Guan Xuetao', Remis Lima Baima
On Wednesday 27 April 2011 21:46:47 Sam Ravnborg wrote:
> From 8546953f0c87d6b1c37c25df73511780c86ad89d Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Fri, 22 Apr 2011 14:45:13 +0200
> Subject: [PATCH] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although a different method is used.
>
> The patch includes several improvements from Arnd Bergmann.
> Michael Marek contributed Makefile.asm-generic.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
I'm glad to see this finally happen.
Maybe you can mention Remis Baima in the changelog as well,
he did an earlier implementation back in the days when some
architectures were still using include/asm-${ARCH}, which IIRC
did not get merged because of the complexity associated with
that.
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PATCH v5] kbuild: asm-generic support
2011-04-27 19:52 ` Arnd Bergmann
2011-04-27 19:52 ` Arnd Bergmann
@ 2011-04-27 20:29 ` Sam Ravnborg
2011-04-27 20:29 ` Sam Ravnborg
2011-04-28 16:16 ` Michal Marek
1 sibling, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 20:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Guan Xuetao, Michal Marek, 'lkml', 'linux-kbuild',
'linux arch', 'Guan Xuetao', Remis Lima Baima
From 1b46234aa99f235b48dce0068fb5fb56ddf6ddab Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Remis Baima did an intial implementation along to achive
the same - see https://patchwork.kernel.org/patch/13352/
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Remis Lima Baima <remis.developer@googlemail.com>
---
Changes from v4 => v5
- Mentioned Remis in changelog (thanks to Arnd)
- Added "Acked-by" from Arnd
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 16 ++++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 10 +++++++++-
5 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..9c67453 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,12 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
+ obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +954,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1028,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1143,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..a57f5bd 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
quiet_cmd_remove = REMOVE $(unwanted)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH v5] kbuild: asm-generic support
2011-04-27 20:29 ` [PATCH v5] " Sam Ravnborg
@ 2011-04-27 20:29 ` Sam Ravnborg
2011-04-28 16:16 ` Michal Marek
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-04-27 20:29 UTC (permalink / raw)
To: Arnd Bergmann, Michal Marek, Remis Lima Baima
Cc: Guan Xuetao, 'lkml', 'linux-kbuild',
'linux arch', 'Guan Xuetao'
From 1b46234aa99f235b48dce0068fb5fb56ddf6ddab Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Fri, 22 Apr 2011 14:45:13 +0200
Subject: [PATCH] kbuild: asm-generic support
There is an increasing amount of header files
shared between individual architectures in asm-generic.
To avoid a lot of dummy wrapper files that just
include the corresponding file in asm-generic provide
some basic support in kbuild for this.
With the following patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm/Kbuild
To use a generic file just add:
generic-y += <name-of-header-file.h>
For each file listed kbuild will generate the necessary
wrapper in arch/$(ARCH)/include/generated/asm.
When installing userspace headers a wrapper is likewise created.
The original inspiration for this came from the unicore32
patchset - although a different method is used.
The patch includes several improvements from Arnd Bergmann.
Michael Marek contributed Makefile.asm-generic.
Remis Baima did an intial implementation along to achive
the same - see https://patchwork.kernel.org/patch/13352/
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Remis Lima Baima <remis.developer@googlemail.com>
---
Changes from v4 => v5
- Mentioned Remis in changelog (thanks to Arnd)
- Added "Acked-by" from Arnd
Sam
.gitignore | 1 +
Documentation/kbuild/makefiles.txt | 36 ++++++++++++++++++++++++++++++++++++
Makefile | 16 ++++++++++++----
scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++
| 10 +++++++++-
5 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 scripts/Makefile.asm-generic
diff --git a/.gitignore b/.gitignore
index 5d56a3f..9dacde0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ modules.builtin
include/config
include/linux/version.h
include/generated
+arch/*/include/generated
# stgit generated dirs
patches-*
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5d145bb..7f2b8e7 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
+ --- 6.9 Generic header files
=== 7 Kbuild syntax for exported headers
--- 7.1 header-y
--- 7.2 objhdr-y
--- 7.3 destination-y
+ --- 7.4 generic-y
=== 8 Kbuild Variables
=== 9 Makefile language
@@ -1209,6 +1211,14 @@ When kbuild executes, the following steps are followed (roughly):
The kbuild infrastructure for *lds file are used in several
architecture-specific files.
+--- 6.9 Generic header files
+
+ The directory include/asm-generic contains the header files
+ that may be shared between individual architectures.
+ The recommended approach how to use a generic header file is
+ to list the file in the Kbuild file.
+ See "7.4 generic-y" for further info on syntax etc.
+
=== 7 Kbuild syntax for exported headers
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1275,32 @@ See subsequent chapter for the syntax of the Kbuild file.
In the example above all exported headers in the Kbuild file
will be located in the directory "include/linux" when exported.
+ --- 7.4 generic-y
+
+ If an architecture uses a verbatim copy of a header from
+ include/asm-generic then this is listed in the file
+ arch/$(ARCH)/include/asm/Kbuild like this:
+
+ Example:
+ #arch/x86/include/asm/Kbuild
+ generic-y += termios.h
+ generic-y += rtc.h
+
+ During the prepare phase of the build a wrapper include
+ file is generated in the directory:
+
+ arch/$(ARCH)/include/generated/asm
+
+ When a header is exported where the architecture uses
+ the generic header a similar wrapper is generated as part
+ of the set of exported headers in the directory:
+
+ usr/include/asm
+
+ The generated wrapper will in both cases look like the following:
+
+ Example: termios.h
+ #include <asm-generic/termios.h>
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index b967b96..9c67453 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
+ -Iarch/$(hdr-arch)/include/generated -Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-include include/generated/autoconf.h
@@ -416,6 +417,12 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
+# Support for using generic headers in asm-generic
+PHONY += asm-generic
+asm-generic:
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
+ obj=arch/$(SRCARCH)/include/generated/asm
+
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -947,7 +954,7 @@ ifneq ($(KBUILD_SRC),)
endif
# prepare2 creates a makefile if using a separate output directory
-prepare2: prepare3 outputmakefile
+prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
include/config/auto.conf
@@ -1021,7 +1028,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
PHONY += __headers
-__headers: include/linux/version.h scripts_basic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic FORCE
$(Q)$(MAKE) $(build)=scripts build_unifdef
PHONY += headers_install_all
@@ -1136,7 +1143,8 @@ CLEAN_FILES += vmlinux System.map \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config usr/include include/generated
+MRPROPER_DIRS += include/config usr/include include/generated \
+ arch/*/include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/linux/version.h \
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 0000000..a687cb6
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,23 @@
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# and for each file listed in this file with generic-y creates
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+
+kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
+include $(kbuild-file)
+
+include scripts/Kbuild.include
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+quiet_cmd_wrap = WRAP $@
+cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
+
+all: $(patsubst %, $(obj)/%, $(generic-y))
+
+$(obj)/%.h:
+ $(call cmd,wrap)
+
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..a57f5bd 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-y list all files an architecture uses from asm-generic
+# Use this to build a list of headers which require a wrapper
+wrapper-files := $(filter $(header-y), $(generic-y))
+
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+header-y := $(filter-out $(generic-y), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(wrapper-files)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
cmd_install = \
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+ for F in $(wrapper-files); do \
+ echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
+ done; \
touch $@
quiet_cmd_remove = REMOVE $(unwanted)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH v5] kbuild: asm-generic support
2011-04-27 20:29 ` [PATCH v5] " Sam Ravnborg
2011-04-27 20:29 ` Sam Ravnborg
@ 2011-04-28 16:16 ` Michal Marek
1 sibling, 0 replies; 58+ messages in thread
From: Michal Marek @ 2011-04-28 16:16 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Arnd Bergmann, Remis Lima Baima, Guan Xuetao, 'lkml',
'linux-kbuild', 'linux arch',
'Guan Xuetao'
On Wed, Apr 27, 2011 at 10:29:49PM +0200, Sam Ravnborg wrote:
> From 1b46234aa99f235b48dce0068fb5fb56ddf6ddab Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Fri, 22 Apr 2011 14:45:13 +0200
> Subject: [PATCH] kbuild: asm-generic support
>
> There is an increasing amount of header files
> shared between individual architectures in asm-generic.
> To avoid a lot of dummy wrapper files that just
> include the corresponding file in asm-generic provide
> some basic support in kbuild for this.
>
> With the following patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm/Kbuild
>
> To use a generic file just add:
>
> generic-y += <name-of-header-file.h>
>
> For each file listed kbuild will generate the necessary
> wrapper in arch/$(ARCH)/include/generated/asm.
>
> When installing userspace headers a wrapper is likewise created.
>
> The original inspiration for this came from the unicore32
> patchset - although a different method is used.
>
> The patch includes several improvements from Arnd Bergmann.
> Michael Marek contributed Makefile.asm-generic.
>
> Remis Baima did an intial implementation along to achive
> the same - see https://patchwork.kernel.org/patch/13352/
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Tested-by: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Remis Lima Baima <remis.developer@googlemail.com>
> ---
>
> Changes from v4 => v5
> - Mentioned Remis in changelog (thanks to Arnd)
> - Added "Acked-by" from Arnd
Applied to kbuild-2.6.git#kbuild, thanks a lot!
Michal
^ permalink raw reply [flat|nested] 58+ messages in thread