[Concept,04/14] examples: Correct dependencies for ulib

Message ID 20250911214425.3687188-5-sjg@u-boot.org
State New
Headers
Series ulib: Add support for Rust main programs |

Commit Message

Simon Glass Sept. 11, 2025, 9:44 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

We need to check for the ulib library before building any examples. Add
this and ensure that the examples are rebuilt if the library changes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 examples/ulib/rules.mk | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
  

Patch

diff --git a/examples/ulib/rules.mk b/examples/ulib/rules.mk
index aba6c63d8b6..c4b0bdb3668 100644
--- a/examples/ulib/rules.mk
+++ b/examples/ulib/rules.mk
@@ -19,11 +19,11 @@  $(foreach obj,$(sys-objs),$(eval $(OUTDIR)/$(obj): \
 
 # Automatic build rules for all programs
 $(foreach prog,$(progs),$(eval $(OUTDIR)/$(prog): \
-	$$(addprefix $(OUTDIR)/,$$($(prog)_objs)) ; \
-	$$(CC) $$(CFLAGS) -o $$@ $$^ $$(SHARED_LDFLAGS)))
+	$$(addprefix $(OUTDIR)/,$$($(prog)_objs)) $(UBOOT_BUILD)/libu-boot.so ; \
+	$$(CC) $$(CFLAGS) -o $$@ $$(filter-out %.so,$$^) $$(SHARED_LDFLAGS)))
 $(foreach prog,$(progs),$(eval $(OUTDIR)/$(prog)_static: \
-	$$(addprefix $(OUTDIR)/,$$($(prog)_objs)) ; \
-	$$(CC) $$(CFLAGS) -o $$@ $$^ $$(STATIC_LDFLAGS)))
+	$$(addprefix $(OUTDIR)/,$$($(prog)_objs)) $(UBOOT_BUILD)/libu-boot.a ; \
+	$$(CC) $$(CFLAGS) -o $$@ $$(filter-out %.a,$$^) $$(STATIC_LDFLAGS)))
 
 # Create the output directory if it doesn't exist
 $(OUTDIR):
@@ -32,8 +32,3 @@  $(OUTDIR):
 # Default rule: compile with U-Boot headers
 $(OUTDIR)/%.o: $(EXAMPLE_DIR)/%.c | $(OUTDIR)
 	$(CC) $(CFLAGS) $(UBOOT_CFLAGS) -c -o $@ $<
-
-# The U-Boot library must be built before we can link against it
-# Order-only prerequisites ensure libraries exist before linking
-$(all_bins): | $(UBOOT_BUILD)/libu-boot.a $(UBOOT_BUILD)/libu-boot.so \
-	$(OUTDIR)
\ No newline at end of file