* [RFC] kbuild: generic support for asm-generic
@ 2011-01-08 13:03 Sam Ravnborg
2011-01-08 13:03 ` Sam Ravnborg
` (5 more replies)
0 siblings, 6 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:03 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
Hi Arnd et all.
This is my second attempt to provide generic support for
architectures that use existing headers from asm-generic.
With this kbuild will read the file: arch/$ARCH/include/asm-generic
For each file listed in this file a wrapper is generated in
arch/$ARCH/inclue/generated/asm/
The patch include support so headers_install works.
The inspiration came from the unicore32 patchset,
but I redid this to make it more general.
I will follow-up with two patches.
One that implment the functionality.
A second that convert two headers in x86 to use the
new asm-generic stuff (only as an example).
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [RFC] kbuild: generic support for asm-generic
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
@ 2011-01-08 13:03 ` Sam Ravnborg
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
` (4 subsequent siblings)
5 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:03 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
Hi Arnd et all.
This is my second attempt to provide generic support for
architectures that use existing headers from asm-generic.
With this kbuild will read the file: arch/$ARCH/include/asm-generic
For each file listed in this file a wrapper is generated in
arch/$ARCH/inclue/generated/asm/
The patch include support so headers_install works.
The inspiration came from the unicore32 patchset,
but I redid this to make it more general.
I will follow-up with two patches.
One that implment the functionality.
A second that convert two headers in x86 to use the
new asm-generic stuff (only as an example).
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PATCH 1/2] kbuild: asm-generic support
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-08 13:03 ` Sam Ravnborg
@ 2011-01-08 13:04 ` Sam Ravnborg
2011-01-08 13:04 ` Sam Ravnborg
` (2 more replies)
2011-01-08 13:05 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
` (3 subsequent siblings)
5 siblings, 3 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:04 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
From 47a8c36e0549191ef8b0ba7dea01d7099b772760 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 8 Jan 2011 14:00:50 +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 followign patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm-generic
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 unicor32
patchset - although is used a different method.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Makefile | 12 +++++--
include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++++--------------------
| 19 ++++++++++-
scripts/asm-generic.sh | 23 ++++++++++++++
4 files changed, 82 insertions(+), 38 deletions(-)
create mode 100644 scripts/asm-generic.sh
diff --git a/Makefile b/Makefile
index 74b2555..ee5437c 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/$(hrd-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
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index c5d2e5d..f859a88 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,45 +1,45 @@
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
$(srctree)/include/asm-$(SRCARCH)/kvm.h),)
-header-y += kvm.h
+generic-y += kvm.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
$(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
-header-y += kvm_para.h
+generic-y += kvm_para.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
$(srctree)/include/asm-$(SRCARCH)/a.out.h),)
-header-y += a.out.h
+generic-y += a.out.h
endif
-header-y += auxvec.h
-header-y += bitsperlong.h
-header-y += byteorder.h
-header-y += errno.h
-header-y += fcntl.h
-header-y += ioctl.h
-header-y += ioctls.h
-header-y += ipcbuf.h
-header-y += mman.h
-header-y += msgbuf.h
-header-y += param.h
-header-y += poll.h
-header-y += posix_types.h
-header-y += ptrace.h
-header-y += resource.h
-header-y += sembuf.h
-header-y += setup.h
-header-y += shmbuf.h
-header-y += sigcontext.h
-header-y += siginfo.h
-header-y += signal.h
-header-y += socket.h
-header-y += sockios.h
-header-y += stat.h
-header-y += statfs.h
-header-y += swab.h
-header-y += termbits.h
-header-y += termios.h
-header-y += types.h
-header-y += unistd.h
+generic-y += auxvec.h
+generic-y += bitsperlong.h
+generic-y += byteorder.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += ptrace.h
+generic-y += resource.h
+generic-y += sembuf.h
+generic-y += setup.h
+generic-y += shmbuf.h
+generic-y += sigcontext.h
+generic-y += siginfo.h
+generic-y += signal.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += swab.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += types.h
+generic-y += unistd.h
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..8cd8bb7 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -28,9 +28,10 @@ install-file := $(install)/.install
check-file := $(install)/.check
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+all-files := $(header-y) $(objhdr-y) $(generic-y)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+generic-files := $(addprefix $(install)/,$(generic-y))
output-files := $(addprefix $(install)/, $(all-files))
# Work out what needs to be removed
@@ -68,8 +69,22 @@ ifndef HDRCHECK
__headersinst: $(subdirs) $(install-file)
@:
+# List of generic files may have two sources.
+# If a file exits in $(srctree)/$(obj) use it
+# otherwise create a dummy that arch/$(ARCH)/include/
+$(generic-files): scripts/headers_install.pl
+ $(Q)set -e; \
+ if [ -f $@ ]; then \
+ $(PERL) $< $(dir $@) $(install) $(SRCARCH) $(notdir $@); \
+ else \
+ mkdir -p $(install); \
+ echo "#include <asm-generic/$(notdir $@)>" \
+ > $(install)/$(notdir $@); \
+ fi
+
targets += $(install-file)
-$(install-file): scripts/headers_install.pl $(input-files) FORCE
+$(install-file): scripts/headers_install.pl \
+ $(input-files) $(generic-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..ec53b37
--- /dev/null
+++ b/scripts/asm-generic.sh
@@ -0,0 +1,23 @@
+#!/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-generic
+# and for each file listed in this file create a small include
+# file in arch/$(ARCH)/include/generated/
+
+# If this arch does not have an asm-generic file exit
+if [ ! -e ${srctree}/arch/$1/include/asm-generic ]; then
+ exit 0
+fi
+
+# read list of header files form asm-generic
+files=$(grep -v ^# ${srctree}/arch/$1/include/asm-generic)
+
+gendir=arch/$1/include/generated/asm
+mkdir -p ${gendir}
+
+# create include files for each file used form asm-generic
+for F in ${files}; do
+ echo "#include <asm-generic/$F>" > ${gendir}/$F
+done
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH 1/2] kbuild: asm-generic support
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-08 13:04 ` Sam Ravnborg
2011-01-08 13:45 ` Stephen Rothwell
2011-01-08 14:10 ` Guan Xuetao
2 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:04 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
From 47a8c36e0549191ef8b0ba7dea01d7099b772760 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 8 Jan 2011 14:00:50 +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 followign patch an architecture can maintain
a list of files in the file arch/$(ARCH)/include/asm-generic
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 unicor32
patchset - although is used a different method.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
Cc: Arnd Bergmann <arnd@arndb.de>
---
Makefile | 12 +++++--
include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++++--------------------
| 19 ++++++++++-
scripts/asm-generic.sh | 23 ++++++++++++++
4 files changed, 82 insertions(+), 38 deletions(-)
create mode 100644 scripts/asm-generic.sh
diff --git a/Makefile b/Makefile
index 74b2555..ee5437c 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/$(hrd-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
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index c5d2e5d..f859a88 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,45 +1,45 @@
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
$(srctree)/include/asm-$(SRCARCH)/kvm.h),)
-header-y += kvm.h
+generic-y += kvm.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
$(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
-header-y += kvm_para.h
+generic-y += kvm_para.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
$(srctree)/include/asm-$(SRCARCH)/a.out.h),)
-header-y += a.out.h
+generic-y += a.out.h
endif
-header-y += auxvec.h
-header-y += bitsperlong.h
-header-y += byteorder.h
-header-y += errno.h
-header-y += fcntl.h
-header-y += ioctl.h
-header-y += ioctls.h
-header-y += ipcbuf.h
-header-y += mman.h
-header-y += msgbuf.h
-header-y += param.h
-header-y += poll.h
-header-y += posix_types.h
-header-y += ptrace.h
-header-y += resource.h
-header-y += sembuf.h
-header-y += setup.h
-header-y += shmbuf.h
-header-y += sigcontext.h
-header-y += siginfo.h
-header-y += signal.h
-header-y += socket.h
-header-y += sockios.h
-header-y += stat.h
-header-y += statfs.h
-header-y += swab.h
-header-y += termbits.h
-header-y += termios.h
-header-y += types.h
-header-y += unistd.h
+generic-y += auxvec.h
+generic-y += bitsperlong.h
+generic-y += byteorder.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += ptrace.h
+generic-y += resource.h
+generic-y += sembuf.h
+generic-y += setup.h
+generic-y += shmbuf.h
+generic-y += sigcontext.h
+generic-y += siginfo.h
+generic-y += signal.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += swab.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += types.h
+generic-y += unistd.h
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..8cd8bb7 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -28,9 +28,10 @@ install-file := $(install)/.install
check-file := $(install)/.check
# all headers files for this dir
-all-files := $(header-y) $(objhdr-y)
+all-files := $(header-y) $(objhdr-y) $(generic-y)
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+generic-files := $(addprefix $(install)/,$(generic-y))
output-files := $(addprefix $(install)/, $(all-files))
# Work out what needs to be removed
@@ -68,8 +69,22 @@ ifndef HDRCHECK
__headersinst: $(subdirs) $(install-file)
@:
+# List of generic files may have two sources.
+# If a file exits in $(srctree)/$(obj) use it
+# otherwise create a dummy that arch/$(ARCH)/include/
+$(generic-files): scripts/headers_install.pl
+ $(Q)set -e; \
+ if [ -f $@ ]; then \
+ $(PERL) $< $(dir $@) $(install) $(SRCARCH) $(notdir $@); \
+ else \
+ mkdir -p $(install); \
+ echo "#include <asm-generic/$(notdir $@)>" \
+ > $(install)/$(notdir $@); \
+ fi
+
targets += $(install-file)
-$(install-file): scripts/headers_install.pl $(input-files) FORCE
+$(install-file): scripts/headers_install.pl \
+ $(input-files) $(generic-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..ec53b37
--- /dev/null
+++ b/scripts/asm-generic.sh
@@ -0,0 +1,23 @@
+#!/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-generic
+# and for each file listed in this file create a small include
+# file in arch/$(ARCH)/include/generated/
+
+# If this arch does not have an asm-generic file exit
+if [ ! -e ${srctree}/arch/$1/include/asm-generic ]; then
+ exit 0
+fi
+
+# read list of header files form asm-generic
+files=$(grep -v ^# ${srctree}/arch/$1/include/asm-generic)
+
+gendir=arch/$1/include/generated/asm
+mkdir -p ${gendir}
+
+# create include files for each file used form asm-generic
+for F in ${files}; do
+ echo "#include <asm-generic/$F>" > ${gendir}/$F
+done
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-08 13:03 ` Sam Ravnborg
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-08 13:05 ` Sam Ravnborg
2011-01-08 13:05 ` Sam Ravnborg
2011-01-08 20:53 ` [RFC] kbuild: generic support for asm-generic Arnd Bergmann
` (2 subsequent siblings)
5 siblings, 1 reply; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:05 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
From fd70bb929b975f02879860aefb48f0b0a14d7aab Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 8 Jan 2011 13:50:52 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/.gitignore | 1 +
arch/x86/include/asm-generic | 3 +++
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 4 insertions(+), 2 deletions(-)
create mode 100644 arch/x86/include/asm-generic
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/.gitignore b/arch/x86/.gitignore
index 0280790..1448346 100644
--- a/arch/x86/.gitignore
+++ b/arch/x86/.gitignore
@@ -1,3 +1,4 @@
boot/compressed/vmlinux
tools/test_get_len
+include/generated
diff --git a/arch/x86/include/asm-generic b/arch/x86/include/asm-generic
new file mode 100644
index 0000000..50aa036
--- /dev/null
+++ b/arch/x86/include/asm-generic
@@ -0,0 +1,3 @@
+# generic headers from include/asm-generic/
+termbits.h
+termios.h
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-08 13:05 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
@ 2011-01-08 13:05 ` Sam Ravnborg
0 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 13:05 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
From fd70bb929b975f02879860aefb48f0b0a14d7aab Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 8 Jan 2011 13:50:52 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/.gitignore | 1 +
arch/x86/include/asm-generic | 3 +++
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 4 insertions(+), 2 deletions(-)
create mode 100644 arch/x86/include/asm-generic
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/.gitignore b/arch/x86/.gitignore
index 0280790..1448346 100644
--- a/arch/x86/.gitignore
+++ b/arch/x86/.gitignore
@@ -1,3 +1,4 @@
boot/compressed/vmlinux
tools/test_get_len
+include/generated
diff --git a/arch/x86/include/asm-generic b/arch/x86/include/asm-generic
new file mode 100644
index 0000000..50aa036
--- /dev/null
+++ b/arch/x86/include/asm-generic
@@ -0,0 +1,3 @@
+# generic headers from include/asm-generic/
+termbits.h
+termios.h
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-08 13:04 ` Sam Ravnborg
@ 2011-01-08 13:45 ` Stephen Rothwell
2011-01-08 14:03 ` Sam Ravnborg
2011-01-08 14:10 ` Guan Xuetao
2 siblings, 1 reply; 58+ messages in thread
From: Stephen Rothwell @ 2011-01-08 13:45 UTC (permalink / raw)
To: Sam Ravnborg
Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
[-- Attachment #1: Type: text/plain, Size: 452 bytes --]
Hi Sam,
On Sat, 8 Jan 2011 14:04:27 +0100 Sam Ravnborg <sam@ravnborg.org> wrote:
>
> -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> + -Iarch/$(hrd-arch)/include/generated -Iinclude \
^^^
hdr-arch?
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-08 13:45 ` Stephen Rothwell
@ 2011-01-08 14:03 ` Sam Ravnborg
2011-01-08 14:03 ` Sam Ravnborg
0 siblings, 1 reply; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 14:03 UTC (permalink / raw)
To: Stephen Rothwell
Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
On Sun, Jan 09, 2011 at 12:45:39AM +1100, Stephen Rothwell wrote:
> Hi Sam,
>
> On Sat, 8 Jan 2011 14:04:27 +0100 Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> > +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> > + -Iarch/$(hrd-arch)/include/generated -Iinclude \
> ^^^
> hdr-arch?
Good spotted.
I wonder how this slipped in?!?
If anyone try this - then please fix the misspelling.
I will repost patch later.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-08 14:03 ` Sam Ravnborg
@ 2011-01-08 14:03 ` Sam Ravnborg
0 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 14:03 UTC (permalink / raw)
To: Stephen Rothwell
Cc: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
On Sun, Jan 09, 2011 at 12:45:39AM +1100, Stephen Rothwell wrote:
> Hi Sam,
>
> On Sat, 8 Jan 2011 14:04:27 +0100 Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
> > +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
> > + -Iarch/$(hrd-arch)/include/generated -Iinclude \
> ^^^
> hdr-arch?
Good spotted.
I wonder how this slipped in?!?
If anyone try this - then please fix the misspelling.
I will repost patch later.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-08 13:04 ` Sam Ravnborg
2011-01-08 13:45 ` Stephen Rothwell
@ 2011-01-08 14:10 ` Guan Xuetao
2011-01-08 14:10 ` Guan Xuetao
2 siblings, 1 reply; 58+ messages in thread
From: Guan Xuetao @ 2011-01-08 14:10 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: Saturday, January 08, 2011 9:04 PM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 47a8c36e0549191ef8b0ba7dea01d7099b772760 Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sat, 8 Jan 2011 14:00:50 +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 followign patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm-generic
>
> 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 unicor32
> patchset - although is used a different method.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> Makefile | 12 +++++--
> include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++++--------------------
> scripts/Makefile.headersinst | 19 ++++++++++-
> scripts/asm-generic.sh | 23 ++++++++++++++
> 4 files changed, 82 insertions(+), 38 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/Makefile b/Makefile
> index 74b2555..ee5437c 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/$(hrd-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
arch/$(hrd-arch)/include/generated dir need to be cleaned by adding it into MRPROPER_DIRS.
> diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
> index c5d2e5d..f859a88 100644
> --- a/include/asm-generic/Kbuild.asm
> +++ b/include/asm-generic/Kbuild.asm
> @@ -1,45 +1,45 @@
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm.h),)
> -header-y += kvm.h
> +generic-y += kvm.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
> -header-y += kvm_para.h
> +generic-y += kvm_para.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
> $(srctree)/include/asm-$(SRCARCH)/a.out.h),)
> -header-y += a.out.h
> +generic-y += a.out.h
> endif
>
> -header-y += auxvec.h
> -header-y += bitsperlong.h
> -header-y += byteorder.h
> -header-y += errno.h
> -header-y += fcntl.h
> -header-y += ioctl.h
> -header-y += ioctls.h
> -header-y += ipcbuf.h
> -header-y += mman.h
> -header-y += msgbuf.h
> -header-y += param.h
> -header-y += poll.h
> -header-y += posix_types.h
> -header-y += ptrace.h
> -header-y += resource.h
> -header-y += sembuf.h
> -header-y += setup.h
> -header-y += shmbuf.h
> -header-y += sigcontext.h
> -header-y += siginfo.h
> -header-y += signal.h
> -header-y += socket.h
> -header-y += sockios.h
> -header-y += stat.h
> -header-y += statfs.h
> -header-y += swab.h
> -header-y += termbits.h
> -header-y += termios.h
> -header-y += types.h
> -header-y += unistd.h
> +generic-y += auxvec.h
> +generic-y += bitsperlong.h
> +generic-y += byteorder.h
> +generic-y += errno.h
> +generic-y += fcntl.h
> +generic-y += ioctl.h
> +generic-y += ioctls.h
> +generic-y += ipcbuf.h
> +generic-y += mman.h
> +generic-y += msgbuf.h
> +generic-y += param.h
> +generic-y += poll.h
> +generic-y += posix_types.h
> +generic-y += ptrace.h
> +generic-y += resource.h
> +generic-y += sembuf.h
> +generic-y += setup.h
> +generic-y += shmbuf.h
> +generic-y += sigcontext.h
> +generic-y += siginfo.h
> +generic-y += signal.h
> +generic-y += socket.h
> +generic-y += sockios.h
> +generic-y += stat.h
> +generic-y += statfs.h
> +generic-y += swab.h
> +generic-y += termbits.h
> +generic-y += termios.h
> +generic-y += types.h
> +generic-y += unistd.h
Kbuild.asm is included in arch/*/include/asm/Kbuild.
When replace all header-y with generic-y, the arch-spec headers will lost.
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..8cd8bb7 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -28,9 +28,10 @@ install-file := $(install)/.install
> check-file := $(install)/.check
>
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> +all-files := $(header-y) $(objhdr-y) $(generic-y)
> input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +generic-files := $(addprefix $(install)/,$(generic-y))
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -68,8 +69,22 @@ ifndef HDRCHECK
> __headersinst: $(subdirs) $(install-file)
> @:
>
> +# List of generic files may have two sources.
> +# If a file exits in $(srctree)/$(obj) use it
> +# otherwise create a dummy that arch/$(ARCH)/include/
> +$(generic-files): scripts/headers_install.pl
> + $(Q)set -e; \
> + if [ -f $@ ]; then \
> + $(PERL) $< $(dir $@) $(install) $(SRCARCH) $(notdir $@); \
> + else \
> + mkdir -p $(install); \
> + echo "#include <asm-generic/$(notdir $@)>" \
> + > $(install)/$(notdir $@); \
> + fi
> +
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) $(generic-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..ec53b37
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,23 @@
> +#!/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-generic
> +# and for each file listed in this file create a small include
> +# file in arch/$(ARCH)/include/generated/
> +
> +# If this arch does not have an asm-generic file exit
> +if [ ! -e ${srctree}/arch/$1/include/asm-generic ]; then
> + exit 0
> +fi
> +
> +# read list of header files form asm-generic
> +files=$(grep -v ^# ${srctree}/arch/$1/include/asm-generic)
> +
> +gendir=arch/$1/include/generated/asm
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
>
> --
Guan Xuetao
^ permalink raw reply [flat|nested] 58+ messages in thread
* RE: [PATCH 1/2] kbuild: asm-generic support
2011-01-08 14:10 ` Guan Xuetao
@ 2011-01-08 14:10 ` Guan Xuetao
0 siblings, 0 replies; 58+ messages in thread
From: Guan Xuetao @ 2011-01-08 14:10 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: Saturday, January 08, 2011 9:04 PM
> To: lkml; linux-kbuild; linux arch; Arnd Bergmann; Guan Xuetao; Michal Marek
> Subject: [PATCH 1/2] kbuild: asm-generic support
>
> >From 47a8c36e0549191ef8b0ba7dea01d7099b772760 Mon Sep 17 00:00:00 2001
> From: Sam Ravnborg <sam@ravnborg.org>
> Date: Sat, 8 Jan 2011 14:00:50 +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 followign patch an architecture can maintain
> a list of files in the file arch/$(ARCH)/include/asm-generic
>
> 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 unicor32
> patchset - although is used a different method.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
> Makefile | 12 +++++--
> include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++++--------------------
> scripts/Makefile.headersinst | 19 ++++++++++-
> scripts/asm-generic.sh | 23 ++++++++++++++
> 4 files changed, 82 insertions(+), 38 deletions(-)
> create mode 100644 scripts/asm-generic.sh
>
> diff --git a/Makefile b/Makefile
> index 74b2555..ee5437c 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/$(hrd-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
arch/$(hrd-arch)/include/generated dir need to be cleaned by adding it into MRPROPER_DIRS.
> diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
> index c5d2e5d..f859a88 100644
> --- a/include/asm-generic/Kbuild.asm
> +++ b/include/asm-generic/Kbuild.asm
> @@ -1,45 +1,45 @@
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm.h),)
> -header-y += kvm.h
> +generic-y += kvm.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
> -header-y += kvm_para.h
> +generic-y += kvm_para.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
> $(srctree)/include/asm-$(SRCARCH)/a.out.h),)
> -header-y += a.out.h
> +generic-y += a.out.h
> endif
>
> -header-y += auxvec.h
> -header-y += bitsperlong.h
> -header-y += byteorder.h
> -header-y += errno.h
> -header-y += fcntl.h
> -header-y += ioctl.h
> -header-y += ioctls.h
> -header-y += ipcbuf.h
> -header-y += mman.h
> -header-y += msgbuf.h
> -header-y += param.h
> -header-y += poll.h
> -header-y += posix_types.h
> -header-y += ptrace.h
> -header-y += resource.h
> -header-y += sembuf.h
> -header-y += setup.h
> -header-y += shmbuf.h
> -header-y += sigcontext.h
> -header-y += siginfo.h
> -header-y += signal.h
> -header-y += socket.h
> -header-y += sockios.h
> -header-y += stat.h
> -header-y += statfs.h
> -header-y += swab.h
> -header-y += termbits.h
> -header-y += termios.h
> -header-y += types.h
> -header-y += unistd.h
> +generic-y += auxvec.h
> +generic-y += bitsperlong.h
> +generic-y += byteorder.h
> +generic-y += errno.h
> +generic-y += fcntl.h
> +generic-y += ioctl.h
> +generic-y += ioctls.h
> +generic-y += ipcbuf.h
> +generic-y += mman.h
> +generic-y += msgbuf.h
> +generic-y += param.h
> +generic-y += poll.h
> +generic-y += posix_types.h
> +generic-y += ptrace.h
> +generic-y += resource.h
> +generic-y += sembuf.h
> +generic-y += setup.h
> +generic-y += shmbuf.h
> +generic-y += sigcontext.h
> +generic-y += siginfo.h
> +generic-y += signal.h
> +generic-y += socket.h
> +generic-y += sockios.h
> +generic-y += stat.h
> +generic-y += statfs.h
> +generic-y += swab.h
> +generic-y += termbits.h
> +generic-y += termios.h
> +generic-y += types.h
> +generic-y += unistd.h
Kbuild.asm is included in arch/*/include/asm/Kbuild.
When replace all header-y with generic-y, the arch-spec headers will lost.
> diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
> index f89cb87..8cd8bb7 100644
> --- a/scripts/Makefile.headersinst
> +++ b/scripts/Makefile.headersinst
> @@ -28,9 +28,10 @@ install-file := $(install)/.install
> check-file := $(install)/.check
>
> # all headers files for this dir
> -all-files := $(header-y) $(objhdr-y)
> +all-files := $(header-y) $(objhdr-y) $(generic-y)
> input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
> +generic-files := $(addprefix $(install)/,$(generic-y))
> output-files := $(addprefix $(install)/, $(all-files))
>
> # Work out what needs to be removed
> @@ -68,8 +69,22 @@ ifndef HDRCHECK
> __headersinst: $(subdirs) $(install-file)
> @:
>
> +# List of generic files may have two sources.
> +# If a file exits in $(srctree)/$(obj) use it
> +# otherwise create a dummy that arch/$(ARCH)/include/
> +$(generic-files): scripts/headers_install.pl
> + $(Q)set -e; \
> + if [ -f $@ ]; then \
> + $(PERL) $< $(dir $@) $(install) $(SRCARCH) $(notdir $@); \
> + else \
> + mkdir -p $(install); \
> + echo "#include <asm-generic/$(notdir $@)>" \
> + > $(install)/$(notdir $@); \
> + fi
> +
> targets += $(install-file)
> -$(install-file): scripts/headers_install.pl $(input-files) FORCE
> +$(install-file): scripts/headers_install.pl \
> + $(input-files) $(generic-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..ec53b37
> --- /dev/null
> +++ b/scripts/asm-generic.sh
> @@ -0,0 +1,23 @@
> +#!/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-generic
> +# and for each file listed in this file create a small include
> +# file in arch/$(ARCH)/include/generated/
> +
> +# If this arch does not have an asm-generic file exit
> +if [ ! -e ${srctree}/arch/$1/include/asm-generic ]; then
> + exit 0
> +fi
> +
> +# read list of header files form asm-generic
> +files=$(grep -v ^# ${srctree}/arch/$1/include/asm-generic)
> +
> +gendir=arch/$1/include/generated/asm
> +mkdir -p ${gendir}
> +
> +# create include files for each file used form asm-generic
> +for F in ${files}; do
> + echo "#include <asm-generic/$F>" > ${gendir}/$F
> +done
> --
> 1.6.0.6
>
> --
Guan Xuetao
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [RFC] kbuild: generic support for asm-generic
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
` (2 preceding siblings ...)
2011-01-08 13:05 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
@ 2011-01-08 20:53 ` Arnd Bergmann
2011-01-08 21:33 ` Sam Ravnborg
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
5 siblings, 1 reply; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-08 20:53 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Saturday 08 January 2011, Sam Ravnborg wrote:
> Hi Arnd et all.
>
> This is my second attempt to provide generic support for
> architectures that use existing headers from asm-generic.
>
> With this kbuild will read the file: arch/$ARCH/include/asm-generic
>
> For each file listed in this file a wrapper is generated in
> arch/$ARCH/inclue/generated/asm/
>
> The patch include support so headers_install works.
>
> The inspiration came from the unicore32 patchset,
> but I redid this to make it more general.
>
> I will follow-up with two patches.
> One that implment the functionality.
> A second that convert two headers in x86 to use the
> new asm-generic stuff (only as an example).
Very nice patch!
This is something I'd certainly like to see upstream, and you made
a good point about keeping it seperate from the unicore32 submission.
One detail I don't like too much is that you now have two different
formats for specifying lists of headers to do something with.
Instead of the new arch/*/include/asm-generic file, how about listing
all files that are actually provided by the architecture as "header-y"
in arch/*/include/asm/Kbuild, and listing all files as something
else in include/asm-generic/Kbuild and include/asm-generic/Kbuild.asm?
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [RFC] kbuild: generic support for asm-generic
2011-01-08 20:53 ` [RFC] kbuild: generic support for asm-generic Arnd Bergmann
@ 2011-01-08 21:33 ` Sam Ravnborg
2011-01-08 21:33 ` Sam Ravnborg
2011-01-09 0:15 ` Arnd Bergmann
0 siblings, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 21:33 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Sat, Jan 08, 2011 at 09:53:31PM +0100, Arnd Bergmann wrote:
> On Saturday 08 January 2011, Sam Ravnborg wrote:
> > Hi Arnd et all.
> >
> > This is my second attempt to provide generic support for
> > architectures that use existing headers from asm-generic.
> >
> > With this kbuild will read the file: arch/$ARCH/include/asm-generic
> >
> > For each file listed in this file a wrapper is generated in
> > arch/$ARCH/inclue/generated/asm/
> >
> > The patch include support so headers_install works.
> >
> > The inspiration came from the unicore32 patchset,
> > but I redid this to make it more general.
> >
> > I will follow-up with two patches.
> > One that implment the functionality.
> > A second that convert two headers in x86 to use the
> > new asm-generic stuff (only as an example).
>
> Very nice patch!
>
> This is something I'd certainly like to see upstream, and you made
> a good point about keeping it seperate from the unicore32 submission.
>
> One detail I don't like too much is that you now have two different
> formats for specifying lists of headers to do something with.
>
> Instead of the new arch/*/include/asm-generic file, how about listing
> all files that are actually provided by the architecture as "header-y"
> in arch/*/include/asm/Kbuild, and listing all files as something
> else in include/asm-generic/Kbuild and include/asm-generic/Kbuild.asm?
Good point.
I will try to address this together with the comments from Guang.
If we use Kbuild syntax then I think we shall name the file
something like
Kbuild.asm-generic
I need to think about the naming of the variables...
We need a variables to express:
In include/asm-generic/Kbuild.asm
- This file exists in a generic variant and it is exported.
The arch may use it verbatim or may have a local variant
In arch/$(ARCH)/include/Kbuild.asm-generic
- This file is provided verbatim by asm-generic
Something like:
export-y - for files listed in Kbuild.asm
generic-y - for files listed in Kbuild.asm-generic
I will try to come up with a patch that uses this - or something
similar.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [RFC] kbuild: generic support for asm-generic
2011-01-08 21:33 ` Sam Ravnborg
@ 2011-01-08 21:33 ` Sam Ravnborg
2011-01-09 0:15 ` Arnd Bergmann
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-08 21:33 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Sat, Jan 08, 2011 at 09:53:31PM +0100, Arnd Bergmann wrote:
> On Saturday 08 January 2011, Sam Ravnborg wrote:
> > Hi Arnd et all.
> >
> > This is my second attempt to provide generic support for
> > architectures that use existing headers from asm-generic.
> >
> > With this kbuild will read the file: arch/$ARCH/include/asm-generic
> >
> > For each file listed in this file a wrapper is generated in
> > arch/$ARCH/inclue/generated/asm/
> >
> > The patch include support so headers_install works.
> >
> > The inspiration came from the unicore32 patchset,
> > but I redid this to make it more general.
> >
> > I will follow-up with two patches.
> > One that implment the functionality.
> > A second that convert two headers in x86 to use the
> > new asm-generic stuff (only as an example).
>
> Very nice patch!
>
> This is something I'd certainly like to see upstream, and you made
> a good point about keeping it seperate from the unicore32 submission.
>
> One detail I don't like too much is that you now have two different
> formats for specifying lists of headers to do something with.
>
> Instead of the new arch/*/include/asm-generic file, how about listing
> all files that are actually provided by the architecture as "header-y"
> in arch/*/include/asm/Kbuild, and listing all files as something
> else in include/asm-generic/Kbuild and include/asm-generic/Kbuild.asm?
Good point.
I will try to address this together with the comments from Guang.
If we use Kbuild syntax then I think we shall name the file
something like
Kbuild.asm-generic
I need to think about the naming of the variables...
We need a variables to express:
In include/asm-generic/Kbuild.asm
- This file exists in a generic variant and it is exported.
The arch may use it verbatim or may have a local variant
In arch/$(ARCH)/include/Kbuild.asm-generic
- This file is provided verbatim by asm-generic
Something like:
export-y - for files listed in Kbuild.asm
generic-y - for files listed in Kbuild.asm-generic
I will try to come up with a patch that uses this - or something
similar.
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [RFC] kbuild: generic support for asm-generic
2011-01-08 21:33 ` Sam Ravnborg
2011-01-08 21:33 ` Sam Ravnborg
@ 2011-01-09 0:15 ` Arnd Bergmann
1 sibling, 0 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 0:15 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek
On Saturday 08 January 2011, Sam Ravnborg wrote:
> We need a variables to express:
> In include/asm-generic/Kbuild.asm
> - This file exists in a generic variant and it is exported.
> The arch may use it verbatim or may have a local variant
Actually, this is not how we traditionally use Kbuild.asm:
This file is only included from the other asm/Kbuild files to
get the list of common files that should be exported from the
architectures. Originally, this included even files that had
no asm-generic counterpart, but that has probably changed now.
The naming of that file may have been a bit confusing.
We already have the list of exported files in
include/asm-generic/Kbuild that sort of does what you describe.
> In arch/$(ARCH)/include/Kbuild.asm-generic
> - This file is provided verbatim by asm-generic
I would just put this information into the
arch/$(ARCH)/include/Kbuild file, with a different variable
name.
The other complication is that not all the files that an
architecture may take verbatim from asm-generic are also
exported.
> Something like:
>
> export-y - for files listed in Kbuild.asm
> generic-y - for files listed in Kbuild.asm-generic
>
> I will try to come up with a patch that uses this - or something
> similar.
Ok.
Would it be enough to have this?:
"generic-y" in arch/$(ARCH)/include/asm/Kbuild:
The architecture does not provide this header, the kernel should use
the asm-generic version through a generated file.
"header-y" in arch/$(ARCH)/include/asm/Kbuild and include/asm-generic/Kbuild.asm:
This file gets exported to user space (as before), and may come from either
arch/$(ARCH)/include/asm or include/asm-generic (if listed as generic-y).
"header-y" in include/asm-generic/Kbuild: The asm-generic version of the header
gets installed. We always do this, because there might be reasons to install
headers for multiple architectures (with a symlink or similar).
We could either install the generated file or a copy of the asm-generic file
for any exported header that the architecture does not have itself.
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* [RFC v2] kbuild: generic support for asm-generic
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
` (3 preceding siblings ...)
2011-01-08 20:53 ` [RFC] kbuild: generic support for asm-generic Arnd Bergmann
@ 2011-01-09 8:28 ` Sam Ravnborg
2011-01-09 8:28 ` Sam Ravnborg
` (2 more replies)
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
5 siblings, 3 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:28 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
Cc: Stephen Rothwell
On Sat, Jan 08, 2011 at 02:03:02PM +0100, Sam Ravnborg wrote:
> Hi Arnd et all.
>
> This is my second attempt to provide generic support for
> architectures that use existing headers from asm-generic.
>
> With this kbuild will read the file: arch/$ARCH/include/asm-generic
>
> For each file listed in this file a wrapper is generated in
> arch/$ARCH/inclue/generated/asm/
>
> The patch include support so headers_install works.
>
> The inspiration came from the unicore32 patchset,
> but I redid this to make it more general.
>
> I will follow-up with two patches.
> One that implment the functionality.
> A second that convert two headers in x86 to use the
> new asm-generic stuff (only as an example).
Based on feedback from Stephen, Guang and Arnd here
is a new patchset supporting generic headers.
Changes since v2:
- Fix spelling miss in LINUXINCLUDE (Stephen)
- Properly delete file with mrproper (Guang)
- Fixed support for headers that are not exported (Guang)
- New way to list files used from the generic set (Arnd)
We now list which files are sued from the generic set in:
arch/$(ARCH)/include/asm/Kbuild like this:
generic-y += termios.h
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [RFC v2] kbuild: generic support for asm-generic
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
@ 2011-01-09 8:28 ` Sam Ravnborg
2011-01-09 8:31 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 8:32 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:28 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
Cc: Stephen Rothwell
On Sat, Jan 08, 2011 at 02:03:02PM +0100, Sam Ravnborg wrote:
> Hi Arnd et all.
>
> This is my second attempt to provide generic support for
> architectures that use existing headers from asm-generic.
>
> With this kbuild will read the file: arch/$ARCH/include/asm-generic
>
> For each file listed in this file a wrapper is generated in
> arch/$ARCH/inclue/generated/asm/
>
> The patch include support so headers_install works.
>
> The inspiration came from the unicore32 patchset,
> but I redid this to make it more general.
>
> I will follow-up with two patches.
> One that implment the functionality.
> A second that convert two headers in x86 to use the
> new asm-generic stuff (only as an example).
Based on feedback from Stephen, Guang and Arnd here
is a new patchset supporting generic headers.
Changes since v2:
- Fix spelling miss in LINUXINCLUDE (Stephen)
- Properly delete file with mrproper (Guang)
- Fixed support for headers that are not exported (Guang)
- New way to list files used from the generic set (Arnd)
We now list which files are sued from the generic set in:
arch/$(ARCH)/include/asm/Kbuild like this:
generic-y += termios.h
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PATCH 1/2] kbuild: asm-generic support
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
2011-01-09 8:28 ` Sam Ravnborg
@ 2011-01-09 8:31 ` Sam Ravnborg
2011-01-09 8:31 ` Sam Ravnborg
2011-01-09 14:03 ` Arnd Bergmann
2011-01-09 8:32 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2 siblings, 2 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:31 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
Cc: Stephen Rothwell
From a7928ed5ab8b1f8f1b1b2bd8a9cb59819f46a522 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:13:22 +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 unicor32
patchset - although is used a different method.
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 | 31 +++++++++++++++++
Makefile | 15 ++++++--
include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++------------------
| 19 +++++++++--
scripts/asm-generic.sh | 23 ++++++++++++
6 files changed, 115 insertions(+), 40 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..7763786 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1250,6 +1250,37 @@ 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.
+
+ --- 7.5 generic-export-y
+
+ List of generic headers to be exported if the architecture
+ does not have their own variants.
+
+ Example:
+ #include/asm-generic/Kbuild.asm
+ generic-export-y += termios.h
+
+ See "generic-y" for a description of how an architectue
+ define which headers are used from the generic set.
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index 74b2555..9eeb44e 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/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index c5d2e5d..a9e89f3 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,45 +1,45 @@
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
$(srctree)/include/asm-$(SRCARCH)/kvm.h),)
-header-y += kvm.h
+generic-export-y += kvm.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
$(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
-header-y += kvm_para.h
+generic-export-y += kvm_para.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
$(srctree)/include/asm-$(SRCARCH)/a.out.h),)
-header-y += a.out.h
+generic-export-y += a.out.h
endif
-header-y += auxvec.h
-header-y += bitsperlong.h
-header-y += byteorder.h
-header-y += errno.h
-header-y += fcntl.h
-header-y += ioctl.h
-header-y += ioctls.h
-header-y += ipcbuf.h
-header-y += mman.h
-header-y += msgbuf.h
-header-y += param.h
-header-y += poll.h
-header-y += posix_types.h
-header-y += ptrace.h
-header-y += resource.h
-header-y += sembuf.h
-header-y += setup.h
-header-y += shmbuf.h
-header-y += sigcontext.h
-header-y += siginfo.h
-header-y += signal.h
-header-y += socket.h
-header-y += sockios.h
-header-y += stat.h
-header-y += statfs.h
-header-y += swab.h
-header-y += termbits.h
-header-y += termios.h
-header-y += types.h
-header-y += unistd.h
+generic-export-y += auxvec.h
+generic-export-y += bitsperlong.h
+generic-export-y += byteorder.h
+generic-export-y += errno.h
+generic-export-y += fcntl.h
+generic-export-y += ioctl.h
+generic-export-y += ioctls.h
+generic-export-y += ipcbuf.h
+generic-export-y += mman.h
+generic-export-y += msgbuf.h
+generic-export-y += param.h
+generic-export-y += poll.h
+generic-export-y += posix_types.h
+generic-export-y += ptrace.h
+generic-export-y += resource.h
+generic-export-y += sembuf.h
+generic-export-y += setup.h
+generic-export-y += shmbuf.h
+generic-export-y += sigcontext.h
+generic-export-y += siginfo.h
+generic-export-y += signal.h
+generic-export-y += socket.h
+generic-export-y += sockios.h
+generic-export-y += stat.h
+generic-export-y += statfs.h
+generic-export-y += swab.h
+generic-export-y += termbits.h
+generic-export-y += termios.h
+generic-export-y += types.h
+generic-export-y += unistd.h
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..3a630c2 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,17 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-export-y list all generic headers to be exported
+# 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 $(generic-export-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 $(wrapper-files), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(generic-y)
+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 +55,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 +81,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..bc04f08
--- /dev/null
+++ b/scripts/asm-generic.sh
@@ -0,0 +1,23 @@
+#!/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>
+files=$( cat ${srctree}/arch/$1/include/asm/Kbuild | \
+ grep -v ^# | grep generic-y | cut -d '=' -f 2)
+
+gendir=arch/$1/include/generated/asm
+mkdir -p ${gendir}
+
+# create include files for each file used form asm-generic
+for F in ${files}; do
+ echo "#include <asm-generic/$F>" > ${gendir}/$F
+done
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PATCH 1/2] kbuild: asm-generic support
2011-01-09 8:31 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-09 8:31 ` Sam Ravnborg
2011-01-09 14:03 ` Arnd Bergmann
1 sibling, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:31 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
Cc: Stephen Rothwell
From a7928ed5ab8b1f8f1b1b2bd8a9cb59819f46a522 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:13:22 +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 unicor32
patchset - although is used a different method.
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 | 31 +++++++++++++++++
Makefile | 15 ++++++--
include/asm-generic/Kbuild.asm | 66 ++++++++++++++++++------------------
| 19 +++++++++--
scripts/asm-generic.sh | 23 ++++++++++++
6 files changed, 115 insertions(+), 40 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..7763786 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1250,6 +1250,37 @@ 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.
+
+ --- 7.5 generic-export-y
+
+ List of generic headers to be exported if the architecture
+ does not have their own variants.
+
+ Example:
+ #include/asm-generic/Kbuild.asm
+ generic-export-y += termios.h
+
+ See "generic-y" for a description of how an architectue
+ define which headers are used from the generic set.
=== 8 Kbuild Variables
diff --git a/Makefile b/Makefile
index 74b2555..9eeb44e 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/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index c5d2e5d..a9e89f3 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,45 +1,45 @@
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
$(srctree)/include/asm-$(SRCARCH)/kvm.h),)
-header-y += kvm.h
+generic-export-y += kvm.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
$(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
-header-y += kvm_para.h
+generic-export-y += kvm_para.h
endif
ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
$(srctree)/include/asm-$(SRCARCH)/a.out.h),)
-header-y += a.out.h
+generic-export-y += a.out.h
endif
-header-y += auxvec.h
-header-y += bitsperlong.h
-header-y += byteorder.h
-header-y += errno.h
-header-y += fcntl.h
-header-y += ioctl.h
-header-y += ioctls.h
-header-y += ipcbuf.h
-header-y += mman.h
-header-y += msgbuf.h
-header-y += param.h
-header-y += poll.h
-header-y += posix_types.h
-header-y += ptrace.h
-header-y += resource.h
-header-y += sembuf.h
-header-y += setup.h
-header-y += shmbuf.h
-header-y += sigcontext.h
-header-y += siginfo.h
-header-y += signal.h
-header-y += socket.h
-header-y += sockios.h
-header-y += stat.h
-header-y += statfs.h
-header-y += swab.h
-header-y += termbits.h
-header-y += termios.h
-header-y += types.h
-header-y += unistd.h
+generic-export-y += auxvec.h
+generic-export-y += bitsperlong.h
+generic-export-y += byteorder.h
+generic-export-y += errno.h
+generic-export-y += fcntl.h
+generic-export-y += ioctl.h
+generic-export-y += ioctls.h
+generic-export-y += ipcbuf.h
+generic-export-y += mman.h
+generic-export-y += msgbuf.h
+generic-export-y += param.h
+generic-export-y += poll.h
+generic-export-y += posix_types.h
+generic-export-y += ptrace.h
+generic-export-y += resource.h
+generic-export-y += sembuf.h
+generic-export-y += setup.h
+generic-export-y += shmbuf.h
+generic-export-y += sigcontext.h
+generic-export-y += siginfo.h
+generic-export-y += signal.h
+generic-export-y += socket.h
+generic-export-y += sockios.h
+generic-export-y += stat.h
+generic-export-y += statfs.h
+generic-export-y += swab.h
+generic-export-y += termbits.h
+generic-export-y += termios.h
+generic-export-y += types.h
+generic-export-y += unistd.h
--git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87..3a630c2 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,17 @@ header-y := $(filter-out %/, $(header-y))
install-file := $(install)/.install
check-file := $(install)/.check
+# generic-export-y list all generic headers to be exported
+# 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 $(generic-export-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 $(wrapper-files), $(header-y))
+all-files := $(header-y) $(objhdr-y) $(generic-y)
+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 +55,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 +81,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..bc04f08
--- /dev/null
+++ b/scripts/asm-generic.sh
@@ -0,0 +1,23 @@
+#!/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>
+files=$( cat ${srctree}/arch/$1/include/asm/Kbuild | \
+ grep -v ^# | grep generic-y | cut -d '=' -f 2)
+
+gendir=arch/$1/include/generated/asm
+mkdir -p ${gendir}
+
+# create include files for each file used form asm-generic
+for F in ${files}; do
+ echo "#include <asm-generic/$F>" > ${gendir}/$F
+done
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
2011-01-09 8:28 ` Sam Ravnborg
2011-01-09 8:31 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-09 8:32 ` Sam Ravnborg
2011-01-09 8:32 ` Sam Ravnborg
2 siblings, 1 reply; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:32 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
Cc: Stephen Rothwell
From bcd633fff41f218bfd4fa4b8361fa2f80c1f9298 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:29:57 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 6fa90a8..52bf61c 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -23,3 +23,9 @@ header-y += unistd_32.h
header-y += unistd_64.h
header-y += vm86.h
header-y += vsyscall.h
+
+# generic headers from include/asm-generic/
+generic-y += termios.h
+generic-y += termbits.h
+generic-y += rtc.h
+
diff --git a/arch/x86/include/asm/rtc.h b/arch/x86/include/asm/rtc.h
deleted file mode 100644
index f71c3b0..0000000
--- a/arch/x86/include/asm/rtc.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/rtc.h>
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-09 8:32 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
@ 2011-01-09 8:32 ` Sam Ravnborg
0 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 8:32 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
Cc: Stephen Rothwell
From bcd633fff41f218bfd4fa4b8361fa2f80c1f9298 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:29:57 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 6fa90a8..52bf61c 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -23,3 +23,9 @@ header-y += unistd_32.h
header-y += unistd_64.h
header-y += vm86.h
header-y += vsyscall.h
+
+# generic headers from include/asm-generic/
+generic-y += termios.h
+generic-y += termbits.h
+generic-y += rtc.h
+
diff --git a/arch/x86/include/asm/rtc.h b/arch/x86/include/asm/rtc.h
deleted file mode 100644
index f71c3b0..0000000
--- a/arch/x86/include/asm/rtc.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/rtc.h>
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
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 8:31 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 8:31 ` Sam Ravnborg
@ 2011-01-09 14:03 ` Arnd Bergmann
2011-01-09 15:10 ` Sam Ravnborg
1 sibling, 1 reply; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 14:03 UTC (permalink / raw)
To: Sam Ravnborg
Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek,
Stephen Rothwell
Hi Sam,
Looks much cleaner to me now, but I still don't see why we even need
the new generic-export-y variable in addition to export-y. Can't we
just simply install all $(filter-out, $(generated-y), $(header-y))
from arch/$(SRCARCH)/include/asm and all $(filter, $(generated-y),
$(header-y)) from rch/$(SRCARCH)/include/generated/asm?
I think that would lead to a less confusing set of rules.
On Sunday 09 January 2011, Sam Ravnborg wrote:
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm.h),)
> -header-y += kvm.h
> +generic-export-y += kvm.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
> $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
> -header-y += kvm_para.h
> +generic-export-y += kvm_para.h
> endif
>
> ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
> $(srctree)/include/asm-$(SRCARCH)/a.out.h),)
> -header-y += a.out.h
> +generic-export-y += a.out.h
> endif
We can probably use the opportunity to clean this up as well, I never
like the idea of conditionalizing the installation of a header on the
presence of the file. Instead, we could either generate these headers
from new generic versions of them, or just put the header-y+= into
arch/$(SRCARCH)/include/asm/Kbuild where it belonged in the first
place.
The Kbuild.asm file was initially meant to list the files that are
exported from every architecture, so we could see the exact differences
in each architecture from its asm/Kbuild file.
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 14:03 ` Arnd Bergmann
@ 2011-01-09 15:10 ` Sam Ravnborg
2011-01-09 16:13 ` Arnd Bergmann
0 siblings, 1 reply; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 15:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek,
Stephen Rothwell
On Sun, Jan 09, 2011 at 03:03:33PM +0100, Arnd Bergmann wrote:
> Hi Sam,
>
> Looks much cleaner to me now, but I still don't see why we even need
> the new generic-export-y variable in addition to export-y. Can't we
> just simply install all $(filter-out, $(generated-y), $(header-y))
> from arch/$(SRCARCH)/include/asm and all $(filter, $(generated-y),
> $(header-y)) from rch/$(SRCARCH)/include/generated/asm?
Like this:
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 3a630c2..7c06dcf 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -31,10 +31,10 @@ check-file := $(install)/.check
# generic-export-y list all generic headers to be exported
# 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 $(generic-export-y), $(generic-y))
+wrapper-files := $(filter $(header-y), $(generic-y))
# all headers files for this dir
-header-y := $(filter-out $(wrapper-files), $(header-y))
+header-y := $(filter-out $(generic-y), $(header-y))
all-files := $(header-y) $(objhdr-y) $(generic-y)
input-files := $(addprefix $(_src)/,$(header-y)) \
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
And then reverting the changes to Kbuild.asm.
Yes this works - and is much simpler. Good!
I originally wanted to know wat set of files I worked
with but this is not needed.
I will test it a bit more tonight and post a v3 of the patchset.
Thanks for the review!
Sam
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 15:10 ` Sam Ravnborg
@ 2011-01-09 16:13 ` Arnd Bergmann
2011-01-09 16:13 ` Arnd Bergmann
0 siblings, 1 reply; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 16:13 UTC (permalink / raw)
To: Sam Ravnborg
Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek,
Stephen Rothwell
On Sunday 09 January 2011, Sam Ravnborg wrote:
> @@ -31,10 +31,10 @@ check-file := $(install)/.check
> # generic-export-y list all generic headers to be exported
> # 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 $(generic-export-y), $(generic-y))
> +wrapper-files := $(filter $(header-y), $(generic-y))
>
> # all headers files for this dir
> -header-y := $(filter-out $(wrapper-files), $(header-y))
> +header-y := $(filter-out $(generic-y), $(header-y))
> all-files := $(header-y) $(objhdr-y) $(generic-y)
> input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
>
> And then reverting the changes to Kbuild.asm.
> Yes this works - and is much simpler. Good!
Ok, excellent!
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [PATCH 1/2] kbuild: asm-generic support
2011-01-09 16:13 ` Arnd Bergmann
@ 2011-01-09 16:13 ` Arnd Bergmann
0 siblings, 0 replies; 58+ messages in thread
From: Arnd Bergmann @ 2011-01-09 16:13 UTC (permalink / raw)
To: Sam Ravnborg
Cc: lkml, linux-kbuild, linux arch, Guan Xuetao, Michal Marek,
Stephen Rothwell
On Sunday 09 January 2011, Sam Ravnborg wrote:
> @@ -31,10 +31,10 @@ check-file := $(install)/.check
> # generic-export-y list all generic headers to be exported
> # 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 $(generic-export-y), $(generic-y))
> +wrapper-files := $(filter $(header-y), $(generic-y))
>
> # all headers files for this dir
> -header-y := $(filter-out $(wrapper-files), $(header-y))
> +header-y := $(filter-out $(generic-y), $(header-y))
> all-files := $(header-y) $(objhdr-y) $(generic-y)
> input-files := $(addprefix $(_src)/,$(header-y)) \
> $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
>
> And then reverting the changes to Kbuild.asm.
> Yes this works - and is much simpler. Good!
Ok, excellent!
Arnd
^ permalink raw reply [flat|nested] 58+ messages in thread
* [RFC v3] kbuild: generic support for asm-generic
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
` (4 preceding siblings ...)
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
@ 2011-01-09 19:27 ` Sam Ravnborg
2011-01-09 19:27 ` Sam Ravnborg
` (2 more replies)
5 siblings, 3 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 19:27 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao
Hi Michal, Arnd et all.
This is my second attempt to provide generic support for
architectures that use existing headers from asm-generic.
@Michal - I consider this ready for you to review / apply.
I would prefer if this patch could be included in the current
merge window - allowing us to convert archs until next merge window.
As this touches the top-level Makefile in an area that is always
used I suggest to at least let i cook in -next for a few days first.
It was inspired by unicore32 - but I have requested Guang _not_
to convert unicore32 to avoid a dependency on this patch.
The patch description:
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.
Changes since v2:
- Fix spelling miss in LINUXINCLUDE (Stephen)
- Properly delete file with mrproper (Guang)
- Fixed support for headers that are not exported (Guang)
- New way to list files used from the generic set (Arnd)
Changes since v3:
- Dropped generic-export.y (from Arnd)
- added check if header is listed as generic but still is present
- fixed "make headers_check"
- updated documentation
I did not include an Reviewed-by / Acked-by from Arnd as
he had not seen the latest iteration in the full.
Diffstat for the patch:
.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
Sample diffstat when using generic-y for three files in x86:
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [RFC v3] kbuild: generic support for asm-generic
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
@ 2011-01-09 19:27 ` Sam Ravnborg
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 19:29 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2 siblings, 0 replies; 58+ messages in thread
From: Sam Ravnborg @ 2011-01-09 19:27 UTC (permalink / raw)
To: lkml, linux-kbuild, linux arch, Arnd Bergmann, Guan Xuetao,
Michal Marek
Hi Michal, Arnd et all.
This is my second attempt to provide generic support for
architectures that use existing headers from asm-generic.
@Michal - I consider this ready for you to review / apply.
I would prefer if this patch could be included in the current
merge window - allowing us to convert archs until next merge window.
As this touches the top-level Makefile in an area that is always
used I suggest to at least let i cook in -next for a few days first.
It was inspired by unicore32 - but I have requested Guang _not_
to convert unicore32 to avoid a dependency on this patch.
The patch description:
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.
Changes since v2:
- Fix spelling miss in LINUXINCLUDE (Stephen)
- Properly delete file with mrproper (Guang)
- Fixed support for headers that are not exported (Guang)
- New way to list files used from the generic set (Arnd)
Changes since v3:
- Dropped generic-export.y (from Arnd)
- added check if header is listed as generic but still is present
- fixed "make headers_check"
- updated documentation
I did not include an Reviewed-by / Acked-by from Arnd as
he had not seen the latest iteration in the full.
Diffstat for the patch:
.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
Sample diffstat when using generic-y for three files in x86:
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
Sam
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PATCH 1/2] kbuild: asm-generic support
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-09 19:27 ` Sam Ravnborg
@ 2011-01-09 19:29 ` Sam Ravnborg
2011-01-09 19:29 ` Sam Ravnborg
` (4 more replies)
2011-01-09 19:29 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2 siblings, 5 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
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
* [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
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-09 19:27 ` Sam Ravnborg
2011-01-09 19:29 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
@ 2011-01-09 19:29 ` Sam Ravnborg
2011-01-09 19:29 ` Sam Ravnborg
2 siblings, 1 reply; 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
From e9405a7193563f948d293cfb4b2c0845c1ad54cc Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:29:57 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 6fa90a8..52bf61c 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -23,3 +23,9 @@ header-y += unistd_32.h
header-y += unistd_64.h
header-y += vm86.h
header-y += vsyscall.h
+
+# generic headers from include/asm-generic/
+generic-y += termios.h
+generic-y += termbits.h
+generic-y += rtc.h
+
diff --git a/arch/x86/include/asm/rtc.h b/arch/x86/include/asm/rtc.h
deleted file mode 100644
index f71c3b0..0000000
--- a/arch/x86/include/asm/rtc.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/rtc.h>
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
1.6.0.6
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [EXAMPLE PATCH 2/2] x86: start to utilize kbuild asm-generic support
2011-01-09 19:29 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
@ 2011-01-09 19:29 ` Sam Ravnborg
0 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 e9405a7193563f948d293cfb4b2c0845c1ad54cc Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sun, 9 Jan 2011 09:29:57 +0100
Subject: [PATCH 2/2] x86: start to utilize kbuild asm-generic support
---
arch/x86/include/asm/Kbuild | 6 ++++++
arch/x86/include/asm/rtc.h | 1 -
arch/x86/include/asm/termbits.h | 1 -
arch/x86/include/asm/termios.h | 1 -
4 files changed, 6 insertions(+), 3 deletions(-)
delete mode 100644 arch/x86/include/asm/rtc.h
delete mode 100644 arch/x86/include/asm/termbits.h
delete mode 100644 arch/x86/include/asm/termios.h
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 6fa90a8..52bf61c 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -23,3 +23,9 @@ header-y += unistd_32.h
header-y += unistd_64.h
header-y += vm86.h
header-y += vsyscall.h
+
+# generic headers from include/asm-generic/
+generic-y += termios.h
+generic-y += termbits.h
+generic-y += rtc.h
+
diff --git a/arch/x86/include/asm/rtc.h b/arch/x86/include/asm/rtc.h
deleted file mode 100644
index f71c3b0..0000000
--- a/arch/x86/include/asm/rtc.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/rtc.h>
diff --git a/arch/x86/include/asm/termbits.h b/arch/x86/include/asm/termbits.h
deleted file mode 100644
index 3935b10..0000000
--- a/arch/x86/include/asm/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termbits.h>
diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
deleted file mode 100644
index 280d78a..0000000
--- a/arch/x86/include/asm/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/termios.h>
--
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-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-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
` (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
end of thread, other threads:[~2011-04-28 16:17 UTC | newest]
Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-08 13:03 [RFC] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-08 13:03 ` Sam Ravnborg
2011-01-08 13:04 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-08 13:04 ` Sam Ravnborg
2011-01-08 13:45 ` Stephen Rothwell
2011-01-08 14:03 ` Sam Ravnborg
2011-01-08 14:03 ` Sam Ravnborg
2011-01-08 14:10 ` Guan Xuetao
2011-01-08 14:10 ` Guan Xuetao
2011-01-08 13:05 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2011-01-08 13:05 ` Sam Ravnborg
2011-01-08 20:53 ` [RFC] kbuild: generic support for asm-generic Arnd Bergmann
2011-01-08 21:33 ` Sam Ravnborg
2011-01-08 21:33 ` Sam Ravnborg
2011-01-09 0:15 ` Arnd Bergmann
2011-01-09 8:28 ` [RFC v2] " Sam Ravnborg
2011-01-09 8:28 ` Sam Ravnborg
2011-01-09 8:31 ` [PATCH 1/2] kbuild: asm-generic support Sam Ravnborg
2011-01-09 8:31 ` Sam Ravnborg
2011-01-09 14:03 ` Arnd Bergmann
2011-01-09 15:10 ` Sam Ravnborg
2011-01-09 16:13 ` Arnd Bergmann
2011-01-09 16:13 ` Arnd Bergmann
2011-01-09 8:32 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2011-01-09 8:32 ` Sam Ravnborg
2011-01-09 19:27 ` [RFC v3] kbuild: generic support for asm-generic Sam Ravnborg
2011-01-09 19:27 ` Sam Ravnborg
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-09 21:24 ` Sam Ravnborg
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
2011-01-10 13:31 ` Guan Xuetao
2011-01-10 13:31 ` Guan Xuetao
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
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
2011-04-27 19:42 ` Sam Ravnborg
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
2011-04-27 20:29 ` Sam Ravnborg
2011-04-28 16:16 ` Michal Marek
2011-01-09 19:29 ` [EXAMPLE PATCH 2/2] x86: start to utilize kbuild " Sam Ravnborg
2011-01-09 19:29 ` Sam Ravnborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).