Skip to content

Commit 0bf5ee2

Browse files
committed
Enhance build system for tarball distribution
This supports both git repositories and release tarballs by converting git submodule operations to conditional clone logic. - Add ensure-submodule helper function with error handling - Convert parse-time shell to proper build targets (DTC_SENTINEL) - Add directory cleanup for pre-existing non-git directories - Fix injection risks via variable quoting and whitelist validation - Improve error messages with explicit stderr output
1 parent 6f3cb95 commit 0bf5ee2

File tree

8 files changed

+136
-69
lines changed

8 files changed

+136
-69
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ ifeq ($(CONFIG_GDBSTUB),y)
122122
GDBSTUB_OUT = $(abspath $(OUT)/mini-gdbstub)
123123
GDBSTUB_COMM = 127.0.0.1:1234
124124
src/mini-gdbstub/Makefile:
125-
git submodule update --init $(dir $@)
125+
$(call ensure-submodule,src/mini-gdbstub,https://github.com/RinHizakura/mini-gdbstub)
126126
GDBSTUB_LIB := $(GDBSTUB_OUT)/libgdbstub.a
127127
$(GDBSTUB_LIB): src/mini-gdbstub/Makefile
128128
$(MAKE) -C $(dir $<) O=$(dir $@)
@@ -200,6 +200,8 @@ DTB_DEPS :=
200200
ifeq ($(CONFIG_SYSTEM),y)
201201
ifneq ($(CONFIG_ELF_LOADER),y)
202202
DTB_DEPS := $(BUILD_DTB) $(BUILD_DTB2C)
203+
# Ensure DTC is cloned before building DTB
204+
$(BUILD_DTB) $(BUILD_DTB2C): $(DTC_SENTINEL)
203205
endif
204206
endif
205207

mk/artifact.mk

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,35 @@ ifeq ($(call has, SYSTEM), 1)
277277
$(Q)(mv $(BIN_DIR)/linux-image/rootfs.cpio /tmp/rv32emu-linux-image-prebuilt/linux-image)
278278
$(Q)(mv $(BIN_DIR)/linux-image/simplefs.ko /tmp/rv32emu-linux-image-prebuilt/linux-image)
279279
else
280-
git submodule update --init $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
280+
$(Q)if [ -d .git ]; then \
281+
git submodule update --init --depth=1 $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb))) || { \
282+
echo "Error: Failed to update test suite submodules" >&2; \
283+
exit 1; \
284+
}; \
285+
else \
286+
for tb in $(TEST_SUITES); do \
287+
case "$$tb" in \
288+
ansibench|rv8-bench) \
289+
if [ -d "./tests/$$tb" ] && [ ! -d "./tests/$$tb/.git" ]; then \
290+
echo "Warning: Removing pre-existing ./tests/$$tb without .git" >&2; \
291+
rm -rf "./tests/$$tb"; \
292+
fi; \
293+
if [ ! -d "./tests/$$tb/.git" ]; then \
294+
case "$$tb" in \
295+
ansibench) git clone --depth=1 https://github.com/sysprog21/ansibench "./tests/$$tb" ;; \
296+
rv8-bench) git clone --depth=1 https://github.com/sysprog21/rv8-bench "./tests/$$tb" ;; \
297+
esac || { \
298+
echo "Error: Failed to clone test suite $$tb" >&2; \
299+
exit 1; \
300+
}; \
301+
fi; \
302+
;; \
303+
*) \
304+
echo "Warning: Unknown test suite '$$tb', skipping" >&2; \
305+
;; \
306+
esac; \
307+
done; \
308+
fi
281309
$(Q)for tb in $(TEST_SUITES); do \
282310
CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" BINDIR=$(BIN_DIR)/linux-x86-softfp $(MAKE) -C ./tests/$$tb; \
283311
done
@@ -293,7 +321,8 @@ else
293321
$(CROSS_COMPILE)gcc $(CFLAGS_CROSS) -o $(BIN_DIR)/riscv32/$$tb ./tests/$$tb.c $(LDFLAGS_CROSS); \
294322
done
295323

