From patchwork Fri Oct 13 09:12:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115714 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp499281qgn; Fri, 13 Oct 2017 02:13:19 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDh/ELuYV9GYEkwn/KJkGfm4Foilu2zyWcgk2jzi09wxTPGQJiOWgCOcHpMa3AsGaC0Gk/9 X-Received: by 10.80.136.124 with SMTP id c57mr1297367edc.59.1507885999578; Fri, 13 Oct 2017 02:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507885999; cv=none; d=google.com; s=arc-20160816; b=BVVFXxkfn88i7YBMfOZFyWOLKnZpFTIFwzWJPoJHMuBEyhJZhdLSygW053x3sHOh8K mNIhRtZLAyiue72b2DzskNRKQB5m+nn0mp2KdVaja55BXQJpLtPDT/ECRNMIfDhnb43C CcNs52/gLcyPQZN2VjMxkn8zik4cA66hRXhVjs7Qk0hEljU77cjFDYQkXscE2yYtaBXb U+u0eHgN8QqHnBxzjx/91mXLS1dyhf+h9ZfHaPHl+GISvLX56gjfcR8fVclVXg5K1M41 8DASak2qfFKFK+NdTyjRu69KnAlGcIt5qM8bJISbYC2RrmcgjUcoNUUmHTsfteEl2C/p 6ftg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=DcE6oFwNAKjrvFT1Rkz2R5zK81c9lWU1oo3kTB9MNwk=; b=DVMuc5eCzBaDnnptdXUCAVPB3pWqMBSz1nio8tO2kMxDnsBSWiZub+uVl42hnx/YXZ 83ApQt8fDfLVL4UoxB+ltHrZjYMTVLZ0LPC2VGJkokl2dO4Df6EkyHUNc4xQ0qb3AZdV hxaTYrMr+wNbhXl52/JLlVRIIy7IEKVyQ/YYTbEGtzZm1TYVhc9mM5IEndoBg3KDJ4+9 ybZSFFpSExN1KLpSg5M0PR/Rr+raUOyhvQYgKMYkHfKW+qY8Zq4SjR7Te65jWgu8ZaVb CB3G4KZvQpfvp4zPzhuuiAntH7UjL6Uep/Qpd4d2uktDdW/kdIb5sr0kM/zSquAYtlkt OuNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Dt/aCZ07; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id a88si681265ede.388.2017.10.13.02.13.19; Fri, 13 Oct 2017 02:13:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Dt/aCZ07; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 1EC16C21FF6; Fri, 13 Oct 2017 09:13:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BF7ADC21EEE; Fri, 13 Oct 2017 09:13:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3C130C21F01; Fri, 13 Oct 2017 09:13:10 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id 16615C21C59 for ; Fri, 13 Oct 2017 09:13:07 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v9D9CiH2002457; Fri, 13 Oct 2017 18:12:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v9D9CiH2002457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507885966; bh=YN0+n0PHHlCD1HOB/o9lA4A5be3QS3Zq7GkyQ5AiCK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dt/aCZ07Vr16ZotgnJzGK/nz2txRwOlozNfCrCGrmrYNSyFbZLahpe8wPRtxOBlac 89kMeVkwwPgJjHZE46SlSeCtmwX5luhw/1byC8wDEzwPUafSS+wb4cZI7I0OYocORI HcpvcA1RJcqVHwJuW9q7hObBIxEkV8hCW6Si/lgoQoJDwG7rmU75OCumKfU3gqSx/I jH5Ywr/AyfjatdSOYnfueS8kuAbKxlPgoVKtV9Q/43T1WjCGSeshYgDfwLW986189p Z/w1V5eqlMfYKlchEU+n6/Cf4Yala+KvOJT/tQJe89chjoi4g7ha1JCllSkvw0kxlD Zi1mmweeua5Ug== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:12:39 +0900 Message-Id: <1507885961-12665-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> References: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini , Michal Marek Subject: [U-Boot] [PATCH 1/3] kbuild: Get rid of KBUILD_STR X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Michal Marek The compiler can accept -DKBUILD_MODNAME="foo", it's just a matter of quoting. That way, we reduce the gcc command line a bit. Signed-off-by: Michal Marek Signed-off-by: Masahiro Yamada [ Linux commit: b42841b7bb6286da56b4fa79835c27166b7e228b ] --- scripts/Makefile.lib | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0d5c529..8934b2f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -99,10 +99,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: Files that end up in two or more modules are compiled without the # KBUILD_MODNAME definition. The reason is that any made-up name would # differ in different configs. -name-fix = $(subst $(comma),_,$(subst -,_,$1)) -basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = $(if $(filter 1,$(words $(modname))),\ - -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + -DKBUILD_MODNAME=$(call name-fix,$(modname))) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) @@ -154,7 +154,7 @@ endif # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__c_flags) $(modkern_cflags) \ - -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__a_flags) $(modkern_aflags) From patchwork Fri Oct 13 09:12:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115716 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp500311qgn; Fri, 13 Oct 2017 02:14:35 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDw4TNPJglFYn7eLRngPSy+kMCNXxUfS9valklE+cNt9vkVfZGnpeM+V/X99zwOdzrQDZa7 X-Received: by 10.80.177.178 with SMTP id m47mr1333796edd.181.1507886075661; Fri, 13 Oct 2017 02:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507886075; cv=none; d=google.com; s=arc-20160816; b=nFMqPqHk77dkCXWWj11tbPCAtgY27MnobhSh933ykmjCMk0lWNB4FyoWmjDb9LhJoY ajhwQqGxWBNynik1WHQcZd4O69KljGodRQEnRxwyA1/BBi4f8nfPWgMeea+aYzSYMT5a MzFsuLEMypqg/H5haikXgBzUNRsqlJI+lX9IArB7OawGvBXNjBhfnuTP8bzZOXPiVwiN agvWha7bCNAWZGH80OIhnFE/49g8xj5ThTBeOI1E6Cu8udKoTLcbeG1R/+JJZU8MxjlM l0/moSCjUM1lgmO7UIwT3t7lg5vOnsy1hgP6oILxVc0813msVpkYxD3vAbAK9XQCD5Nm 77Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=qASIkShc8vnzZjT6CnTDpqAoIG7b6603KUZeteqL5lE=; b=QjGz4814UvmtPrt2IjIhngFaMKGIYaJgtFxNUbH4CqTcMtzcKVEh5evlyy60FVEngy sHQK40k55r60xPkaO1zxqHERrz7Pd9dteqHq9oMjn2vTY/aHlNkgioINHMqtEg3TNeGg +3o88fV6ZGMSp0c1C1u3MLUFLFZar6GsOSC7oisnPJOtY0LA5rET/d2FFvPM3Esmilxs N6Zar4Wo3bUqhbGViQgeK0XnXkxpgBR6ykwKJcepjU6HTr/z0hECtl/CBnug/rfpID8r zOrLQbiFsVmEGYH8gnRZz98qjLLH0nHN7mlr6/aZ59RMenzHmlvM/8p6OhO1edWP6l+k ZV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Yj5IGjCc; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id y13si656275edd.111.2017.10.13.02.14.35; Fri, 13 Oct 2017 02:14:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Yj5IGjCc; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 20C9DC21FE8; Fri, 13 Oct 2017 09:13:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7C85AC21F4E; Fri, 13 Oct 2017 09:13:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4D909C21C59; Fri, 13 Oct 2017 09:13:10 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id 1995FC21EEE for ; Fri, 13 Oct 2017 09:13:07 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v9D9CiH3002457; Fri, 13 Oct 2017 18:12:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v9D9CiH3002457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507885966; bh=wHoZcESuUVAqGlWpP+8yZchOx9406IMXanxy9qbAzJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yj5IGjCcHCjSkjoTqeuTaUlbFDtU75ksOJsE9pRTkHI+6b6x7Adb5zDm4UtlfZzmU 0db4OQG/gKOC7GUcl4eisg+Myo9VRtub/zlhvMdBfekW8+5MLlsQgbEziVgW1E/KIm kCi0jVdC5iK4BzZFHpS9ZUkRN0P56ZpjGkNlNhVgf+toSNKpl56maim0pb7bbLc+tb wcDNI7vV091Pro7DyxR08u1Czno1h/8PhDYGhV9UyXJ3tAaO8JypS5LxaQ9XrH7L3H kxrcba+RbSnw18282Fx5K+x7CbyvEYQdiEdFAJguSfClzem6NTELHO+fB5Kurq/4Jg cKfOzAweY/0Qg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:12:40 +0900 Message-Id: <1507885961-12665-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> References: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH 2/3] kbuild: add stringify helper to quote a string passed to C files X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" I want to reuse $(squote)$(quote)...$(quote)$(squote) in the next commit. Move it to a helper. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 4 ++++ scripts/Makefile.lib | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 2c7918a..48a641c 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -30,6 +30,10 @@ baseprereq = $(basename $(notdir $<)) escsq = $(subst $(squote),'\$(squote)',$1) ### +# Quote a string to pass it to C files. foo => '"foo"' +stringify = $(squote)$(quote)$1$(quote)$(squote) + +### # Easy method for doing a status message kecho := : quiet_kecho := echo diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 8934b2f..bd0977e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -99,7 +99,7 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: Files that end up in two or more modules are compiled without the # KBUILD_MODNAME definition. The reason is that any made-up name would # differ in different configs. -name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = $(if $(filter 1,$(words $(modname))),\ -DKBUILD_MODNAME=$(call name-fix,$(modname))) From patchwork Fri Oct 13 09:12:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115715 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp499912qgn; Fri, 13 Oct 2017 02:14:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDdiLDfCvAGBmXGtjLJlHj62yT296NIeeju3j7F81iNS6ISiKlY/WaDp8k0UoT2DOWdYs2j X-Received: by 10.80.153.205 with SMTP id n13mr1336131edb.281.1507886044752; Fri, 13 Oct 2017 02:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507886044; cv=none; d=google.com; s=arc-20160816; b=aD4Chl/A+4P6xbh+FGVH5rItbWE3xBd1RmY2bcbkaW7VO7vbWtM9920nE+rD6A8hij RCzR5EOX/IntwXM9A+YhC7m/pcBtMU1WMidUG7PUB9c6JxJcvq/8zW3lLQzgmHbH7+Ik mfRmbmTsQT5Z5dZq4aabSrQoCp16qmYYOI13LR6CVGyD17oq3oXoWupNFmNwjlcBBIjX gqr8HEiIdMqCn8NmdAXO87AJV2MEWJIwEl2cEWhcw2nMtr68PmN7pk08FUO8aNvjMrAv SzaPnytpE+6Xr+vUrTiDSGjJq4LQ8NmwpJXygbYb+nq0QKsvrtH0wYzqKp20bWT/VgTC FBHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=9drrZY1IRF+9P/fTmYO4H3LUInXweyWUcPteIESXGyM=; b=To/OHdrfblVIKQ4INRkwvY19+YxodVsB8r3W3ZH+1PQjAaqfBO/6FwVhPd0NPuiCWk J3On/LrnlGPnN2yMegVrislwon5k2t2YwDjYBf5vdpI2TEHHrnX/waz+9vYY+sPc4ZBg G68oaudwp2UKqFb4XR2XJbLpALqQCOqTVukIgT7z4HVYdc/BCQ66phz94xzN9e/moH0R elIzlUvQm+NjkHq2iIn6SkzYUlSwUgtF8TUl9ETN0VagKyRFI54QiOrfM+l6aNsHdJBf Tjp/teL7stKSpNJskZwuC9g8gbhYgZ9OMOMD6n7RjkshEhFX5jeUcBTLF1Qs2RDDcZrp kvgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lcNK7QIC; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id j2si706012edj.200.2017.10.13.02.14.04; Fri, 13 Oct 2017 02:14:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lcNK7QIC; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 2F527C21F6B; Fri, 13 Oct 2017 09:13:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 68614C21FA8; Fri, 13 Oct 2017 09:13:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 72482C21EEE; Fri, 13 Oct 2017 09:13:10 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id 3FC61C21EF8 for ; Fri, 13 Oct 2017 09:13:07 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v9D9CiH4002457; Fri, 13 Oct 2017 18:12:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v9D9CiH4002457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507885967; bh=sNZysxVvpOJcpW41VyJbAvUEb7Dpi80dnXcC1vZw1AA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcNK7QICQSkY5lLOmZVXsqd3hSGDNN5MqSMHtYPnqXwK5NZPE47Nl+o6sVjB78pzR OOrc86FisHnObD5w/Oy1cp3xIxnea5NYUpI1NyK3euNU4u5Gs/N2uOId63Au/EmzA4 GDU2FviMQOgI5JcyFbLLIrELEW6QfvafxJjUJBeREjJI1QQpF5YTgTXU+ReRo10DUU ZQcs4ZPzwNo8BSn54yIlcZx3Px6eo8YcMfQZtim/te7eh3al1wFabXhRhsvWf0wdgK Lzt6gTwexm1zRoyOH1tpnoL0KDrXX2MxJR7MqNTRLf8K1VWfZ0wCN8g0p0iDAJMNpi KfxVQ4YpUmbQg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:12:41 +0900 Message-Id: <1507885961-12665-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> References: <1507885961-12665-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH 3/3] kbuild: redefine __FILE__ as relative path from $(srctree) if possible X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since Kbuild runs in the objtree, __FILE__ can be a very long path depending of $(srctree). If objtree is a child of srctree, the situation is a bit better. ($(srctree) is "..") For other cases of out-of-tree build, filenames in WARN_ON() etc. are still an absolute path. It also means the U-Boot image depends on where it was built. Here, the idea is to redefine __FILE__ as the relative path from $(srctree), but doing so causes a compiler warning: warning: "__FILE__" redefined [-Wbuiltin-macro-redefined] The option -Wno-builtin-macro-redefined can suppress it, but it is only recognized by GCC 4.4 or newer. Redefine __FILE__ only when possible. Signed-off-by: Masahiro Yamada --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 888486b..ab7775d 100644 --- a/Makefile +++ b/Makefile @@ -1334,6 +1334,15 @@ prepare0: archprepare FORCE # All the preparing.. prepare: prepare0 +# If possible, redefne __FILE__ as relative path from $(srctree). +# $$ is needed to expand the following in submake +ifeq ($(call cc-option-yn,-Wno-builtin-macro-redefined),y) +KBUILD_CFLAGS += -Wno-builtin-macro-redefined \ + -D__FILE__=$$(call stringify,$$(src)/$$(notdir $$<)) +endif +# CAUTION: Do not add any reference to KBUILD_CFLAGS below this line. +# Any call of cc-option, etc. will fail. + # Generate some files # ---------------------------------------------------------------------------