From patchwork Fri Feb 20 00:19:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1905 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546798; bh=oA3hePKY/UpuYfJAUgC/uA8KN5fGbFK1rnqffRDUWzs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JWIpw3xjRN5qMci3q2Abu8TSrSA7w6Nx1wbPFzcKjxHzQuATM20yD2ImatdTI59LY dYAzB4qYy8p/JRM9+EsI/Io62Gqo1cFda5ZWv3hGAkv/7Jo82Kb+c3HVoOqJIsGsYf Z13IoKlmshsHxE9B5C8bEK/Ovxkw25xb7Dtca5jr332mmbD6WzQg0d1xXi11pr8FaH zBqQO+cc1uee+0dgUVsywiCSFkWnOGWeDOzQ3hiEa1kzEswFz/3QTh+AgyH7OuCQe+ a4UBPt4RKO4GmF0f2FAklkMTFn13o7t1F064Nnrp5Ir/6HjbveTjqTsH3NLOblfXUA U+Mpw9vtjIsDQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0847D69C8F for ; Thu, 19 Feb 2026 17:19:58 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4UMW0sJY0of6 for ; Thu, 19 Feb 2026 17:19:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546797; bh=oA3hePKY/UpuYfJAUgC/uA8KN5fGbFK1rnqffRDUWzs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=le0cr4b7K973OX8oWLucb17B/83OUC5DRSbjvtaQ5DOgS9E/ILYn4EZT8MAbt9fqX Sed8EYfwNr48ZwEb2ZvDCEN4MxBQTI6mCNd306D/yETEn2CYKrw22baw8hjFZ0K2rT 4mcRfS3sG3lQ/FBEpsePLvbMqgulEk4dZjhVIDzcZ4i8/hZBPWksj5baXxZBUIp7Bp CVnshMFvXJHUN7IUJZiRC1t21u9RM2XTxG7TvVe5PqUdTBB2vNYlolMNj0VA/Dfdo7 YKaWJGNsf99l8Ym7tgKK92KLgiWzjqVePsworEWAHVyOjlhz/adyVc2CD/8zatoyR4 9w7TxnctxjCKQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA3F769C87 for ; Thu, 19 Feb 2026 17:19:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546795; bh=StK7VJbckN8L8v/4hvDmVvTHOrPj6yHRFjg7AeOcNbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6aHgs84/nrx3Y73ANHQRbJbnBIRoOb1GYhiTaySADKSb86CJtlD6cZvNSN/GaxUF 7IHZEhYx0OG4vYR9NhciZ54IYtvG1VW7OY0bj3Cc9Q1OTth+qXre/2pG2XWIs7rY46 tooPZ5jlbUpUcZS4O0pdAYYWaaUuK+QsYpll/itb2BP1ixuayG45TV6v5BUP6JMBRm kFI9DoIge9mS2jbss2lzuiOpP1PP/i9inbSkQhqoDbMAqqJ2NeeUFJ3ZpsymOg4a+i p4abV7+Hj5exH5Qb1gGl+QPZaLONi8onyBFIqj7Yk+fXAg5js88DMYVw1V2gxzt1C0 /ig/wkKflzdxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 960E569C85; Thu, 19 Feb 2026 17:19:55 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 5vfaAxwzifFr; Thu, 19 Feb 2026 17:19:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546791; bh=y33N8lMZ/8cYfnfYaQwa48rXfMlm8vfdlRa8QetYEcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xo9p0o0S78w2F9iXCuHgqJP++jv7KYpeJhctUqk9VWdZnAJBqxhrwBNgV8GoT1fB/ EUM1OMmGRZ5RWwMakO7ZE7gPt+en1O8nru+/oyCFPSWy7c8qb3L1u5v4qgxIh686At wHRfVaZ7bPmYXWnQmUdL77qUnCQ+iUzEZyLrl4AEsob/kIEVZdzS8IaO7KR9DcobrD TIZi7jxQ9xDFIEKXtnHedeqUkPEHwcY+/xN6+T7b3yUyO5L4ZAoy3uz94IzzbtOALB EWJ7zr0vAFlwaCCx2n1GYKEYfqpbqIHNuzNMiYdG57YAuIm90mXwXiF/X6WU35tDLg wac3s48BQCA1Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B10F369C7C; Thu, 19 Feb 2026 17:19:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 19 Feb 2026 17:19:11 -0700 Message-ID: <20260220001926.2366140-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260220001926.2366140-1-sjg@u-boot.org> References: <20260220001926.2366140-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BSD7ODVDCTBUC3SYUQEVUOTIRE5HLHL3 X-Message-ID-Hash: BSD7ODVDCTBUC3SYUQEVUOTIRE5HLHL3 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/13] ulib: Extract common example build rules for demo List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Generalise the per-example link, objcopy and cat rules in Makefile.ulib-example from demo-specific to foreach+eval over the ULIB_EXAMPLES list. This is a pure refactoring that produces identical build output but makes it straightforward to add further examples. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- scripts/Makefile.ulib-example | 48 +++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/scripts/Makefile.ulib-example b/scripts/Makefile.ulib-example index 575dedcfbf2..796b74b0c14 100644 --- a/scripts/Makefile.ulib-example +++ b/scripts/Makefile.ulib-example @@ -25,32 +25,52 @@ quiet_cmd_u-boot-example = LD $@ # Per-example object lists (matches examples/ulib/Kbuild) example-demo-objs := examples/ulib/demo.o examples/ulib/demo_helper.o -# Link each example ELF (depends on u-boot to ensure archives exist) -examples/ulib/demo: $(example-demo-objs) u-boot FORCE - $(eval example-objs := $(example-demo-objs)) - $(call if_changed,u-boot-example) - $(EXAMPLE_POST_LINK) +# Generate link rule for each example +define example_link_rule +examples/ulib/$(1): $$(example-$(1)-objs) u-boot FORCE + $$(eval example-objs := $$(example-$(1)-objs)) + $$(call if_changed,u-boot-example) + $$(EXAMPLE_POST_LINK) +endef + +$(foreach e,$(ULIB_EXAMPLES),$(eval $(call example_link_rule,$(e)))) ifeq ($(CONFIG_EFI_APP),y) # EFI: embed DTB and convert to PE binary -OBJCOPYFLAGS_demo-app.efi := $(OBJCOPYFLAGS_EFI) -examples/ulib/demo-app.efi: examples/ulib/demo dts/dt.dtb FORCE - $(if $(CONFIG_OF_SEPARATE),$(call if_changed,embeddtb)) - $(call if_changed,zobjcopy) +$(foreach e,$(ULIB_EXAMPLES),\ + $(eval OBJCOPYFLAGS_$(e)-app.efi := $$(OBJCOPYFLAGS_EFI))) + +define example_efi_rule +examples/ulib/$(1)-app.efi: examples/ulib/$(1) dts/dt.dtb FORCE + $$(if $$(CONFIG_OF_SEPARATE),$$(call if_changed,embeddtb)) + $$(call if_changed,zobjcopy) +endef + +$(foreach e,$(ULIB_EXAMPLES),$(eval $(call example_efi_rule,$(e)))) examples_$(EXAMPLE_ARCH): \ $(foreach e,$(ULIB_EXAMPLES),examples/ulib/$(e)-app.efi) FORCE @: else # Binary target (without DTB) -OBJCOPYFLAGS_demo-nodtb.bin = $(OBJCOPYFLAGS_u-boot-nodtb.bin) -examples/ulib/demo-nodtb.bin: examples/ulib/demo FORCE - $(call if_changed,objcopy) +$(foreach e,$(ULIB_EXAMPLES),\ + $(eval OBJCOPYFLAGS_$(e)-nodtb.bin = $$(OBJCOPYFLAGS_u-boot-nodtb.bin))) + +define example_nodtb_rule +examples/ulib/$(1)-nodtb.bin: examples/ulib/$(1) FORCE + $$(call if_changed,objcopy) +endef + +$(foreach e,$(ULIB_EXAMPLES),$(eval $(call example_nodtb_rule,$(e)))) ifeq ($(EXAMPLE_APPEND_DTB),y) # Binary with DTB appended -examples/ulib/demo.bin: examples/ulib/demo-nodtb.bin dts/dt.dtb FORCE - $(call if_changed,cat) +define example_bin_rule +examples/ulib/$(1).bin: examples/ulib/$(1)-nodtb.bin dts/dt.dtb FORCE + $$(call if_changed,cat) +endef + +$(foreach e,$(ULIB_EXAMPLES),$(eval $(call example_bin_rule,$(e)))) examples_$(EXAMPLE_ARCH): \ $(foreach e,$(ULIB_EXAMPLES),examples/ulib/$(e).bin) FORCE