From patchwork Sun Mar 12 12:01:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 9619313 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 7477A60417 for ; Sun, 12 Mar 2017 12:11:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C4182811E for ; Sun, 12 Mar 2017 12:11:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 505F528512; Sun, 12 Mar 2017 12:11:05 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 A6D702811E for ; Sun, 12 Mar 2017 12:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755726AbdCLMLE (ORCPT ); Sun, 12 Mar 2017 08:11:04 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33206 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755697AbdCLMLD (ORCPT ); Sun, 12 Mar 2017 08:11:03 -0400 Received: by mail-pf0-f195.google.com with SMTP id v190so15989043pfb.0; Sun, 12 Mar 2017 05:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=J40KwMNgzg/cNBcyWFPQnd6ps43YjkGGSlE2L/vUQTs=; b=AhEPmwEs3k40evPytpIPt+uxbRyOdS+UoA/M7CzXqBaU2z1IW3zg2EYCvukGUcNuEd lyQUPEQUfUWeVCbQZo/GkkUENZnY/giv0ARUl6Kl59Rc/2SNmVvHdLNQEZFbS8b6MQ6m LHJbQBjTaOs65xUxSY8t9kmgtC9u2Y66J8ZYAt45/easKtz9b3TcGsPKPn4U7WkSBXFk YupGbNB5tHTSEK3Qj3PNw/0ghQjfyb+uaYknqkvzebQyVwbWBG8M1ynSJtt3uTT4rGAx F+mqxk9b8INZYVyS8YTpguRhe4RYrxUO1vqqwv9d/yMR1REDy7qQDcww5xQLdlO+thZS q/bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=J40KwMNgzg/cNBcyWFPQnd6ps43YjkGGSlE2L/vUQTs=; b=qIgkLlqTIfAkLtQOsMV3rbav+Z0tUjMah2lRzw//N8WJhDdUZGvqp1lytsUl4GF99p H4WzJgyHCwiNvBKiyfM28r6MtGEWyg6plZYEAqfkTBTQPn75f+1g/PnDsHxAIvXPBcts Rfy6UrgIvHfPHEMfdsnWhJuBw7dHJFxiek+OouxolAc7nZOBG0TIu5zZ14FM3mQALS91 8dcIS+lablF6xwPlnmrX4cnLGYQvWAtkNjEdJ2aGXhby9sBAQxtojqc18pkxM3JbxUQT vLDr/fk3+pORJM0oqQU/SSPRd4F6W/94Q5drIB7t/sZJe94GKzMK7+tdLucDXjhxiW3D +Mgw== X-Gm-Message-State: AMke39nexL9dHHLgAz4NlDuWjN+DeCvpiSSktZSgC2HrEvKXQEXuui1IEikM6cysfG0X7A== X-Received: by 10.84.237.22 with SMTP id s22mr39781433plk.145.1489320662226; Sun, 12 Mar 2017 05:11:02 -0700 (PDT) Received: from localhost ([103.6.84.57]) by smtp.gmail.com with ESMTPSA id x10sm28258296pfi.21.2017.03.12.05.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Mar 2017 05:11:01 -0700 (PDT) From: Wei Yang To: mmarek@suse.com Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Yang , Masahiro Yamada Subject: [PATCH] kbuild: strip the last slash in KBUILD_EXTMOD Date: Sun, 12 Mar 2017 20:01:14 +0800 Message-Id: <20170312120114.14296-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 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 Current kbuild will build the target again if we run "make M=dir" and "make M=dir/" by turns, since if_changed will see the prerequisite is changed. The behavior may confuse the user a little, since actually we are building the same target and no difference. According to current implementation in scripts/Makefile.build, the obj passed to next level is a directory name with last slash stripped. This patch strips the last slash, and slashes in case user doing so, in KBUILD_EXTMOD which is assigned from "M=". Signed-off-by: Wei Yang CC: Masahiro Yamada --- v2: * remote the temp variable __KBUILD_EXTMOD, since this breaks the user case * use realpath to strips all the slash at the end, then remote the common part if it is an in tree build to make it the same behavior as previous version --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b8dfb24b1911..7f12e88cc0fb 100644 --- a/Makefile +++ b/Makefile @@ -191,6 +191,8 @@ ifeq ("$(origin M)", "command line") KBUILD_EXTMOD := $(M) endif +KBUILD_EXTMOD := $(subst $(CURDIR)/,,$(realpath $(KBUILD_EXTMOD))) + # If building an external module we do not care about the all: rule # but instead _all depend on modules PHONY += all