From patchwork Mon Oct 2 08:07:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114560 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp410939qgn; Mon, 2 Oct 2017 01:08:26 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDzP5E/skc7uEMG7hFoNtCdqFUdXGXF5NSIX0njea0FAlVo6Yrz1U44SWZgUPJJK+Eq71Q8 X-Received: by 10.98.64.14 with SMTP id n14mr3093923pfa.342.1506931706506; Mon, 02 Oct 2017 01:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506931706; cv=none; d=google.com; s=arc-20160816; b=ehkWt7AjBc7FbPSp+T//GEav/vnsdgcQf7+wky914xU0mKCMea7EUeQid26biIuZ/m Wc84MImqrpZlDdUbaT2ZS7NaxAYc4yX5dZo8Y97MYk+Y8WYsgJVqu+XA2eKq2kzIXpbj fpqDB2EQ8X9Seu/Aqp5GH5WIffOILvrRpgHliDonbb13HXF1LobkHYQz7elIamZGXDO9 Vhw/mR+5izFPihrGIr1PS6nBka0QF8GykLev4lQZT/HiNPYO6EVeRJqkOpBSiEMugppq QFYHlih751m9CND5lEKqrVWxLZT9bS/NZJifZ7DGlO35AQcSjkDS6ziB8RX+aG7GGJDd qQrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=9JgXutuZ0YWSZxD/BTHeBow07XqCNFEL7ZJI3rws//M=; b=xM97hOwNlOJAQx4pKIWKmuWrBRg4aqdGTh8HAr+NhrDosda+wCeYFPerU00SCbPLIP q4GXlVFbbsp9aEJPPPsi7Tw3VmXP4JvWi1ftRbb6gYdWuaiGj4b/2uCoKnc1Yvq+bOZc IYRZAYxaGytcAwzJ1ZLiycNsHsc+8axRUaeisNSeGDLs7ncD6n/EE/PSZue3i+hPkFkF vj/oXY0XWLggzhWN4oqDeNDEQIGPiRilvpuSLSYjj2ENY6Wvn42Z/KoCFvXSBznq01qG By9VN4gWqgfmyDEaMjaHtbcKgDaazSqljR8sCnJGrgNOh8WfmCbVHTLQXhCpSDgEHkJ2 uO8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=h0ue0Ib8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si611875pfc.275.2017.10.02.01.08.26; Mon, 02 Oct 2017 01:08:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=h0ue0Ib8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751105AbdJBIIV (ORCPT + 26 others); Mon, 2 Oct 2017 04:08:21 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:49222 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdJBIIS (ORCPT ); Mon, 2 Oct 2017 04:08:18 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v9287dMC030106; Mon, 2 Oct 2017 17:07:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9287dMC030106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1506931660; bh=9JgXutuZ0YWSZxD/BTHeBow07XqCNFEL7ZJI3rws//M=; h=From:To:Cc:Subject:Date:From; b=h0ue0Ib83xXpGoyZr6Q2xB25AL/U9tYZ8+vv40h58taIZ2vgPgrIODFNio2HUR0ay PPAwhInZASOP82uyEouLcUOgtUpbOwVgZro4pH196rCXeIOtpw36EZPweuRuramEa0 mKcNqahMYnFMZygkJTlMticHEXmJJ6OlH6vVenduxVcOy3TzLmA859nL+vrcdeHmkg 5PQUSVaS9nADnrgFcDtIRCf6qrfOJQDKGGpgqc627L9MzFXZfGBb09ZAcwD1HPOvF1 18KWRUqr4/Devv0FRYp2yac6FI/BycgWqVCLN+F6K/WOg8EJNVLq273W+ZdwiogZ0w ge7EL/DIEDy0g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Julien Grall , Masahiro Yamada , linux-pm@vger.kernel.org, Michal Marek , David Carrillo-Cisneros , linux-kernel@vger.kernel.org, Thomas Renninger , Josh Poimboeuf , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH] kbuild: revert $(realpath ...) to $(shell cd ... && /bin/pwd) Date: Mon, 2 Oct 2017 17:07:28 +0900 Message-Id: <1506931648-15511-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I thought commit 8e9b46679923 ("kbuild: use $(abspath ...) instead of $(shell cd ... && /bin/pwd)") was a safe conversion, but it changed the behavior. $(abspath ...) / $(realpath ...) does not expand shell special characters, such as '~'. Here is a simple Makefile example: ---------------->8---------------- $(info /bin/pwd: $(shell cd ~/; /bin/pwd)) $(info abspath: $(abspath ~/)) $(info realpath: $(realpath ~/)) all: @: ---------------->8---------------- $ make /bin/pwd: /home/masahiro abspath: /home/masahiro/workspace/~ realpath: This can be a real problem if 'make O=~/foo' is invoked from another Makefile or primitive shell like dash. This commit partially reverts 8e9b46679923. Fixes: 8e9b46679923 ("kbuild: use $(abspath ...) instead of $(shell cd ... && /bin/pwd)") Reported-by: Julien Grall Signed-off-by: Masahiro Yamada --- Makefile | 4 ++-- tools/power/cpupower/Makefile | 2 +- tools/scripts/Makefile.include | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index cf007a3..1b48717 100644 --- a/Makefile +++ b/Makefile @@ -130,8 +130,8 @@ endif ifneq ($(KBUILD_OUTPUT),) # check that the output directory actually exists saved-output := $(KBUILD_OUTPUT) -$(shell [ -d $(KBUILD_OUTPUT) ] || mkdir -p $(KBUILD_OUTPUT)) -KBUILD_OUTPUT := $(realpath $(KBUILD_OUTPUT)) +KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ + && /bin/pwd) $(if $(KBUILD_OUTPUT),, \ $(error failed to create output directory "$(saved-output)")) diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile index 4c5a481..d6e1c02 100644 --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile @@ -26,7 +26,7 @@ endif ifneq ($(OUTPUT),) # check that the output directory actually exists -OUTDIR := $(realpath $(OUTPUT)) +OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) endif diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 9dc8f07..1e8b611 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -1,7 +1,7 @@ ifneq ($(O),) ifeq ($(origin O), command line) - ABSOLUTE_O := $(realpath $(O)) - dummy := $(if $(ABSOLUTE_O),,$(error O=$(O) does not exist)) + dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) + ABSOLUTE_O := $(shell cd $(O) ; pwd) OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/) COMMAND_O := O=$(ABSOLUTE_O) ifeq ($(objtree),) @@ -12,7 +12,7 @@ endif # check that the output directory actually exists ifneq ($(OUTPUT),) -OUTDIR := $(realpath $(OUTPUT)) +OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) endif