From 062ef433f8690566a898e05fdd7c9af342c0d213 Mon Sep 17 00:00:00 2001 From: Holger Dengler Date: Wed, 18 Apr 2018 15:05:30 +0200 Subject: build: cleanup build processing Cleanup build processing: - support quiet and verbose build output (V=0, 1, or 2) - cleanup clean targets - replace for-loops with foreach statements The build process now supports 3 levels of verbosity. Default (V=0) provides very little output of the latex tooling, V=1 adds the full output of the latex tooling and V=2 adds output of the make tooling. Signed-off-by: Holger Dengler --- Makefile | 85 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 33 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5ca3319..290c142 100644 --- a/Makefile +++ b/Makefile @@ -2,27 +2,53 @@ NONE := $(shell touch .config) include .config +# Verbose build output: +# V=0: minimal output +# V=1: verbose output from latex tools (like latexmk) +# V=2: verbose output from all commands and make as well +ifeq ("$(origin V)", "command line") + BUILD_VERBOSE = $(V) +endif +ifndef BUILD_VERBOSE +BUILD_VERBOSE = 0 +endif +ifeq ($(BUILD_VERBOSE),2) +Q = +else +Q = @ +endif + TOP_DIR := $(CURDIR) PATHS := CONFIG_PATH := $(CURDIR) CONFIG_FILE := .config CONFIG := $(CONFIG_PATH)/$(CONFIG_FILE) +CONFIG_OLD := $(CONFIG).old DEPLOY_FOLDER := deploy -DEPLOY := $(CONFIG_PATH)/$(DEPLOY_FOLDER) +DEPLOY := $(CONFIG_PATH)/$(DEPLOY_FOLDER) HANDOUT_FOLDER := handouts HANDOUT :=$(DEPLOY)/$(HANDOUT_FOLDER) -CONFIG_FOLDER := configs +DEFCONF_FOLDER := $(CURDIR)/configs -BUILD_COMMAND := latexmk -xelatex -bibtex -pdf -BUILD_DEBUG := -halt-on-error --interaction=errorstopmode -BUILD_ARGS := -BUILD := $(BUILD_COMMAND) $(BUILD_DEBUG) $(BUILD_ARGS) +BUILD_COMMAND := latexmk +BUILD_ARGS := -f -halt-on-error -xelatex -bibtex -pdf +ifeq ($(BUILD_VERBOSE),0) +BUILD_ARGS += --interaction=batchmode -silent +else +BUILD_ARGS += --interaction=errorstopmode -verbose +endif +BUILD := $(BUILD_COMMAND) $(BUILD_ARGS) KCONFIG_PATH := ./kconfig-frontends/frontends KCONFIG := $(KCONFIG_PATH)/conf/conf KMCONFIG := $(KCONFIG_PATH)/mconf/mconf +MODMK = $(MAKE) -f $(TOP_DIR)/modules.mk +ifneq ($(BUILD_VERBOSE),2) +MODMK += --quiet +endif + # Folder that should not include to build paths EXCLUDE_PATH := \ grep -v ./kconfig-frontends | \ @@ -38,11 +64,9 @@ PATHS = $(dir $(MAKE_FILES)) export -build: - mkdir -p $(HANDOUT) - for dir in $(PATHS) ; do \ - ($(MAKE) -C $$dir -f $(CURDIR)/modules.mk $@ >> log.txt); \ - done +build: $(BUILD_REQ) + $(Q)mkdir -p $(HANDOUT) + $(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) $@;) $(KMCONFIG): cd kconfig-frontends/ && ./configure && make @@ -51,35 +75,30 @@ $(KCONFIG): cd kconfig-frontends/ && ./configure && make menuconfig: $(KMCONFIG) - $(KMCONFIG) Kconfig + $(Q)$(KMCONFIG) Kconfig config: $(KCONFIG) - $(KCONFIG) --oldaskconfig Kconfig + $(Q)$(KCONFIG) --oldaskconfig Kconfig oldconfig: $(KCONFIG) - cp $@ $(CONFIG_FILE) - $(KCONFIG) --oldconfig Kconfig + $(Q)cp $@ $(CONFIG_FILE) + $(Q)$(KCONFIG) --oldconfig Kconfig clean: - @echo "Cleaning" - rm -rf $(DEPLOY_FOLDER) - find -name "tmp*" -exec rm -f {} \; - for dir in $(PATHS) ; do \ - ($(MAKE) -C $$dir -f $(CURDIR)/modules.mk $@_texfiles >> log.txt); \ - done - -mrproper distclean: - @echo "distclean" - rm -f $(CONFIG_FILE) - rm -f $(CONFIG_FILE).old - rm -rf $(DEPLOY_FOLDER) - find -name "tmp*" -exec rm -f {} \; - for dir in $(PATHS) ; do \ - ($(MAKE) -C $$dir -f $(CURDIR)/modules.mk clean >> log.txt); \ - done + $(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) $@_texfiles;) + $(Q)rm -rf $(DEPLOY_FOLDER) + +mrproper: clean + $(Q)echo [CLEAN] $@ + $(Q)rm -f $(CONFIG) + $(Q)rm -f $(CONFIG_OLD) + +distclean: mrproper + $(Q)echo [CLEAN] $@ + $(Q)find -name "tmp*" -exec rm -f {} \; %_defconfig: $(KCONFIG) - cp $(CONFIG_FOLDER)/$@ $(CONFIG_FILE) - $(KCONFIG) --oldconfig Kconfig + $(Q)cp $(DEFCONF_FOLDER)/$@ $(CONFIG_FILE) + $(Q)$(KCONFIG) --oldconfig Kconfig .PHONY: config oldconfig menuconfig build clean mrproper distclean -- cgit v1.2.3