From patchwork Thu Mar 19 03:38:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 6045551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DED3EBF90F for ; Thu, 19 Mar 2015 03:41:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00114204D5 for ; Thu, 19 Mar 2015 03:41:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1465B204D1 for ; Thu, 19 Mar 2015 03:41:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYRIH-0006lJ-Ez; Thu, 19 Mar 2015 03:38:49 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYRIA-0006aC-2p for linux-arm-kernel@lists.infradead.org; Thu, 19 Mar 2015 03:38:43 +0000 Received: by pabyw6 with SMTP id yw6so62246640pab.2 for ; Wed, 18 Mar 2015 20:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=8Dbi7VqPU7E/rWPkwPWOCae3PgsBcyDHQgWpc2+HU6o=; b=g+qX9Rid8otjpFGnHUQiNQnMZ43dK5cwy22BGety7EympQDZhzgDTQwvGdylTe2KLF Ix55LCvbQUcGfiBDjsc0sAuA2yk4USZHUV7euEmeEItcUoFWD5tmh2FmyS1KLu2XBqh7 oMU7kO+Ix4nkk5uuCS6XZtyimEIORjly4KPnxN6XmORaBmZVUbR7MHxKLiG/naXbLeYL fIFcApcXtOE2AVi40k3RfA4tTWUclM1CtsVk3XdtkQiO3vgwc6uZHKqk0jFfnoaAA7Fp 7PAihm1vYJITADLQgtJs8hX1aNEAJsUUoyKAeMLrn8nn9xia+AgagMukJj2n7dyiUCc/ OSLQ== X-Received: by 10.70.15.161 with SMTP id y1mr66459211pdc.9.1426736300240; Wed, 18 Mar 2015 20:38:20 -0700 (PDT) Received: from [172.26.79.213] ([64.211.224.253]) by mx.google.com with ESMTPSA id e4sm94103pdm.70.2015.03.18.20.38.17 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Mar 2015 20:38:19 -0700 (PDT) Message-ID: <550A44A8.9090302@gmail.com> Date: Wed, 18 Mar 2015 20:38:16 -0700 From: Frank Rowand User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: frowand.list@gmail.com, Rob Herring , Grant Likely , Russell King , Michal Marek Subject: [patch 5/7] dt: dtb version: kbuild scripts References: <550A42AC.8060104@gmail.com> In-Reply-To: <550A42AC.8060104@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150318_203842_261387_AB771715 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -0.8 (/) Cc: Mark Rutland , "devicetree@vger.kernel.org" , Pawel Moll , Ian Campbell , linux-kbuild@vger.kernel.org, Linux Kernel list , Leif Lindholm , Kumar Gala , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: frowand.list@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Frank Rowand After applying this patch, need to add execute permission to the new file scripts/version_dtb_increment_once Modify the dtb compile rules to generate dtb version header files. Create script to increment .version_dtb just once per make of one of more dtbs, and to generate the dtb version header files. Signed-off-by: Frank Rowand --- scripts/Makefile.lib | 20 ++++-- scripts/version_dtb_increment_once | 90 +++++++++++++++++++++++++++ Index: b/scripts/Makefile.lib =================================================================== --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -159,11 +159,19 @@ cpp_flags = -Wp,-MD,$(depfile) $(NO ld_flags = $(LDFLAGS) $(ldflags-y) +# Do not want to pull kernel header files into .dtb, so minimize the risk of +# that by adding include/generated/ to include path instead of include/ +# Headers in include/generated/ are used by include/dt-bindings/version.dtsi dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(SRCARCH)/boot/dts \ -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ -I$(srctree)/drivers/of/testcase-data \ - -undef -D__DTS__ + -Iinclude/generated \ + -undef -D__DTS__ \ + -D___DTB_DTB_PATH="\"$@\"" \ + -D___DTB_DTS_PATH="\"$<\"" \ + -D"___DTB_DTC_VERSION=\"$(shell scripts/dtc/dtc -v | cut -d" " -f2-)\"" + # Finds the multi-part object the current object will be linked into modname-multi = $(sort $(foreach m,$(multi-used),\ @@ -282,10 +290,12 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb) quiet_cmd_dtc = DTC $@ -cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ - $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ - -i $(dir $<) $(DTC_FLAGS) \ - -d $(depfile).dtc.tmp $(dtc-tmp) ; \ +cmd_dtc = \ + $(srctree)/scripts/version_dtb_increment_once ; \ + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ + -i $(dir $<) $(DTC_FLAGS) \ + -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) $(obj)/%.dtb: $(src)/%.dts FORCE Index: b/scripts/version_dtb_increment_once =================================================================== --- /dev/null +++ b/scripts/version_dtb_increment_once @@ -0,0 +1,90 @@ +#!/bin/sh + +# increment .version_dtb at most once per build + +# VERSION_DTB_BASE is exported instead of passed to this script as an arg. +# +# If the value is passed as an arg then the make dependency triggers on +# every build of a .dtb because if_changed_dep detects that cmd_dtc has +# changed since the previous build (see scripts/Makefile.lib). + +# Nice output in kbuild format +# Will be supressed by "make -s" +info() +{ + if [ "${quiet}" != "silent_" ]; then + printf " %-7s %s\n" ${1} ${2} + fi +} + + +# flock(1) to avoid race in parallel build +(flock 9 + + if [ ! -r .version_dtb -o ! -s .version_dtb ] ; then + rm -f .version_dtb + touch .version_dtb + fi + + VERSION_DTB=`cat .version_dtb` + if [ "${VERSION_DTB}" != "${VERSION_DTB_BASE}" ] ; then + exit + fi + + info GEN .version_dtb + + VERSION_DTB=`expr 0${VERSION_DTB} + 1` + echo ${VERSION_DTB} > .version_dtb + + # Do not expand names + set -f + + # Fix the language to get consistent output + LC_ALL=C + export LC_ALL + + if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then + TIMESTAMP=`date` + else + TIMESTAMP=$KBUILD_BUILD_TIMESTAMP + fi + if test -z "$KBUILD_BUILD_USER"; then + COMPILE_BY=$(whoami | sed 's/\\/\\\\/') + else + COMPILE_BY=$KBUILD_BUILD_USER + fi + if test -z "$KBUILD_BUILD_HOST"; then + COMPILE_HOST=`hostname` + else + COMPILE_HOST=$KBUILD_BUILD_HOST + fi + + DTB_COMPILER=`scripts/dtc/dtc -v | cut -d" " -f2-` + + VERSION="UTS_RELEASE (${COMPILE_BY}@${COMPILE_HOST}) (${DTB_COMPILER}) #${VERSION_DTB} ${TIMESTAMP}" + + # truncate to get same result as scripts/mkcompile_h + UTS_LEN=64 + TRUNCATE="cut -b -$UTS_LEN" + + + # Generate compile_dtb.h + TARGET=include/generated/compile_dtb.h + info UPD $TARGET + + ( echo /\* This file is auto generated, version ${VERSION_DTB} \*/ + + echo -n \#define DTB_VERSION \"\( + echo -n `echo ${COMPILE_BY} | $TRUNCATE` + echo -n @ + echo -n `echo ${COMPILE_HOST} | $TRUNCATE` + echo -n \) \(${DTB_COMPILER}\) \#${VERSION_DTB} ${TIMESTAMP} + echo \" + + ) > $TARGET + + +) 9> .version_dtb_flock + +# Do not place anything here. Exit from inside flock(1) will come here +# instead of exiting script.