296-
git submodule update --init ./tests/doom ./tests/quake
324+
$(call ensure-submodule,tests/doom,https://github.com/sysprog21/doom_riscv)
325+
$(call ensure-submodule,tests/quake,https://github.com/sysprog21/quake-embedded)
297326
$(Q)$(PRINTF) "Building doom ...\n"
298327
$(Q)$(MAKE) -C ./tests/doom/src/riscv CROSS=$(CROSS_COMPILE)
299328
$(Q)cp ./tests/doom/src/riscv/doom-riscv.elf $(BIN_DIR)/riscv32/doom
@@ -335,7 +364,7 @@ endif
335364

336365
ieeelib:
337366
ifeq ($(call has, PREBUILT), 0)
338-
git submodule update --init ./src/ieeelib
367+
$(call ensure-submodule,src/ieeelib,https://github.com/sysprog21/ieeelib)
339368
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BIN_DIR)
340369
endif
341370

mk/common.mk

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,35 @@ $(1):
109109
$$(Q)mkdir -p $$@
110110
endef
111111

112+
# Conditional submodule/clone helper for tarball compatibility
113+
# Handles both git repository (uses submodule) and release tarball (uses git clone)
114+
# $(1): target directory
115+
# $(2): repository URL
116+
# $(3): branch/tag (optional, defaults to default branch)
117+
define ensure-submodule
118+
@if [ -d .git ]; then \
119+
git submodule update --init --depth=1 "$(1)" || { \
120+
echo "Error: Failed to update submodule $(1)" >&2; \
121+
exit 1; \
122+
}; \
123+
else \
124+
if [ -d "$(1)" ] && [ ! -d "$(1)/.git" ]; then \
125+
echo "Warning: Directory $(1) exists without .git, removing..." >&2; \
126+
rm -rf "$(1)"; \
127+
fi; \
128+
if [ ! -d "$(1)/.git" ]; then \
129+
CLONE_OPTS="--depth=1"; \
130+
if [ -n "$(3)" ]; then \
131+
CLONE_OPTS="$$CLONE_OPTS --branch=$(3)"; \
132+
fi; \
133+
git clone $$CLONE_OPTS "$(2)" "$(1)" || { \
134+
echo "Error: Failed to clone $(2) to $(1)" >&2; \
135+
exit 1; \
136+
}; \
137+
fi; \
138+
fi
139+
endef
140+
112141
# Generic object compilation rule
113142
# $(1): output directory variable name (e.g., OUT)
114143
# $(2): source directory (e.g., src)
@@ -190,13 +219,13 @@ $$(foreach e,$(2),$$(eval $$(call run-test-action,$(1),$$(e))))
190219

191220
run-test-$(1): $$($(1)_TEST_OUT)
192221
$$(Q)$$(foreach e,$$($(1)_TEST_ACTIONS),\
193-
$$(PRINTF) "Running $$(e) ... "; \
194-
if cmp $$($(1)_TEST_SRCDIR)/$$(e).expect $$($(1)_TEST_OUTDIR)/$$(e).out; then \
195-
$$(call notice, [OK]); \
196-
else \
197-
$$(PRINTF) "Failed.\n"; \
198-
exit 1; \
199-
fi; \
222+
$$(PRINTF) "Running $$(e) ... "; \
223+
if cmp $$($(1)_TEST_SRCDIR)/$$(e).expect $$($(1)_TEST_OUTDIR)/$$(e).out; then \
224+
$$(call notice, [OK]); \
225+
else \
226+
$$(PRINTF) "Failed.\n"; \
227+
exit 1; \
228+
fi; \
200229
)
201230
endef
202231

mk/external.mk

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,23 @@ endef
7373
# Returns: exits with error if verification fails; skips if no SHA tool
7474
define verify-sha
7575
@if [ -z "$(1)" ]; then \
76-
echo "Skipping SHA verification for $(3) (no SHA tool available)"; \
76+
echo "Skipping SHA verification for $(3) (no SHA tool available)"; \
7777
elif [ -d "$(3)" ]; then \
78-
FILE_HASHES=$$(find "$(3)" -type f -not -path '*/.git/*' -print0 | LC_ALL=C sort -z | xargs -0 $(1) 2>/dev/null | LC_ALL=C sort); \
79-
if [ -z "$$FILE_HASHES" ]; then \
80-
echo "SHA verification failed for directory $(3): no files found"; \
81-
exit 1; \
82-
fi; \
83-
COMPUTED=$$(echo "$$FILE_HASHES" | $(1) | cut -f1 -d' '); \
84-
if [ "$$COMPUTED" != "$(2)" ]; then \
85-
echo "SHA verification failed for directory $(3)"; \
86-
exit 1; \
87-
fi; \
78+
FILE_HASHES=$$(find "$(3)" -type f -not -path '*/.git/*' -print0 | LC_ALL=C sort -z | xargs -0 $(1) 2>/dev/null | LC_ALL=C sort); \
79+
if [ -z "$$FILE_HASHES" ]; then \
80+
echo "SHA verification failed for directory $(3): no files found"; \
81+
exit 1; \
82+
fi; \
83+
COMPUTED=$$(echo "$$FILE_HASHES" | $(1) | cut -f1 -d' '); \
84+
if [ "$$COMPUTED" != "$(2)" ]; then \
85+
echo "SHA verification failed for directory $(3)"; \
86+
exit 1; \
87+
fi; \
8888
else \
89-
if ! echo "$(2) $(3)" | $(1) -c - >/dev/null 2>&1; then \
90-
echo "SHA verification failed for $(3)"; \
91-
exit 1; \
92-
fi; \
89+
if ! echo "$(2) $(3)" | $(1) -c - >/dev/null 2>&1; then \
90+
echo "SHA verification failed for $(3)"; \
91+
exit 1; \
92+
fi; \
9393
fi
9494
endef
9595

@@ -132,7 +132,7 @@ TIMIDITY_DATA_SHA_CMD := $(SHA1SUM)
132132
BUILDROOT_VERSION := 2025.11
133133
BUILDROOT_DATA_DEST := /tmp
134134
BUILDROOT_DATA := $(BUILDROOT_DATA_DEST)/buildroot
135-
BUILDROOT_DATA_URL := git clone https://github.com/buildroot/buildroot $(BUILDROOT_DATA) -b $(BUILDROOT_VERSION) --depth=1
135+
BUILDROOT_DATA_URL := git clone https://github.com/buildroot/buildroot "$(BUILDROOT_DATA)" -b $(BUILDROOT_VERSION) --depth=1
136136
# find /tmp/buildroot -type f -not -path '*/.git/*' -print0 | \
137137
# LC_ALL=C sort -z | \
138138
# xargs -0 sha1sum | \
@@ -155,7 +155,7 @@ LINUX_DATA_SHA_CMD := $(SHA256SUM)
155155
SIMPLEFS_VERSION := rel2025.0
156156
SIMPLEFS_DATA_DEST := /tmp
157157
SIMPLEFS_DATA := $(SIMPLEFS_DATA_DEST)/simplefs
158-
SIMPLEFS_DATA_URL := git clone https://github.com/sysprog21/simplefs $(SIMPLEFS_DATA) -b $(SIMPLEFS_VERSION) --depth=1
158+
SIMPLEFS_DATA_URL := git clone https://github.com/sysprog21/simplefs "$(SIMPLEFS_DATA)" -b $(SIMPLEFS_VERSION) --depth=1
159159
# find /tmp/simplefs -type f -not -path '*/.git/*' -print0 | \
160160
# LC_ALL=C sort -z | \
161161
# xargs -0 sha1sum | \
@@ -174,10 +174,10 @@ $($(1)_DATA):
174174
$(Q)mkdir -p $($(1)_DATA_DEST)
175175
$(Q)$$(call download,$($(1)_DATA_URL))
176176
$(Q)$(if $(call is-git-clone,$($(1)_DATA_URL)),,\
177-
$$(call extract,$($(1)_DATA_DEST),$(notdir $($(1)_DATA_URL)),$(or $($(1)_DATA_SKIP_DIR_LEVEL),0)))
177+
$$(call extract,$($(1)_DATA_DEST),$(notdir $($(1)_DATA_URL)),$(or $($(1)_DATA_SKIP_DIR_LEVEL),0)))
178178
$$(call verify-sha,$($(1)_DATA_SHA_CMD),$($(1)_DATA_SHA),$($(1)_DATA))
179179
$(if $(call is-git-clone,$($(1)_DATA_URL)),,\
180-
$$(call epilogue,$(notdir $($(1)_DATA_URL))))
180+
$$(call epilogue,$(notdir $($(1)_DATA_URL))))
181181
endef
182182

