From patchwork Fri Mar 16 15:27:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 147217 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2FE7CB765A for ; Sat, 17 Mar 2012 02:28:05 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 86F7F281F8; Fri, 16 Mar 2012 16:28:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s2WryZ4zaRJF; Fri, 16 Mar 2012 16:28:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6052281E6; Fri, 16 Mar 2012 16:27:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 56947281EA for ; Fri, 16 Mar 2012 16:27:56 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xrNcrKoDU0-T for ; Fri, 16 Mar 2012 16:27:55 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by theia.denx.de (Postfix) with ESMTPS id 9B621281E4 for ; Fri, 16 Mar 2012 16:27:53 +0100 (CET) Received: by dakl33 with SMTP id l33so6386097dak.3 for ; Fri, 16 Mar 2012 08:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=0T8bF22wPQcD0DVWLPSPUSAq9ZmJDrc7t668VkG1F9o=; b=M0LHtRRjWCV/hPj53TYqRcZDrGi4ExHTidBHcIbWlTPpd69iiRtWrCK856miGMSnrl Jtg3ZV8+N2gS2v7z+KJzaGkDiaFETAIw9DwGm/JDc2IsdPtl+1JTwW6VQJROFCRglXbS 3lAF4g6rQPKUHmzXkvhm3zQduQJ1Oy+cCRdqEhfkHwuc54PYICwcRXYkMcJMz4X23l6l GY6F53dVmtXAkFov35RRgLVhCeewQSCXwe6IPHEKOlXHtNEOC2IJhCws+3J5YX9+ELn7 05QcKd/2xoWb1BIdwNNB1XhbuxoqIxMxULtpbNnOtgEJDXY8toRp3V7+6xcP3DXKx1P/ 0evw== Received: by 10.68.193.138 with SMTP id ho10mr15620012pbc.80.1331911670645; Fri, 16 Mar 2012 08:27:50 -0700 (PDT) Received: from localhost.localdomain (ip68-230-54-74.ph.ph.cox.net. [68.230.54.74]) by mx.google.com with ESMTPS id a2sm1952776pbl.33.2012.03.16.08.27.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 08:27:49 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Date: Fri, 16 Mar 2012 08:27:47 -0700 Message-Id: <1331911668-22107-1-git-send-email-trini@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1331227222-12419-1-git-send-email-aneesh@ti.com> References: <1331227222-12419-1-git-send-email-aneesh@ti.com> Subject: [U-Boot] [PATCH 1/2] tools, config.mk: Add gcc-version.sh, cc-version test from Linux X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Added from Linux - commit fde7d9049e55ab85a390be7f415d74c9f62dd0f9 Signed-off-by: Tom Rini --- config.mk | 6 +++++- tools/gcc-version.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletions(-) create mode 100755 tools/gcc-version.sh diff --git a/config.mk b/config.mk index ddaa477..8f4a253 100644 --- a/config.mk +++ b/config.mk @@ -104,7 +104,7 @@ HOSTCFLAGS += -pedantic ######################################################################### # -# Option checker (courtesy linux kernel) to ensure +# Option checker, gcc version (courtesy linux kernel) to ensure # only supported compiler options are used # CC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mk @@ -126,6 +126,10 @@ cc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\ $(if $(call cc-option-sys,$1),$1,$2))) endif +# cc-version +# Usage gcc-ver := $(call cc-version) +cc-version = $(shell $(SHELL) $(SRCTREE)/tools/gcc-version.sh $(CC)) + # # Include the make variables (CC, etc...) # diff --git a/tools/gcc-version.sh b/tools/gcc-version.sh new file mode 100755 index 0000000..debecb5 --- /dev/null +++ b/tools/gcc-version.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# gcc-version [-p] gcc-command +# +# Prints the gcc version of `gcc-command' in a canonical 4-digit form +# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. +# +# With the -p option, prints the patchlevel as well, for example `029503' for +# gcc-2.95.3, `030301' for gcc-3.3.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 __GNUC__ | $compiler -E -xc - | tail -n 1) +MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) +if [ "x$with_patchlevel" != "x" ] ; then + PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1) + printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL +else + printf "%02d%02d\\n" $MAJOR $MINOR +fi