From patchwork Thu Oct 12 09:56:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10001419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D5EB602BF for ; Thu, 12 Oct 2017 09:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18A428D54 for ; Thu, 12 Oct 2017 09:57:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E61D728D58; Thu, 12 Oct 2017 09:57:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9941428D54 for ; Thu, 12 Oct 2017 09:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdJLJ5p (ORCPT ); Thu, 12 Oct 2017 05:57:45 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:26519 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbdJLJ5e (ORCPT ); Thu, 12 Oct 2017 05:57:34 -0400 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 v9C9uHcm005959; Thu, 12 Oct 2017 18:56:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9C9uHcm005959 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507802181; bh=Qvjufx8+osW2OaHrl9kU4g2M/ttBP2djeCqMwHPmBng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDtfCr5x0aMCZjWzU+74JAQ0OUE2915o4HHeP/paUb3ulOH2loaek+AQYT4TmJ9Kc X4OdJchdADCipIp3kmx1Lf5y0L//Xea4ViHEOakprg9IzZbN0w6HXFHvu0naz8lHnN EeTCDjEULyHP6r40W2fTxMu2mgccGCDiIvkS/zP7PXhDaRPTuBj7zx7iIf977+9DqU kNceIJ9yRy5pG0q9dyzzBjsXgM9zJnfatSG1DWhp5f6irSPEx+ErXrfdkaTa7PJGsS fRwiWjQf3gy15beal1sYdSmd4kjEMLn/yV2P0Z7Qdjrj2Sg4/6CfysTySL4/qDT7D/ KEd3EkRT3ZT3A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Joe Perches , Tom Rini , Geert Uytterhoeven , Masahiro Yamada , Matthias Kaehlcke , Cao jin , Arnd Bergmann , James Hogan , linux-kernel@vger.kernel.org, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Michal Marek , Douglas Anderson , Josh Poimboeuf , Ingo Molnar , Mark Charlebois Subject: [PATCH 1/2] kbuild: add stringify helper to quote a string passed to C files Date: Thu, 12 Oct 2017 18:56:03 +0900 Message-Id: <1507802164-31614-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> References: <1507802164-31614-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 db81df3..0b97354 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -33,6 +33,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 580e605..9bbb019 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -89,7 +89,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)))