From patchwork Fri Mar 2 04:31:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 130456 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp857726lja; Thu, 1 Mar 2018 20:35:01 -0800 (PST) X-Google-Smtp-Source: AG47ELsotiYei8iYWCv4L4X3atA7tPjgywElgRKi5I6Lle3wHY/TsjVlTRU2UJ62XGrLe+HzmUGd X-Received: by 2002:a17:902:7d17:: with SMTP id z23-v6mr4041496pll.427.1519965301261; Thu, 01 Mar 2018 20:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519965301; cv=none; d=google.com; s=arc-20160816; b=k1/jt86f0OH1GiODEejq3NIrrcGVgjwL4PV4kg8lhSyCCKFvyjIArqBUqMjtJr/ex5 Bzpxvs+3oog8Q+c0bDE/hmp93HwM6xg/wvU5gokmnikAZjYx2zxnnYkQ1JtnAVknF4em neYiBOizWkhurh0MogJVFJujnEIcC7y+oM8XvDbA8EcAKRnd/MDKph+E/RJ2s0z+Gt1Y bx6iJYMWkspKgemMz90TJ/ztSnGMyepMDpWoMRoUMVc0x+AfozBfvrH2ClaycXztnGQS DC8ADiqPJL+uI6coPHluWmQRpLYzVMLurwhwGnAoC4Y8M/fqvtTvBQ7lPo3DQFK2bfRM 3ofw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=n3TiXYeIZq5TxMCCO5/91SkL7VVJ0kFWr2vwwZHYS3A=; b=pms+KqVzkFcOcmqdrkLQrvqA4cUeAW9NpGLW5TII7WbD33UganuLh9lXFo4t0hF0fE 8ByNO0UuUbtkvRFwvuVzA2/APMgX1ZKaTPlZUx6UVWh7ACXOuZsRHrwOp/adS4dDpjc2 6zaRjNpJdaUB7i1hxc7lEFbDvG5kCHqls633/O7P2nzYB/18DRstwMZWrsybN+G8I6st OF4vMEYkJyQr0SCFvdHgeObdErcsUlQF+JKk8bY3KWiXEfUWaxU6sTi1S1NmRWwJ0ph4 LNDc/12ZTkqPl+IIo7QDMc+2a9DLtZis9mrWgJx8bOq2+/sR9EWNQ2CyNA5samNU1btL /CKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qb3eBU0O; 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 h89si4224220pfa.182.2018.03.01.20.35.01; Thu, 01 Mar 2018 20:35:01 -0800 (PST) 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=qb3eBU0O; 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 S1165079AbeCBEe5 (ORCPT + 28 others); Thu, 1 Mar 2018 23:34:57 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:53203 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164993AbeCBEds (ORCPT ); Thu, 1 Mar 2018 23:33:48 -0500 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 w224WURC022085; Fri, 2 Mar 2018 13:32:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w224WURC022085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1519965152; bh=n3TiXYeIZq5TxMCCO5/91SkL7VVJ0kFWr2vwwZHYS3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qb3eBU0Op06riLVBpYsUR0BBXrGyJ4nYqxY+FagMWk8Pjp/Wnk17OYhjpqmV6ToMd vfyy0XO4pUPhb8vGR6fuhnnUD3M3JTWyTxP1yIkYqFcDxQgCAX9e+MzXxXm13j4mu0 9SAQJC0IPwaMjDc4C71uEYfWD+7AdeIfd4aEeBXbhRvJuKyOcp43dS3T8RzlYhx4LR fo9nyM/iz9akLzREEEd9vZq9jp26/79wTNBNcHMuix9mKlAKCbO/LQi1Dv1INZ2jnl Y7LI4w6Mbb6ZJ20oDfl4cwTyNiJWa2Md5xFpDOraCh6SJ0KRVOY4E8XE1x4dN9dJ2d Yy5AzJdHpN4CA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Masahiro Yamada , Tony Luck , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu Subject: [PATCH v2 01/11] kbuild: define PYTHON2 and PYTHON3 variables instead of PYTHON Date: Fri, 2 Mar 2018 13:31:51 +0900 Message-Id: <1519965121-12017-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519965121-12017-1-git-send-email-yamada.masahiro@socionext.com> References: <1519965121-12017-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The variable 'PYTHON' allows users to specify a proper executable name in case the default 'python' does not work. However, this does not address the case where both Python 2 and Python 3 scripts are used in one source tree. PEP 394 (https://www.python.org/dev/peps/pep-0394/) provides a convention for Python scripts portability. Here is a quotation: In order to tolerate differences across platforms, all new code that needs to invoke the Python interpreter should not specify 'python', but rather should specify either 'python2' or 'python3'. This distinction should be made in shebangs, when invoking from a shell script, when invoking via the system() call, or when invoking in any other context. arch/ia64/scripts/unwcheck.py is apparently written in Python 2, so it should be invoked by 'python2'. It is legitimate to use 'python' for scripts compatible with both Python 2 and Python 3, but this is rare (at least I do not see the case in kernel tree). You do not need to make efforts to write your scripts in that way. Anyway, Python 2 will retire in 2020. This commit is needed for new scripts written in Python 3. For the backward compatibility for ia64, if 'PYTHON' is specified, it is propagated to 'PYTHON2'. Signed-off-by: Masahiro Yamada --- Changes in v2: - Add backward compatibility for PYTHON Makefile | 5 +++-- arch/ia64/Makefile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 4fb97e9..ea23d9b 100644 --- a/Makefile +++ b/Makefile @@ -393,7 +393,8 @@ GENKSYMS = scripts/genksyms/genksyms INSTALLKERNEL := installkernel DEPMOD = /sbin/depmod PERL = perl -PYTHON = python +PYTHON2 := $(if $(PYTHON), $(PYTHON), python2) +PYTHON3 := python3 CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ @@ -439,7 +440,7 @@ GCC_PLUGINS_CFLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES -export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE +export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON2 PYTHON3 UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index 2dd7f51..862a2ba 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -75,7 +75,7 @@ vmlinux.gz: vmlinux $(Q)$(MAKE) $(build)=$(boot) $@ unwcheck: vmlinux - -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $< + -$(Q)READELF=$(READELF) $(PYTHON2) $(srctree)/arch/ia64/scripts/unwcheck.py $< archclean: $(Q)$(MAKE) $(clean)=$(boot)