From patchwork Wed Aug 22 12:54:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 1361231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id D63DCDF280 for ; Wed, 22 Aug 2012 13:07:07 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T4Aa9-00028Q-UM; Wed, 22 Aug 2012 13:02:50 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T4AZN-0001yE-7A for linux-arm-kernel@lists.infradead.org; Wed, 22 Aug 2012 13:02:07 +0000 Received: from klappe2.localnet (HSI-KBW-149-172-5-253.hsi13.kabel-badenwuerttemberg.de [149.172.5.253]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MYcDK-1T94Ni0puM-00VTOR; Wed, 22 Aug 2012 15:01:56 +0200 From: 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 User-Agent: KMail/1.12.2 (Linux/3.5.0; KDE/4.3.2; x86_64; ; ) References: <201208221253.07278.arnd@arndb.de> In-Reply-To: <201208221253.07278.arnd@arndb.de> MIME-Version: 1.0 Message-Id: <201208221254.22292.arnd@arndb.de> X-Provags-ID: V02:K0:byxa+A5pKr+xytSiuQpKCTQ53ZcuyyNM0obb3Lc1mmE 8t4k5qIdVPTBJ0YiRV4Zjpm2DRq7DiJxGgd0kWyW6ObICJtfgT 8W2MTspeu0m0OsGj6T90GCiagbHy1Pf2kMWPv7xvy698JSTQyz c3Gj5Lupk76vNSs6BldAy1VUGa8hw9zMlXsaZir63yJp13EYI6 KYkfffGBG8QW6lS1aw6m8vPpaBXFcMsIZAbpSM6m3JhtWEY+3c nF1IHKC3vWwhA+XaVLGH/uxw8E6C1piYxBBJm4IFvg8WbKwtcW 23CSltq6V3hLIir2/MMDM7xnr4haCREjKGYvWNG9gmvnAGF2IS drSkZaep3KeA1OS9FGK8= X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.8 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 to 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 to get a unique name because it matches the directory name under arch/arm, but other names would work with the same script, and have been suggested previously. Signed-off-by: Arnd Bergmann Acked-by: Nicolas Pitre --- arch/arm/Makefile | 1 + arch/arm/tools/Makefile | 5 ++++ arch/arm/tools/gen-headers | 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 diff --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