scst: Move build mode updates into recipes

Do not update the build_mode file while make is only expanding the
recipe, since that also happens for dry runs. Run the update as the
recipe itself so write failures are reported to the caller.
This commit is contained in:
Gleb Chesnokov
2026-08-21 19:58:59 +03:00
parent f30bf2b208
commit 1a7c0c9b3c
+12 -13
View File
@@ -24,12 +24,14 @@ SCST_DIR=src
# Set variable $(2) to value $(3) in file $(1) if $(2)=$(3) does not yet occur
# in file $(1).
set_var = $(shell if grep -q '^$(2)=' '$(1)' 2>/dev/null; then \
grep -q '^$(2)=$(3)$$' '$(1)' || \
sed -i 's/^$(2)=.*/$(2)=$(3)/' '$(1)'; \
else \
echo '$(2)=$(3)' >> '$(1)'; \
fi)
define set_var
if grep -q '^$(2)=' '$(1)' 2>/dev/null; then \
grep -q '^$(2)=$(3)$$' '$(1)' || \
sed -i 's/^$(2)=.*/$(2)=$(3)/' '$(1)'; \
else \
echo '$(2)=$(3)' >> '$(1)'; \
fi
endef
all: include/build_mode.h
cd $(SCST_DIR) && $(MAKE) $@
@@ -48,23 +50,20 @@ extraclean:
cd $(SCST_DIR) && $(MAKE) $@
2debug:
$(call set_var,build_mode,BUILD_MODE,)
@true
@$(call set_var,build_mode,BUILD_MODE,)
2release:
$(call set_var,build_mode,BUILD_MODE,RELEASE)
@true
@$(call set_var,build_mode,BUILD_MODE,RELEASE)
2perf:
$(call set_var,build_mode,BUILD_MODE,PERF)
@true
@$(call set_var,build_mode,BUILD_MODE,PERF)
release-archive:
../scripts/generate-release-archive scst \
"$$(sed -n 's/^#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^\"]*\)\".*/\1/p' include/scst_const.h)"
build_mode:
$(call set_var,build_mode,BUILD_MODE,)
@$(call set_var,build_mode,BUILD_MODE,)
include/build_mode.h: build_mode
@rm -f $@.tmp; \