From c81df42f0b5b7734bbff9173361d24f98dd6f87b Mon Sep 17 00:00:00 2001 From: WHC Date: Mon, 5 Oct 2026 12:40:45 +0800 Subject: [PATCH] Fix -j race on libsashidown.a; cst-agent-update keeps the install prefix --- Makefile | 10 ++++++++-- scripts/bootstrap_linux.sh | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 45c638d..d340c53 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ TESTS = \ TEST_LIBS = -lm $(CURL_LIBS) $(PTHREAD_LIBS) -.PHONY: all clean check demo sashidown-lib cmake-gcc cmake-clang asan install uninstall +.PHONY: all clean check demo sashidown-lib FORCE cmake-gcc cmake-clang asan install uninstall all: sashidown-lib cst-agent @@ -116,9 +116,15 @@ cmake-clang: cmake -B build-clang -DCMAKE_C_COMPILER=clang -DCST_BUILD_TUI=ON cmake --build build-clang -sashidown-lib: +sashidown-lib: $(SD_DIR)/libsashidown.a + +# The sub-make decides whether the archive is stale; FORCE only makes sure it +# is asked, and -j builds wait for it before linking. +$(SD_DIR)/libsashidown.a: FORCE $(MAKE) -C $(SD_DIR) libsashidown.a +FORCE: + cst-agent: $(OBJ) $(SD_DIR)/libsashidown.a $(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(LDLIBS) diff --git a/scripts/bootstrap_linux.sh b/scripts/bootstrap_linux.sh index d29e9ff..f2b5ad9 100755 --- a/scripts/bootstrap_linux.sh +++ b/scripts/bootstrap_linux.sh @@ -99,6 +99,7 @@ main() { run_make install PREFIX="$prefix" >/dev/null cat >"$prefix/bin/cst-agent-update" <