From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] [RFC] ARM: autogenerate mach-foo/* and plat-foo/* header redirects
Date: Wed, 22 Aug 2012 12:54:22 +0000 [thread overview]
Message-ID: <201208221254.22292.arnd@arndb.de> (raw)
In-Reply-To: <201208221253.07278.arnd@arndb.de>
This is an attempt to simplify the duplicate header problem for
multiplatform kernels, in multiple steps:
1. (this patch)
for each arch/arm/mach-${MACHINE}/include/mach-${MACHINE}/*.h file,
generate a arch/arm/include/generated/mach/*.h file at build time,
same for plat-*.
2. rename all arch/arm/mach-${MACHINE}/include/mach/*.h to
arch/arm/mach-${MACHINE}/include/mach-${MACHINE}/*.h and
arch/arm/plat-${PLAT}/include/plat/*.h to
arch/arm/plat-${PLAT}/include/plat-${PLAT}/*.h
3. change all includes of <mach/*.h> to <mach-${MACHINE}/*.h>
in all files where ${MACHINE} is known.
4. ...
5. Revert this patch again.
We can apply this patch at any time, and do step 2 at the end
of the next merge window to minimize the potential for conflicts.
We will also still need to deal with any inclusion of a mach/*
file, but out of the 6355 ones we have today, I expect only a
few hundred to remain after step 3 and they will be much easier
to spot.
I've picked the format <mach-foo/bar.h> to get a unique name because
it matches the directory name under arch/arm, but other names
would work with the same script, <mach/foo-bar.h> and <foo/bar.h>
have been suggested previously.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/Makefile | 1 +
arch/arm/tools/Makefile | 5 ++++
| 57 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100755 arch/arm/tools/gen-headers
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 30eae87..761b077 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -274,6 +274,7 @@ boot := arch/arm/boot
archprepare:
$(Q)$(MAKE) $(build)=arch/arm/tools include/generated/mach-types.h
+ $(Q)$(MAKE) $(build)=arch/arm/tools plat="$(plat-y)" machine="$(machine-y)" gen_headers
# Convert bzImage to zImage
bzImage: zImage
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 635cb18..6e18ca9 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -8,3 +8,8 @@ include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
@echo ' Generating $@'
@mkdir -p $(dir $@)
$(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
+
+gen_headers:
+ $(Q)bash $(srctree)/$(src)/gen-headers $(srctree) $(objtree) $(machine) $(plat)
+
+.PHONY: gen_headers
--git a/arch/arm/tools/gen-headers b/arch/arm/tools/gen-headers
new file mode 100755
index 0000000..caa6a9a
--- /dev/null
+++ b/arch/arm/tools/gen-headers
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+SRC=$1
+OBJ=$2
+MACH=$3
+PLAT1=$4
+PLAT2=$5
+
+# create $3 to include $2 if it doesn't already have the correct
+# contents, or remove it if it's no longer needed.
+mkfile()
+{
+ if [ -e $1/$2 ] ; then
+ if [ ! -e $3 ] ; then
+ mkdir -p ${3%/*}
+ echo "#include <${2}>" > $3
+ elif [ "`cat $3`" != "#include <${2#./}>" ] ; then
+ echo "#include <${2}>" > $3
+ fi
+ elif [ ! -e $1/$2 -a -e $3 ] ; then
+ rm -f $3
+ fi
+}
+
+# list any header files that are present in the source or
+# destination directories
+find_files()
+{
+ pushd ${SRC}/arch/arm/$1-$2/include/$1-$2 >/dev/null 2>&1 &&
+ find . -type f -name \*.h -o -name \*.S &&
+ popd > /dev/null 2>&1
+ pushd ${OBJ}/arch/arm/include/generated/$1 >/dev/null 2>&1 &&
+ find . -type f -name \*.h -o -name \*.S &&
+ popd > /dev/null 2>&1
+}
+
+# process files in either mach-{MACH} or plat-${PLAT}
+mkfiles()
+{
+ mkdir -p ${OBJ}/arch/arm/include/generated/$1
+
+ FILES=`find_files $1 $2 | sort -u`
+ for i in ${FILES} ; do
+ mkfile "${SRC}/arch/arm/$1-$2/include/" "$1-$2/${i#./}" \
+ "${OBJ}/arch/arm/include/generated/$1/$i"
+ done
+}
+
+# always process mach-*
+mkfiles mach ${MACH}
+# process plat-* if applicable
+if [ -d ${SRC}/arch/arm/plat-${PLAT1} ]; then
+ mkfiles plat ${PLAT1}
+fi
+if [ -d ${SRC}/arch/arm/plat-${PLAT2} ]; then
+ mkfiles plat ${PLAT2}
+fi
--
1.7.10
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org
Subject: [PATCH 1/4] [RFC] ARM: autogenerate mach-foo/* and plat-foo/* header redirects
Date: Wed, 22 Aug 2012 12:54:22 +0000 [thread overview]
Message-ID: <201208221254.22292.arnd@arndb.de> (raw)
In-Reply-To: <201208221253.07278.arnd@arndb.de>
This is an attempt to simplify the duplicate header problem for
multiplatform kernels, in multiple steps:
1. (this patch)
for each arch/arm/mach-${MACHINE}/include/mach-${MACHINE}/*.h file,
generate a arch/arm/include/generated/mach/*.h file at build time,
same for plat-*.
2. rename all arch/arm/mach-${MACHINE}/include/mach/*.h to
arch/arm/mach-${MACHINE}/include/mach-${MACHINE}/*.h and
arch/arm/plat-${PLAT}/include/plat/*.h to
arch/arm/plat-${PLAT}/include/plat-${PLAT}/*.h
3. change all includes of <mach/*.h> to <mach-${MACHINE}/*.h>
in all files where ${MACHINE} is known.
4. ...
5. Revert this patch again.
We can apply this patch at any time, and do step 2 at the end
of the next merge window to minimize the potential for conflicts.
We will also still need to deal with any inclusion of a mach/*
file, but out of the 6355 ones we have today, I expect only a
few hundred to remain after step 3 and they will be much easier
to spot.
I've picked the format <mach-foo/bar.h> to get a unique name because
it matches the directory name under arch/arm, but other names
would work with the same script, <mach/foo-bar.h> and <foo/bar.h>
have been suggested previously.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/Makefile | 1 +
arch/arm/tools/Makefile | 5 ++++
| 57 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100755 arch/arm/tools/gen-headers
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 30eae87..761b077 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -274,6 +274,7 @@ boot := arch/arm/boot
archprepare:
$(Q)$(MAKE) $(build)=arch/arm/tools include/generated/mach-types.h
+ $(Q)$(MAKE) $(build)=arch/arm/tools plat="$(plat-y)" machine="$(machine-y)" gen_headers
# Convert bzImage to zImage
bzImage: zImage
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 635cb18..6e18ca9 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -8,3 +8,8 @@ include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
@echo ' Generating $@'
@mkdir -p $(dir $@)
$(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
+
+gen_headers:
+ $(Q)bash $(srctree)/$(src)/gen-headers $(srctree) $(objtree) $(machine) $(plat)
+
+.PHONY: gen_headers
--git a/arch/arm/tools/gen-headers b/arch/arm/tools/gen-headers
new file mode 100755
index 0000000..caa6a9a
--- /dev/null
+++ b/arch/arm/tools/gen-headers
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+SRC=$1
+OBJ=$2
+MACH=$3
+PLAT1=$4
+PLAT2=$5
+
+# create $3 to include $2 if it doesn't already have the correct
+# contents, or remove it if it's no longer needed.
+mkfile()
+{
+ if [ -e $1/$2 ] ; then
+ if [ ! -e $3 ] ; then
+ mkdir -p ${3%/*}
+ echo "#include <${2}>" > $3
+ elif [ "`cat $3`" != "#include <${2#./}>" ] ; then
+ echo "#include <${2}>" > $3
+ fi
+ elif [ ! -e $1/$2 -a -e $3 ] ; then
+ rm -f $3
+ fi
+}
+
+# list any header files that are present in the source or
+# destination directories
+find_files()
+{
+ pushd ${SRC}/arch/arm/$1-$2/include/$1-$2 >/dev/null 2>&1 &&
+ find . -type f -name \*.h -o -name \*.S &&
+ popd > /dev/null 2>&1
+ pushd ${OBJ}/arch/arm/include/generated/$1 >/dev/null 2>&1 &&
+ find . -type f -name \*.h -o -name \*.S &&
+ popd > /dev/null 2>&1
+}
+
+# process files in either mach-{MACH} or plat-${PLAT}
+mkfiles()
+{
+ mkdir -p ${OBJ}/arch/arm/include/generated/$1
+
+ FILES=`find_files $1 $2 | sort -u`
+ for i in ${FILES} ; do
+ mkfile "${SRC}/arch/arm/$1-$2/include/" "$1-$2/${i#./}" \
+ "${OBJ}/arch/arm/include/generated/$1/$i"
+ done
+}
+
+# always process mach-*
+mkfiles mach ${MACH}
+# process plat-* if applicable
+if [ -d ${SRC}/arch/arm/plat-${PLAT1} ]; then
+ mkfiles plat ${PLAT1}
+fi
+if [ -d ${SRC}/arch/arm/plat-${PLAT2} ]; then
+ mkfiles plat ${PLAT2}
+fi
--
1.7.10
next prev parent reply other threads:[~2012-08-22 12:54 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-22 12:53 [PATCH 0/4] [RFC] ARM: multiplatform: rename all mach headers Arnd Bergmann
2012-08-22 12:53 ` Arnd Bergmann
2012-08-22 12:54 ` Arnd Bergmann [this message]
2012-08-22 12:54 ` [PATCH 1/4] [RFC] ARM: autogenerate mach-foo/* and plat-foo/* header redirects Arnd Bergmann
2012-08-22 15:24 ` Nicolas Pitre
2012-08-22 15:24 ` Nicolas Pitre
2012-08-24 13:44 ` Rob Herring
2012-08-24 13:44 ` Rob Herring
2012-08-22 12:56 ` [PATCH 2/4] [RFC] ARM: mass move of mach-*/plat-* header files Arnd Bergmann
2012-08-22 12:56 ` Arnd Bergmann
2012-08-22 15:28 ` Nicolas Pitre
2012-08-22 15:28 ` Nicolas Pitre
2012-08-22 15:37 ` Arnd Bergmann
2012-08-22 15:37 ` Arnd Bergmann
2012-08-22 13:00 ` [PATCH 3/4] [RFC] ARM: multiplatform: rename all mach headers Arnd Bergmann
2012-08-22 13:00 ` Arnd Bergmann
2012-08-22 15:31 ` Nicolas Pitre
2012-08-22 15:31 ` Nicolas Pitre
2012-08-22 13:01 ` [PATCH 4/4] [RFC] ARM: treewide: manually change more mach-*/*.h includes Arnd Bergmann
2012-08-22 13:01 ` Arnd Bergmann
2012-08-22 15:33 ` Nicolas Pitre
2012-08-22 15:33 ` Nicolas Pitre
2012-08-22 21:43 ` Russell King - ARM Linux
2012-08-22 21:43 ` Russell King - ARM Linux
2012-08-23 11:35 ` Arnd Bergmann
2012-08-23 11:35 ` Arnd Bergmann
2012-08-23 12:37 ` Nicolas Ferre
2012-08-23 12:37 ` Nicolas Ferre
2012-08-23 13:31 ` Arnd Bergmann
2012-08-23 13:31 ` Arnd Bergmann
2012-08-23 17:26 ` Arnd Bergmann
2012-08-23 17:26 ` Arnd Bergmann
2012-08-24 20:36 ` Tony Lindgren
2012-08-24 20:36 ` Tony Lindgren
2012-08-30 19:04 ` Tony Lindgren
2012-08-30 19:04 ` Tony Lindgren
2012-09-05 0:36 ` Tony Lindgren
2012-09-05 0:36 ` Tony Lindgren
2012-08-24 20:47 ` Russell King - ARM Linux
2012-08-24 20:47 ` Russell King - ARM Linux
2012-08-24 20:52 ` Russell King - ARM Linux
2012-08-24 20:52 ` Russell King - ARM Linux
2012-08-27 22:16 ` Haojian Zhuang
2012-08-27 22:16 ` Haojian Zhuang
2012-08-22 15:23 ` [PATCH 0/4] [RFC] ARM: multiplatform: rename all mach headers Nicolas Pitre
2012-08-22 15:23 ` Nicolas Pitre
2012-08-22 15:31 ` Arnd Bergmann
2012-08-22 15:31 ` Arnd Bergmann
2012-08-22 19:44 ` Stephen Warren
2012-08-22 19:44 ` Stephen Warren
2012-08-22 20:04 ` Arnd Bergmann
2012-08-22 20:04 ` Arnd Bergmann
2012-08-24 13:19 ` Shawn Guo
2012-08-24 13:19 ` Shawn Guo
2012-08-24 13:55 ` Rob Herring
2012-08-24 13:55 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201208221254.22292.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.