From de11624f42f982810ef9c2f4923e611274aace96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 14 Mar 2025 21:25:14 +0100 Subject: [PATCH] mk: Avoid broken rebuild if program --help fails Make will happily consider a target available if it's zero sized. When writing output files with shell redirections for commands that usually succeed we can apply the `|| rm $@` pattern. For commands where --help exits with failure we always rerun the recipe instead. --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 89ffaef66..646fb64fc 100644 --- a/Makefile +++ b/Makefile @@ -1038,7 +1038,7 @@ docs/source/generated: # some commands return an error and print the usage text to stderr define DOC_USAGE_STDERR -docs/source/generated/$(1): $(TARGETS) docs/source/generated +docs/source/generated/$(1): $(TARGETS) docs/source/generated FORCE -$(Q) ./$(PROGRAM_PREFIX)$(1) --help 2> $$@ endef DOCS_USAGE_STDERR := yosys-config yosys-filterlib @@ -1053,7 +1053,7 @@ $(foreach usage,$(DOCS_USAGE_STDERR),$(eval $(call DOC_USAGE_STDERR,$(usage)))) # others print to stdout define DOC_USAGE_STDOUT docs/source/generated/$(1): $(TARGETS) docs/source/generated - $(Q) ./$(PROGRAM_PREFIX)$(1) --help > $$@ + $(Q) ./$(PROGRAM_PREFIX)$(1) --help > $$@ || rm $$@ endef DOCS_USAGE_STDOUT := yosys yosys-smtbmc yosys-witness $(foreach usage,$(DOCS_USAGE_STDOUT),$(eval $(call DOC_USAGE_STDOUT,$(usage)))) @@ -1190,5 +1190,7 @@ echo-cxx: -include kernel/*.d -include techlibs/*/*.d +FORCE: + .PHONY: all top-all abc test install install-abc docs clean mrproper qtcreator coverage vcxsrc .PHONY: config-clean config-clang config-gcc config-gcc-static config-gprof config-sudo