Skip to content

Commit 993be97

Browse files
committed
Implement better support for --silent flag in top-level Makefile
The extra information printed when using the top-level makefile can clutter the output when it needs to be further processed, e.g. when running `make show-info | jq`. Make it respect the --silent flag (which also suppresses messages about changing directories which would break parsing as well). will be ignored, and an empty message aborts the commit.
1 parent 0e3fd2c commit 993be97

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ endif
1616

1717
################################################################################
1818

19+
SILENT := $(findstring s,$(word 1, $(MAKEFLAGS)))
20+
21+
define print
22+
$(if $(SILENT),,$(info $1))
23+
endef
24+
1925
COLOR_STEP := $(shell tput smso 2>/dev/null)
2026
COLOR_WARN := $(shell (tput setab 3; tput setaf 0) 2>/dev/null)
2127
TERM_RESET := $(shell tput sgr0 2>/dev/null)
@@ -28,7 +34,7 @@ TERM_RESET := $(shell tput sgr0 2>/dev/null)
2834

2935
# fallback target when target undefined here is given
3036
.DEFAULT:
31-
@echo "$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET)"
37+
$(call print,$(COLOR_STEP)=== Falling back to Buildroot target '$@' ===$(TERM_RESET))
3238
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$@"
3339

3440
# default target when no target is given - must be first in Makefile
@@ -42,11 +48,11 @@ $(TARGETS_CONFIG): %-config:
4248
echo ""; \
4349
bash -c 'read -t 10 -p "Waiting 10s, press enter to continue or Ctrl-C to abort..."' || true; \
4450
fi
45-
@echo "$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET)"
51+
$(call print,$(COLOR_STEP)=== Using $*_defconfig ===$(TERM_RESET))
4652
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$*_defconfig"
4753

4854
$(TARGETS): %: %-config
49-
@echo "$(COLOR_STEP)=== Building $@ ===$(TERM_RESET)"
55+
$(call print,$(COLOR_STEP)=== Building $@ ===$(TERM_RESET))
5056
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL)
5157

5258
buildroot-help:

0 commit comments

Comments
 (0)