From patchwork Fri Feb 16 18:38:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 128621 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp868529ljc; Fri, 16 Feb 2018 10:46:47 -0800 (PST) X-Google-Smtp-Source: AH8x224kWlvV4/m02As7pa4wh8n65u8fuSdTuYiE5Md6l9ksV7T4uugzC8miA8zPEtpiUOr7Qf34 X-Received: by 2002:a17:902:1746:: with SMTP id i64-v6mr6615504pli.53.1518806807547; Fri, 16 Feb 2018 10:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518806807; cv=none; d=google.com; s=arc-20160816; b=M5ZSewuLZkrtzpMzmm6qiKZnbLL9hI/Z7dNnkUAItwtogTNduACf59OsiDHkaBUreE TCQkwA/idBVStjcDCu1FP0d2Li98PeBEbxJg4SKt+5iWj0IMpHIh6tBI+usBunmxThBg +rdlskBybzR9yVKT/e3q1T2ZeyiSEGc/OFYL9sNHcqsRfnmL8ynLc8t1U9/wO6FK1Yjo LjblkM198t0YqWOPKphkSwFVGBjRZbQD6n9LyJaX/Z7qxQYgTT3U+BTHpx+3ADE9hxPp UPLpvevx/uGg0Q1nM8hMIEAXNMVhS2g0v7L9lB9NTqzhilY6F1Xf2idYxu+lbaKwQgFt Ghew== 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=g4jr7p8+pSavXrVBxgeLhmsF9gTgnd5dakNfR8FDu8k=; b=WSXwz/EKKUVIvGloizirUKK0hpNlmZwYVNCCS82iEAfF5HLgik3c5ZBVdtOpHf6Y04 6aoamjs0u7jJnvPb9ZIQNGQHhEmsonqberH3rQCcTtLJBd/hSieI5SRnvSwSNimi8Dy1 ZFf3wszeJCLZA1DaMZ16n7ZCtybbjsrmG42iSwrhbjV7phBl/1+PfDjZ4X4mqxb+m0QW ow7DWUU+tHTcqzYolqlJoLsUsP9HkLXB687/Z+MpjgYehagIRi6daxbrkYyjMG3WicLt FwDblXkSLzBc2Uira5vY1gwQec0CqLoi4qYeTwH5dbY6hqdzI7B1T/krESNF6aL4CAK4 7LBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Zv2WgPoR; 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 126si2374670pfd.48.2018.02.16.10.46.47; Fri, 16 Feb 2018 10:46:47 -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=Zv2WgPoR; 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 S1752184AbeBPSpM (ORCPT + 28 others); Fri, 16 Feb 2018 13:45:12 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57780 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752718AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTJ013418; Sat, 17 Feb 2018 03:39:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTJ013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806368; bh=g4jr7p8+pSavXrVBxgeLhmsF9gTgnd5dakNfR8FDu8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zv2WgPoRD5elvY50ieLvOVEDup3dPLbKRWyua+EoBAHVZMB83ZvVv7rna0Zef36PA 9/88wiMWHeEg56GF5wMZy8r89tuBB6ZmvX0dR25uFosurZe33DJiiD+G+mVWiwXNj8 gupHLKUw72v/82pQ3/vksS4CMIzEgA2KpMVNWzMV7RSpHJtrfIX1jdK876nnal4qeA 80vi65YuGXDHyY+vht/IpVFm6pSgzT3hxUNgaQyYNmviz3EEy6ewNPVF0fcLBYPjcP mObrh4I6tw5KFl4ao5wiP7+05FYazKjRaMf+0bfUnc7hCpK1molhuMms95c1plcGsm XetrjKOXE1DGg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Sami Tolvanen , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 16/23] kbuild: add clang-version.sh Date: Sat, 17 Feb 2018 03:38:44 +0900 Message-Id: <1518806331-7101-17-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-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 From: Sami Tolvanen Based on gcc-version.sh, clang-version.sh prints out the correct version of clang. Signed-off-by: Sami Tolvanen Tested-by: Nick Desaulniers Signed-off-by: Masahiro Yamada --- scripts/clang-version.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/clang-version.sh -- 2.7.4 diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh new file mode 100755 index 0000000..9780efa --- /dev/null +++ b/scripts/clang-version.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# clang-version [-p] clang-command +# +# Prints the compiler version of `clang-command' in a canonical 4-digit form +# such as `0500' for clang-5.0 etc. +# +# With the -p option, prints the patchlevel as well, for example `050001' for +# clang-5.0.1 etc. +# + +if [ "$1" = "-p" ] ; then + with_patchlevel=1; + shift; +fi + +compiler="$*" + +if [ ${#compiler} -eq 0 ]; then + echo "Error: No compiler specified." + printf "Usage:\n\t$0 \n" + exit 1 +fi + +MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) +MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) +if [ "x$with_patchlevel" != "x" ] ; then + PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) + printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL +else + printf "%02d%02d\\n" $MAJOR $MINOR +fi