fix(make): detect cmd.exe shell for native Windows ABE builds (#642)

* fix(make): detect cmd.exe shell for native Windows ABE builds
* Fix build command syntax in Makefile for Windows
This commit is contained in:
Daniel Uptain authored and GitHub committed 2026-09-25 13:42:16 +08:00
1 parent 0503d04d7a
commit 3b83bc7e3a
2 files changed
+21 -5

No files matched your search

+15 -2
View File
@@ -20,11 +20,24 @@ ABE_HDRS = $(ABE_SRC_DIR)/com_iid.h \
$(ABE_SRC_DIR)/bootstrap.h \
$(ABE_SRC_DIR)/bootstrap_layout.h
# Detect cmd.exe vs POSIX sh. OS=Windows_NT is set under MSYS2/Git Bash too,
# but those use sh — so shell detection is what matters for recipe syntax.
# cmd echoes the quotes back; POSIX sh strips them.
ifeq ($(shell echo "x"),"x")
WIN_CMD_SHELL := 1
endif
ifdef WIN_CMD_SHELL
ABE_REPORT_CMD = for %%I in ("$@") do @echo built $@ (%%~zI bytes)
else
ABE_REPORT_CMD = printf "built %s (%s bytes)\n" "$@" "$$(wc -c < $@ | tr -d ' ')"
endif
# crypto/windows/payload/ is tracked in git, so no mkdir is required.
$(ABE_BIN): $(ABE_C_SRCS) $(ABE_HDRS)
@mkdir -p $(ABE_BIN_DIR)
$(ZIG) cc -target $(ABE_TARGET) $(ABE_CFLAGS) $(ABE_LDFLAGS) \
$(ABE_C_SRCS) -o $@ $(ABE_LDLIBS)
@printf "built %s (%s bytes)\n" "$@" "$$(wc -c < $@ | tr -d ' ')"
@$(ABE_REPORT_CMD)
.PHONY: payload payload-verify payload-clean