public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
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	[thread overview]
Message-ID: <20240729143116.1804615-2-mark.rutland@arm.com> (raw)
In-Reply-To: <20240729143116.1804615-1-mark.rutland@arm.com>

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 <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
 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)
 
-- 
2.30.2



  reply	other threads:[~2024-07-29 14:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
2024-07-29 14:31 ` Mark Rutland [this message]
2024-07-29 14:31 ` [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains Mark Rutland
2024-08-02  9:21 ` [BOOT-WRAPPER 0/3] Allow " Marc Zyngier
2024-08-02 10:10 ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240729143116.1804615-2-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=akos.denke@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=luca.fancellu@arm.com \
    --cc=maz@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox