From patchwork Tue Aug 21 15:58:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10836 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9C56023F27 for ; Tue, 21 Aug 2012 15:59:00 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2D9E9A1863E for ; Tue, 21 Aug 2012 15:58:51 +0000 (UTC) Received: by yhpp61 with SMTP id p61so6270661yhp.11 for ; Tue, 21 Aug 2012 08:58:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-provags-id:x-gm-message-state; bh=mlHsrbOqodVD6ya5HXrlzfuxYGX/EdOOtBSiwQVXPbg=; b=JJUKqkxlFz+IFpozmMcj/p17nOAgIs+ec9S7vr/h4NzbFNRwH6uVELDIa9VJyPXmSg l2KwYrd43ygxjQ8plU49qgY8IuNHzwebajNMVXHTQbDDsVfyMVgLPk3hFkz6oDhRKZTV Qem1tF8F/1gSL54iwezPUm/Z0+SrJxe2AeXHmqikl/10h+Hv0zjuK/4AA2ozCx2/7knf 2XE3Yyd7QezQTQ8bc3uikc0SLCruDtjx1tVddPKfhyA1MKAFEazNbheMj2Md5nAxVf56 +7HBCvzA8fXXvlPd3JKP2F8nYhjVX4mMgpFSVs/OsFd+XKpgnvzFjyKzdF0cOSxdygvt bOYg== Received: by 10.50.217.227 with SMTP id pb3mr14119532igc.28.1345564738965; Tue, 21 Aug 2012 08:58:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp154166igc; Tue, 21 Aug 2012 08:58:57 -0700 (PDT) Received: by 10.216.71.195 with SMTP id r45mr8670166wed.21.1345564737040; Tue, 21 Aug 2012 08:58:57 -0700 (PDT) Received: from moutng.kundenserver.de (moutng.kundenserver.de. [212.227.17.10]) by mx.google.com with ESMTP id f24si2427956weo.85.2012.08.21.08.58.56; Tue, 21 Aug 2012 08:58:57 -0700 (PDT) Received-SPF: neutral (google.com: 212.227.17.10 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) client-ip=212.227.17.10; Authentication-Results: mx.google.com; spf=neutral (google.com: 212.227.17.10 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mail=arnd@arndb.de Received: from localhost.localdomain (HSI-KBW-149-172-5-253.hsi13.kabel-badenwuerttemberg.de [149.172.5.253]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0Mdurl-1TK8oK2yEP-00Pe8J; Tue, 21 Aug 2012 17:58:53 +0200 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Arnd Bergmann Subject: [RFC 1/4] ARM: autogenerate mach-foo/* and plat-foo/* header redirects Date: Tue, 21 Aug 2012 17:58:41 +0200 Message-Id: <1345564724-14466-2-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1345564724-14466-1-git-send-email-arnd@arndb.de> References: <1345564724-14466-1-git-send-email-arnd@arndb.de> X-Provags-ID: V02:K0:nAak1O3b+Fj5vbSUqsqJXvk1gvHAlSv2z0T1xWt+6o6 e8FOMA+ABuZEzJCrab+GEs7GgtWMLVEiYVAoKn4i52kD2Gc9kM 1OKtL3gvPdZdx1nRjp72LIrLPJhmO8rVdObS5gHTL5WascbLSo eHyuuROoITL67zYnnnIk5hGJ79hBwSTe83gp3z+70lY/pjRxGR n2iVdPTRydHm5xZ1461OzZi+5Th08SCrKtaNlOBWlC9xTQi2mI 1zuY9JcJSMCgv3VKZ2WcmG//u1cfBSjz0ZynAVP0+I+RTHHb0K PUmeEPbEHZwNZx8Cn59iOpSkWLbTvyGr9EA+s3MuxP0Ed1BK4i /qHKZp0Qg4X+24UPMbiBuayoI87KftrGpkNWgo5LIp00SvhqM2 UBQaYz7bVDqYA== X-Gm-Message-State: ALoCoQlAf1rYWeFj8uUr4863/GQZ++5qvrpr1aHlwDkTyDafHqfwsvr7I0cGOhd9IxoTDUE62j2q 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 --- 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