183183
# Generate rules for static external data (known URLs at parse time)
@@ -191,24 +191,24 @@ $(LINUX_DATA_DEST)/linux-$(LINUX_VERSION).$(LINUX_PATCHLEVEL).%.tar.gz:
191191
$(Q)mkdir -p $(LINUX_DATA_DEST)
192192
$(VECHO) " GET\t$@\n"
193193
$(Q)LINUX_TARBALL=$$(wget -q -O- $(LINUX_CDN_VERSION_URL) 2>/dev/null | \
194-
grep -oE 'linux-$(LINUX_VERSION)\.$(LINUX_PATCHLEVEL)\.[0-9]+\.tar\.gz' | \
195-
awk -F'[.-]' '{print $$4, $$0}' | sort -rn | head -1 | awk '{print $$2}'); \
194+
grep -oE 'linux-$(LINUX_VERSION)\.$(LINUX_PATCHLEVEL)\.[0-9]+\.tar\.gz' | \
195+
awk -F'[.-]' '{print $$4, $$0}' | sort -rn | head -1 | awk '{print $$2}'); \
196196
if [ -z "$$LINUX_TARBALL" ]; then \
197-
echo "Error: Failed to detect Linux kernel tarball from $(LINUX_CDN_VERSION_URL)"; \
198-
exit 1; \
197+
echo "Error: Failed to detect Linux kernel tarball from $(LINUX_CDN_VERSION_URL)"; \
198+
exit 1; \
199199
fi; \
200200
LINUX_SHA=$$(wget -q -O- $(LINUX_CDN_VERSION_URL)/sha256sums.asc 2>/dev/null | \
201-
grep "$$LINUX_TARBALL" | awk '{print $$1}'); \
201+
grep "$$LINUX_TARBALL" | awk '{print $$1}'); \
202202
if [ -z "$$LINUX_SHA" ]; then \
203-
echo "Error: Failed to fetch SHA256 for $$LINUX_TARBALL"; \
204-
exit 1; \
203+
echo "Error: Failed to fetch SHA256 for $$LINUX_TARBALL"; \
204+
exit 1; \
205205
fi; \
206206
wget -q --show-progress --continue "$(LINUX_CDN_VERSION_URL)/$$LINUX_TARBALL" && \
207207
tar -xf "$$LINUX_TARBALL" --strip-components=$(LINUX_DATA_SKIP_DIR_LEVEL) -C $(LINUX_DATA_DEST) && \
208208
if [ -z "$(LINUX_DATA_SHA_CMD)" ]; then \
209-
echo "Skipping SHA verification for $$LINUX_TARBALL (no SHA tool available)"; \
209+
echo "Skipping SHA verification for $$LINUX_TARBALL (no SHA tool available)"; \
210210
elif ! echo "$$LINUX_SHA $$LINUX_TARBALL" | $(LINUX_DATA_SHA_CMD) -c - >/dev/null 2>&1; then \
211-
echo "SHA verification failed for $$LINUX_TARBALL"; exit 1; \
211+
echo "SHA verification failed for $$LINUX_TARBALL"; exit 1; \
212212
fi && \
213213
$(RM) "$$LINUX_TARBALL"
214214

