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: 6045491 Return-Path: X-Original-To: patchwork-linux-kbuild@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 BD030BF90F for ; Thu, 19 Mar 2015 03:38:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB7C8203F4 for ; Thu, 19 Mar 2015 03:38:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2A2A2040F for ; Thu, 19 Mar 2015 03:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751330AbbCSDiV (ORCPT ); Wed, 18 Mar 2015 23:38:21 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:35639 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751303AbbCSDiU (ORCPT ); Wed, 18 Mar 2015 23:38:20 -0400 Received: by pabyw6 with SMTP id yw6so62246637pab.2; 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 Reply-To: frowand.list@gmail.com 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 CC: Ian Campbell , Kumar Gala , Leif Lindholm , Mark Rutland , Pawel Moll , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , linux-kbuild@vger.kernel.org, Linux Kernel list Subject: [patch 5/7] dt: dtb version: kbuild scripts References: <550A42AC.8060104@gmail.com> In-Reply-To: <550A42AC.8060104@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 +++++++++++++++++++++++++++ -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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.