From patchwork Fri Oct 13 09:51:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115724 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp531047qgn; Fri, 13 Oct 2017 02:54:08 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBilqPaxNZMpZ81+11+k2Awn2d39Z3nlbRmLjiSHb7SjcOQweWfh/w03ElkJfaAhUPLakIa X-Received: by 10.80.205.136 with SMTP id p8mr1422814edi.255.1507888448671; Fri, 13 Oct 2017 02:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507888448; cv=none; d=google.com; s=arc-20160816; b=Lv1luax7G1WdeKb2bRJDIInjHDIVyrcedakF817tVZNQH+zfKNH5yVctqqtWhoUmu9 d9YCgPsH7yBv5WnFoDRmO6TtfDFbvVEfJEl20Nz8MaC7fVeKlPLUtv+79vgGQVn3h5K1 6aj9z9TOiRMDuoEzM/2B4hdzgLH5XeBtIXmkzLnAOTaC66JDanyWdCEvUKKrF9H08TCE pnXV06ouLqn3tIvg0vyQUq1by+nbMGVEtsijL5Eot902yyQQECTxIZrzsSt4qcUiaV2t RchuaOwQUURPtEmOv9tAwMJhoLPDtaAP8U/Tdy91i//fOjky/bXhPN73p1v9PzjfMLNf eqGA== 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=lY37Jj/eT7glhCJwoGnCdO73CiKVRxY9usF+X1Q0iNQ=; b=AiSAXraJKenDZBXwURYXqG22/cFPxUkQDKE1fLDh0Ladh4tLQ9YMDPNGQ4hy/Gk1/f +PIFpr4lHh00GjoeTHxWPhGHet0DWbDBFeLkh3fEq9/PBF9kMxswv5387BpHeQrilfQP ndSotl7hxix68bgEZQBC4q+J/o+eIV4kXFol3Sb7wP1j8JOi3ym5kiGt1DXja9AJdkYw 5HNRVGliyAgIYgcpuXehSLVvQBS99LxgE3Zu0x+5iuH3S2vh81xXptgDIU4u69bFKGOY 4R51rOlSO/aBhf5GD3wl4nM0inZQaSQqbECh7zVWOQ9EYiAtsS2rIphuSLpokk25LCZ2 KClQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=DKhdibdi; 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 q5si707798edj.502.2017.10.13.02.54.08; Fri, 13 Oct 2017 02:54:08 -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=DKhdibdi; 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 4BF2BC21F32; Fri, 13 Oct 2017 09:53:27 +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 16B98C21F32; Fri, 13 Oct 2017 09:52:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E612AC21EEE; Fri, 13 Oct 2017 09:52:14 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id BDB7DC21D82 for ; Fri, 13 Oct 2017 09:52:13 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9D9plP4031812; Fri, 13 Oct 2017 18:51:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9D9plP4031812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507888309; bh=zLHPIUBVf5D46P+KrHugh1yjIGE4p2ellQQdnway5ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKhdibdi0/u9rGuvkV1sLah9S/F7YCt3FGOHniS+rQtSNPrBUM1vB0zl5Vr/1eJkl cO/eOR+pJN4Gu+U5Sn/L/eiiHHQdyohhXO0RT0M5GKObfvdVUAcgup9XNDeCyCwI1p ADwRs8IzlsIg66vBjxTnGv5T8WOer9b2pzkMsUHO/pNxywNTfXPP/fHbmx81O0Qcm9 MBkaCt7/xdLsxWLRvK2mijSDZI3iFSX51A9xoHXijcXngYC2jKSD7h88sBKie6mDNz gBI1H6X8n5i+XZ6DMFZROSpAeBdiee/F56kJwXMTY51roZ7hAOh9fdgZ33Uo95yH+4 Quj8H0UOwwNnA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:51:43 +0900 Message-Id: <1507888305-20628-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> References: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini , Michal Marek Subject: [U-Boot] [PATCH v2 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 ] --- Changes in v2: None 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:51:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115722 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp530195qgn; Fri, 13 Oct 2017 02:52:45 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC7Q/YbDshZ6Y7w6EtEmb+Mars/yEBm4sB7m9V7BWPTr7NqWj9xcxL43pPROoRduB29/W45 X-Received: by 10.80.245.212 with SMTP id x20mr1397768edm.123.1507888364939; Fri, 13 Oct 2017 02:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507888364; cv=none; d=google.com; s=arc-20160816; b=lfrFRyxgGoLzkSerlcD5tKCWipLq+KK+z4Ayy3Ox8aiyaA3fOf5g+CCc/QEwT4h2iT LOfiKzUB6dZlp+AcdZUjmnkP9xP9wepNpCdtD6JBB0rF/nG3GWLitFFtPBkdQQf0Ul07 EbE/uruZFaE9++UzzHcwfeCphYTLJL4y4V1JnKIU5rxIzVYM6VjlH84t8cveYoUnTBR7 YmPh6SKeXSRvPeoFGoZ6OsL5x727aMMayaR+CO25FR3GHo5kOYoPPG7xvqLczuTUZ6F+ ZXvEf89Q9owPjf45MhlWdaItZj/olqVFE7PxaURQSYfw7ej+KjQ0l6zOYQD3yCGtp+a3 I+Dw== 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=r3EkcIMtMleubxQhPUcn1niXEoSz3hjuib0yt8NewQY=; b=ztAuruYveG5Ng12in6XMZShjZcq0wmZopir5II0DlEHEmEObdkMcKt0kZL88QbdbPE pqMbTi9clqgYvqX/LNtsBlgFY8Ykh3CjtjZowu/WfXXKv2lh7iJXTSHobPe6bnskBFJh BNfpzGA8Z7wrMizEuj14hMbmiv6UI1ZwLQ0pdYdvyNc956NXqtYaTBvonOUjofgLfnHW UpUnTiZVxDVURZwFH4m0HvaYqKraJuoHob/LwRaRFjKf56IglgwDz6yiN2QglVytwHme yMpAar4aV3UfET7zdnluLMKTLRo87kXBMVtbdX5PJKwJq5P23udamdNYBYwItIgjeG0s 7BMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Frgb17uf; 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 o92si607680eda.547.2017.10.13.02.52.44; Fri, 13 Oct 2017 02:52:44 -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=Frgb17uf; 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 8442BC21F43; Fri, 13 Oct 2017 09:52:41 +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 1EE0BC21EF2; Fri, 13 Oct 2017 09:52:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C0524C21C46; Fri, 13 Oct 2017 09:52:14 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 9D7F8C21C59 for ; Fri, 13 Oct 2017 09:52:13 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9D9plP5031812; Fri, 13 Oct 2017 18:51:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9D9plP5031812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507888309; bh=6FCtA0tjq1JTp+tYrbtnCL9w9Ma9hYkD02IExy2ymdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Frgb17ufOtRlkwqm6G/71q5AoDmG6pqhsZB2etjQYcVbq7n4YMHp8cWybyFpK9ftO Qz5H0FYAmia4bBiVDIvzoMRaISapmFwdAo3ksV5BSAt5QpV8N9siIItZAHsEj5TZSP y96N+9krugineOinMXtRrX0LIThnsVskGN2jVd2OBIqAVk/IGnt37H+LBNhIAK7VNi VV81wcLFf1ef7gjoEtnGuDFPl5u1Sq8G4FuduHVOKMiewZMNwhtkCDnQEvghev9AXs HixgJ4TXsYcsIjv03Vqk68uQ434XF8VvjCfOZh/8Hyn6kZ01+is0JD76f1egQJEYWa 8/4v5DSvX3C1Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:51:44 +0900 Message-Id: <1507888305-20628-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> References: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 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 --- Changes in v2: None 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:51:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115721 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp529945qgn; Fri, 13 Oct 2017 02:52:25 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBdQzEHD0/JMi+xaJttNTgr7tJF4bvqAb9sLVDlVxnEqbJ2VhUT9AJQddSAgYgX3PZENDI1 X-Received: by 10.80.201.12 with SMTP id o12mr1390117edh.98.1507888344928; Fri, 13 Oct 2017 02:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507888344; cv=none; d=google.com; s=arc-20160816; b=fuzc+dvylW4VHDGSrYPhxnTP4MyuMHSa7/y3500PZFbwW51NVZ9lvqA7dxguEW+Gxh N3OMOoIgot6Jeo3D5TWwacQSndmQl0ojSLW273aPrvuwAt84sfngyqwxo0K11TCvG++m kqx+/HeK5CrmTdgYDzd5c/eAvCFPNdDFhnIREJPI12OkHpFJriiNirejd2DlbyLKY0hQ DBzRlnu5EWWQA4Vvcbyb4GStRCAab8ykXZ6j4G8YaqcYyvg3A8HL6cIzvCMbAOjGUPhW CYCkMIkzARVnuZP1H5XABNhIYzUomSVAtMk78R4+Ak+YT9HRbDFUJRTwmDutcNhu8y8B JDWg== 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=ZF3asI2fbc85pep8YPF4nuL6NU1CI1xkrFI1oQTkh6Y=; b=bdEs1ZsmEKJlIsf2C7uy48oB8aCYu3R6C7od39lhI+5tNG1RHBzBhWfoE/OLa8dHxe m5pjklsNpDHsX7YSIO3YYy4pSDAMh4CUG5r6qr9751o7b9slv40HIWA/JbwpSlabCyU8 WY54LY2NVJWiRSz/ROm9uH65gb2BpLteC4E8afJuDL4yK9gvjWKPo866Zcf+Cg/3D/kY SjisKT7fU4itrkBMpp18niWCI/mPMxTVOGo6Os5tGrm+NNRG9/YjCkTjjDwaEJ3Sx7Rj qSKkHavp3e+fHB5uP1yfOClKPte0AoOiYnq9I4ANL7fHi7Oo5hnqTJ6vMyfVZgJfoBMR fTyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=tMfDK5nO; 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 x1si650988edc.447.2017.10.13.02.52.24; Fri, 13 Oct 2017 02:52:24 -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=tMfDK5nO; 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 1D0DAC21F6B; Fri, 13 Oct 2017 09:52:20 +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 8BBC8C21C59; Fri, 13 Oct 2017 09:52:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B60E2C21E6F; Fri, 13 Oct 2017 09:52:14 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 9C8BBC21C46 for ; Fri, 13 Oct 2017 09:52:13 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9D9plP6031812; Fri, 13 Oct 2017 18:51:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9D9plP6031812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507888310; bh=NyEnJhsc/hpJYbwH7We5Sh2j225yNh+dUrmWMxW5cSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tMfDK5nOWGZdbUDYkFO0MwOLAfSNJ77UerPVcRycsCnM8V9NXl5fkUpaNUsUt2wpp QfZDaeKvcvtZCcDGNXGNxRNMdyzdEapEUNGeijjZqqZ2f1WfqM/2sRqV4NxqQMewrR R2x3PF+tp5JjHk/clw3p1ht3xkN7r236FyiFKsTb/9uclkzlx5VzTVIxsKXnL7xIvz WjwAAt0bmMKrqq31EQOR2U2HksW64/qZWB1i0JDmUmVbtsEmlMSm9A1r/lVfvyNpob So9oDQX5715ETJWdQGSEh2RgjCeqB2BW8OcsJODImAZpSycYwJqepw3g1QptQhjue/ Vb+lFk4ZTNkwQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 18:51:45 +0900 Message-Id: <1507888305-20628-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> References: <1507888305-20628-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 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 --- Changes in v2: - Rephrase comments for clarification - Fix a typo Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 888486b..1ff312a 100644 --- a/Makefile +++ b/Makefile @@ -1334,6 +1334,15 @@ prepare0: archprepare FORCE # All the preparing.. prepare: prepare0 +# If possible, redefine __FILE__ as relative path from $(srctree). +# $$ is needed to evaluate the variables in sub-directories. +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. +# $(call cc-option,...) etc. may return wrong result. + # Generate some files # ---------------------------------------------------------------------------