Received: by 10.223.185.116 with SMTP id b49csp1045524wrg; Fri, 16 Feb 2018 11:24:17 -0800 (PST) X-Google-Smtp-Source: AH8x227Pqn5bHxuNJtiENGKU+AjP0AhPNrm13bX0NSOPECp8NCrW0zZPgvAeTrA+PTbYXkhqAEt5 X-Received: by 2002:a17:902:6ac7:: with SMTP id i7-v6mr6639832plt.368.1518809057468; Fri, 16 Feb 2018 11:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518809057; cv=none; d=google.com; s=arc-20160816; b=RB5W2FgG7kMgP2JSnAqs5ItQ4f+pff+VkJ9Zmh6WQBSHsKMHgkaRvvpUlyiaS0hhEx LgJxAvVSDI+owWPDebnSBET/VEPSiCU3sAs66pt/YL4ODHDYqmWEMlv48t78AwQVrpmP akEOeZCZJ8t4YOLmy1KbV9TmoLwMgTtDrnMzNOn8s0B18f4t+kAU5dJ+JiKXzSnJvjYD OkyEYiOzOn4/8F832RO4A69EVypAgyUKCvnBho7HZoS+wPubaJgG8HqZMCY732VCdDix C4eaoKSJo9lCIeCIT3/dztpHuvALiQyu/w3IziHLATwYZLMnPGN4Olkn0ddF3FW9dSLb PF6Q== 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 u16-v6si11285092plq.693.2018.02.16.11.24.03; Fri, 16 Feb 2018 11:24:17 -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 S1752054AbeBPSpM (ORCPT + 99 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 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 -- 2.7.4