From patchwork Mon Jul 29 14:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13745143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D65C4C3DA4A for ; Mon, 29 Jul 2024 14:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GN/GNS3Oe+d0yHzdcX9Z5r8aLiWvqxGNIlJjkNslJac=; b=0lS8mPYjo5fACvTzNkYteYRH8L HVLZioVhyoumsUXjcjmA0kxsYc3bvpyCxu5VHrKUevse588aQoO+LiTExJW46W3FtJIp34EOTs3Sr uJjI1Hlig6kbQk+2hXj3YtCwjDPHoAYEhHmQ6/kEUlB4uDd52+/Eyx1fHldjoEORvOeP/KDaClJbN b/2HhgVhomiOVV697BOtQl2JGB58YGzCItR1iSDQPdx3tlgiOHcQExPOeVWJcWqGsr960FheMp3mP aHVAGtKC4ZLbDKVzO0+ic0ghRUDs9jTZdoqQ3tIL5PoygpFaHEYvJMf+huiJFXPWkDfdaHwUKhbYn qe12byHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRiw-0000000Bk1p-126X; Mon, 29 Jul 2024 14:51:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRPI-0000000BcBZ-0yOk for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 14:31:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 74169143D; Mon, 29 Jul 2024 07:31:49 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0C3E43F64C; Mon, 29 Jul 2024 07:31:22 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akos.denke@arm.com, andre.przywara@arm.com, luca.fancellu@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Date: Mon, 29 Jul 2024 15:31:14 +0100 Message-Id: <20240729143116.1804615-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240729143116.1804615-1-mark.rutland@arm.com> References: <20240729143116.1804615-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_073124_345436_8B440A27 X-CRM114-Status: GOOD ( 13.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently we have the test-dtc-option helepr to check whether dtc supports an option. In subsequent patches we'll want similar for ld, and it seems likely that we'll want this for other commands in future. This patch adds a new test-cmd helper that can be used to check whether a command succeeds (based on its return value), and can be used to choose between a value if the comand succeeds and a value if the command fails. The existing test-dtc-option helper is reworked to use test-cmd. The helpers are added near the start of the file so that they'll be defined prior to usage whetever they're used within the file. This is purely for human comprehension as Make itself does not care about their location within the Makefile. Signed-off-by: Mark Rutland Cc: Andre Przywara Cc: Akos Denke Cc: Luca Fancellu Cc: Marc Zyngier --- Makefile.am | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6ebece2..6ab5cfd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,16 @@ SCRIPT_DIR := $(top_srcdir)/scripts +# test-cmd cmd,val-if-success,val-if-success,val-if-failure +define test-cmd +$(if $(shell { $(1); } >/dev/null 2>&1 && echo "success"),$(2),$(3)) +endef + +# Run dtc with an given command line option to check support for it. +define test-dtc-option +$(call test-cmd,echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null,$(1),) +endef + # VE PHYS_OFFSET := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findmem.pl $(KERNEL_DTB)) UART_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011') @@ -162,11 +172,6 @@ $(COMMON_SRC): model.lds: $(LD_SCRIPT) Makefile $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) $(XEN) -DXEN_OFFSET=$(XEN_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $< -# Run dtc with an given command line option to check support for it. -define test-dtc-option -$(if $(shell echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null 2>&1),,$(1)) -endef - DTC_NOWARN = $(call test-dtc-option,-Wno-clocks_property) DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)