mk/kconfig.mk

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ KCONFIGLIB_REPO := https://github.com/sysprog21/Kconfiglib
1616
$(KCONFIG_DIR)/kconfiglib.py:
1717
$(VECHO) "Downloading Kconfig tools...\n"
1818
$(Q)if [ -z "$(KCONFIG_DIR)" ]; then \
19-
echo "Error: KCONFIG_DIR is empty"; exit 1; \
19+
echo "Error: KCONFIG_DIR is empty"; exit 1; \
2020
fi
2121
$(Q)case "$(KCONFIG_DIR)" in \
22-
/*|..*) echo "Error: KCONFIG_DIR must be relative path under project"; exit 1 ;; \
22+
/*|..*) echo "Error: KCONFIG_DIR must be relative path under project"; exit 1 ;; \
2323
esac
2424
$(Q)if [ -d "$(KCONFIG_DIR)" ] && [ ! -f "$(KCONFIG_DIR)/kconfiglib.py" ]; then \
25-
echo "Removing incomplete Kconfig directory..."; \
26-
rm -rf "$(KCONFIG_DIR)"; \
25+
echo "Removing incomplete Kconfig directory..."; \
26+
rm -rf "$(KCONFIG_DIR)"; \
2727
fi
28-
$(Q)git clone --depth=1 -q $(KCONFIGLIB_REPO) $(KCONFIG_DIR)
28+
$(Q)git clone --depth=1 -q $(KCONFIGLIB_REPO) "$(KCONFIG_DIR)"
2929
@echo "Kconfig tools installed to $(KCONFIG_DIR)"
3030

3131
# Ensure all Kconfig tools exist
@@ -47,28 +47,28 @@ config: env-check $(KCONFIG_DIR)/menuconfig.py
4747
# Apply default configuration (supports CONFIG=name for named configs)
4848
defconfig: $(KCONFIG_DIR)/defconfig.py
4949
@if [ -n "$(CONFIG)" ]; then \
50-
if [ -f "configs/$(CONFIG)_defconfig" ]; then \
51-
echo "Applying configs/$(CONFIG)_defconfig..."; \
52-
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/$(CONFIG)_defconfig; \
53-
else \
54-
echo "Error: configs/$(CONFIG)_defconfig not found"; exit 1; \
55-
fi; \
50+
if [ -f "configs/$(CONFIG)_defconfig" ]; then \
51+
echo "Applying configs/$(CONFIG)_defconfig..."; \
52+
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/$(CONFIG)_defconfig; \
53+
else \
54+
echo "Error: configs/$(CONFIG)_defconfig not found"; exit 1; \
55+
fi; \
5656
else \
57-
echo "Applying default configuration..."; \
58-
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/defconfig; \
57+
echo "Applying default configuration..."; \
58+
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/defconfig; \
5959
fi
6060
@python3 $(KCONFIG_DIR)/genconfig.py --header-path $(CONFIG_HEADER) $(KCONFIG)
6161
@echo "Configuration applied."
6262

6363
# Pattern rule for named defconfigs (e.g., make jit_defconfig)
6464
%_defconfig: $(KCONFIG_DIR)/defconfig.py
6565
@if [ -f "configs/$*_defconfig" ]; then \
66-
echo "Applying configs/$*_defconfig..."; \
67-
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/$*_defconfig; \
68-
python3 $(KCONFIG_DIR)/genconfig.py --header-path $(CONFIG_HEADER) $(KCONFIG); \
69-
echo "Configuration applied."; \
66+
echo "Applying configs/$*_defconfig..."; \
67+
python3 $(KCONFIG_DIR)/defconfig.py --kconfig $(KCONFIG) configs/$*_defconfig; \
68+
python3 $(KCONFIG_DIR)/genconfig.py --header-path $(CONFIG_HEADER) $(KCONFIG); \
69+
echo "Configuration applied."; \
7070
else \
71-
echo "Error: configs/$*_defconfig not found"; exit 1; \
71+
echo "Error: configs/$*_defconfig not found"; exit 1; \
7272
fi
7373

7474
# Update configuration after Kconfig changes

mk/riscv-arch-test.mk

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ _MK_RISCV_ARCH_TEST_INCLUDED := 1
77

88
riscof-check:
99
$(Q)if [ "$(shell pip show riscof 2>&1 | head -n 1 | cut -d' ' -f1)" = "WARNING:" ]; then \
10-
$(PRINTF) "Run 'pip3 install -r requirements.txt' to install dependencies.\n"; \
11-
exit 1; \
10+
$(PRINTF) "Run 'pip3 install -r requirements.txt' to install dependencies.\n"; \
11+
exit 1; \
1212
fi
1313

1414
ARCH_TEST_DIR ?= tests/riscv-arch-test
@@ -42,23 +42,23 @@ ifeq ($(CROSS_COMPILE),)
4242
endif
4343
ifeq ($(SKIP_PREREQ),1)
4444
$(Q)test -x $(BIN) || \
45-
{ echo "Error: SKIP_PREREQ=1 requires pre-built binary. Run 'make' first."; exit 1; }
45+
{ echo "Error: SKIP_PREREQ=1 requires pre-built binary. Run 'make' first."; exit 1; }
4646
$(Q)test -x tests/arch-test-target/sail_cSim/riscv_sim_RV32 || \
47-
{ echo "Error: SKIP_PREREQ=1 requires pre-fetched sail binary. Run 'make artifact' first."; exit 1; }
47+
{ echo "Error: SKIP_PREREQ=1 requires pre-fetched sail binary. Run 'make artifact' first."; exit 1; }
4848
$(Q)test -d $(ARCH_TEST_DIR) || \
49-
{ echo "Error: SKIP_PREREQ=1 requires submodule. Run 'git submodule update --init tests/riscv-arch-test/' first."; exit 1; }
49+
{ echo "Error: SKIP_PREREQ=1 requires submodule. Run 'git submodule update --init tests/riscv-arch-test/' first."; exit 1; }
5050
else
51-
git submodule update --init $(dir $(ARCH_TEST_DIR))
51+
$(call ensure-submodule,tests/riscv-arch-test,https://github.com/riscv-non-isa/riscv-arch-test)
5252
$(Q)cp $(OUT)/rv32emu-prebuilt-sail-$(HOST_PLATFORM) tests/arch-test-target/sail_cSim/riscv_sim_RV32
5353
$(Q)chmod +x tests/arch-test-target/sail_cSim/riscv_sim_RV32
5454
endif
5555
$(Q)python3 -B $(RISCV_TARGET)/setup.py --riscv_device=$(RISCV_DEVICE) --hw_data_misaligned_support=$(hw_data_misaligned_support) --work_dir=$(WORK)
5656
$(Q)grep -q '^\[RISCOF\]' $(WORK)/config.ini || \
57-
{ echo "Error: config.ini missing RISCOF section. Contents:"; cat $(WORK)/config.ini; exit 1; }
57+
{ echo "Error: config.ini missing RISCOF section. Contents:"; cat $(WORK)/config.ini; exit 1; }
5858
$(Q)riscof run --no-clean --work-dir=$(WORK) \
59-
--config=$(WORK)/config.ini \
60-
--suite=$(ARCH_TEST_SUITE) \
61-
--env=$(ARCH_TEST_DIR)/riscv-test-suite/env
59+
--config=$(WORK)/config.ini \
60+
--suite=$(ARCH_TEST_SUITE) \
61+
--env=$(ARCH_TEST_DIR)/riscv-test-suite/env
6262

6363
.PHONY: riscof-check arch-test
6464

mk/softfloat.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ SOFTFLOAT_OBJS := $(addprefix $(OUT)/softfloat/, \
334334
SOFTFLOAT_SENTINEL := src/softfloat/.git
335335

336336
$(SOFTFLOAT_SENTINEL):
337-
$(Q)git submodule update --init $(dir $@)
337+
$(call ensure-submodule,src/softfloat,https://github.com/ucb-bar/berkeley-softfloat-3)
338338
SOFTFLOAT_DUMMY_PLAT := $(OUT)/softfloat/platform.h
339339
$(SOFTFLOAT_DUMMY_PLAT):
340340
$(Q)mkdir -p $(dir $@)

mk/system.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ compute_size = $(shell echo "obase=16; ibase=10; $(1)*$(MiB)" | bc)
1414
ifeq ($(CONFIG_SYSTEM),y)
1515

1616
CFLAGS += -Isrc/dtc/libfdt
17-
LIBFDT_HACK := $(shell git submodule update --init src/dtc 2>/dev/null)
17+
18+
# DTC dependency as proper target (not parse-time shell)
19+
DTC_SENTINEL := src/dtc/.git
20+
$(DTC_SENTINEL):
21+
$(call ensure-submodule,src/dtc,https://github.com/dgibson/dtc)
1822

1923
DEV_SRC := src/devices
2024
DEV_OUT := $(OUT)/devices
@@ -61,6 +65,9 @@ deps := $(DEV_OBJS:%.o=%.o.d)
6165
OBJS_EXT += system.o
6266
OBJS_EXT += dtc/libfdt/fdt.o dtc/libfdt/fdt_ro.o dtc/libfdt/fdt_rw.o dtc/libfdt/fdt_wip.o
6367

68+
# Ensure DTC is available before compiling libfdt objects
69+
$(addprefix $(OUT)/,$(filter dtc/%,$(OBJS_EXT))): $(DTC_SENTINEL)
70+
6471
# Memory Layout Configuration
6572

6673
# Memory configuration for kernel mode (ELF_LOADER=n)

0 commit comments

Comments
 (0)