From patchwork Mon Aug 5 12:46:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 1969044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pFzf/NmK; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=F+qLkIUT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wcx5w1jlnz1yZb for ; Mon, 5 Aug 2024 22:46:57 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=I+7hFIZmJ+ElbFIn9+UVfZ3iEincUKf6leFQdtNrpJs=; b=pFzf/NmKSXhgvz e+pu1GIuKcQQju4s7H4+y4L4yUUv1ujQalCRmyPL0pAuj0vqmLKlABWz0x1k52Rf60b8QvCBd8Mwe T73zEjf1lZJXHSH6IOrvrXB/OFAcUTqXgNwwSpIIT4mccxlNOK42jv1Sq8j/s1kpu8AeRC2Rrlx9z DaZn9goStoTmCGj63sNHnlvM/Pw7Nvb81TjuolMRyE3RouR+3inllDQI5R43KXjlCfUVOJCvfu7Of 4Tz626acpp737cwohGflZEKzBi470fu3Mt5KgmWdeOaILUNYOIHQ1WIX1vgmq1w3VbpPQOtlI7E3P WqZTUZCns5YZuZpvq4Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sax6n-0000000Fpy9-0lmr; Mon, 05 Aug 2024 12:46:41 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sax6k-0000000Fpx9-1MQE for opensbi@lists.infradead.org; Mon, 05 Aug 2024 12:46:39 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fd640a6454so78696235ad.3 for ; Mon, 05 Aug 2024 05:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722861996; x=1723466796; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rQ0NfvHJ4acFHiYrN2QAsh3dS3q3zYLvdQfdVhw2MV4=; b=F+qLkIUTwenKbwzH31W3+kiUXcfr+4FXXwq/gnF8vr+khi+o1U3b2jpuDQYODY0E4L NrkTX3Gr32rIcaewcvwBqUeG1XAtJpjCOrByrDnaxQQEp+fAgZsPAyVdtQcH8WI4L6Wn x7XystBjxd4Ey/MvnCFZ/dKw3r283bk+Hfigi28+6LQQ1K77UqR0YzDDbdRx6V0Kg9jO RP+sRJhFCUX2QPGOv+0Jx8ChSIq92on8Z3NiF4CTNlui0cqmlJ8LqNa4oOsRrfVaDVjL 4bhUzHU8v/fvVY4TlHEHK4zPvBimFTNXmHINSNZjgOJWWp4V5eeSeIpQeVyGDUEeJrI9 Y3hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722861996; x=1723466796; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rQ0NfvHJ4acFHiYrN2QAsh3dS3q3zYLvdQfdVhw2MV4=; b=U/oHaYDowPDrJdKIotY4Mrrnfxa7wmLiJidjjQCpTvarMtyqqsy35fwAJbtxTWqhPb BSQOsKtmDoIA9H8V8Ab4+4hRriNmRaw8xPTgeM/hHkx0vrxNXvQP4MfYgBjcPuYE6KoU u2Wy7z27e/GNZrZARgagit1677tDwIKbHthdbCql2My+gGiCMUftO8E8b+94FYx0DXGq Srh7K88zQ0oIZlURRw6yBmLRkpsnL3zQoiSBUaC7PYhWrTutt64EDCsYohfZrgp0/1lS VEdLZqSvxC09IGRIqoTFlhIlFouyMPAvygYIWO+E9A8Bg+J8p0UHTVt0Lag/pMTns9rw m4jA== X-Gm-Message-State: AOJu0YxhfdCNbeXPt5g1TWE1wxpzJTQXA6YSJmHmT0seZGEenqw8x8q0 kqz6pBqdpiRFFs2eESY0YF9XZMU/L9xpIdcjaEJQN8tr419gvog8HaWt3tWMKJAuP5hXoqBrqoK W X-Google-Smtp-Source: AGHT+IG7j3JAcUMuq7aeOYbac2LwWsOdKYM8DUako5JY+v3912wLGf61gg71l3hZUChK6RJp86njZA== X-Received: by 2002:a17:903:1247:b0:1f9:f018:6973 with SMTP id d9443c01a7336-1ff574a1e32mr109573045ad.51.1722861996399; Mon, 05 Aug 2024 05:46:36 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([179.133.97.107]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff591858basm66531345ad.223.2024.08.05.05.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 05:46:36 -0700 (PDT) From: Daniel Henrique Barboza To: opensbi@lists.infradead.org Cc: anup@brainfault.org, Daniel Henrique Barboza Subject: [PATCH] Makefile: fix OPENSBI_VERSION_GIT build with submodules Date: Mon, 5 Aug 2024 09:46:32 -0300 Message-ID: <20240805124632.1732560-1-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_054638_382345_F5B27D73 X-CRM114-Status: UNSURE ( 9.02 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When building OpenSBI via a submodule, OPENSBI_VERSION_GIT can be left unset in case '.git' isn't a dir. This is the case when building OpenSBI as a QEMU submodule: $ cat .git gitdir: ../../.git/modules/roms/opensbi Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:636 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When building OpenSBI via a submodule, OPENSBI_VERSION_GIT can be left unset in case '.git' isn't a dir. This is the case when building OpenSBI as a QEMU submodule: $ cat .git gitdir: ../../.git/modules/roms/opensbi As a result, building OpenSBI tag v1.5.1 in QEMU will result in a binary that will have "OpenSBI v1.5" as a banner. Use "git rev-parse --git-dir" instead of checking if '.git' is a dir to detect if the current dir is a git repo. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Anup Patel --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9c7fd4d..1497174 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,13 @@ endif # Find library version OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'` OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'` -OPENSBI_VERSION_GIT=$(shell if [ -d $(src_dir)/.git ]; then git describe 2> /dev/null; fi) +OPENSBI_VERSION_GIT= + +# Detect 'git' presence before issuing 'git' commands +GIT_AVAIL=$(shell command -v git 2> /dev/null) +ifneq ($(GIT_AVAIL),) +OPENSBI_VERSION_GIT=$(shell git rev-parse --git-dir &> /dev/null && git describe 2> /dev/null) +endif # Setup compilation commands ifneq ($(LLVM),)