summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorHolger Dengler <dengler@linutronix.de>2018-04-18 15:05:30 +0200
committerHolger Dengler <dengler@linutronix.de>2018-04-18 15:13:02 +0200
commit062ef433f8690566a898e05fdd7c9af342c0d213 (patch)
treeb5d8d1d536126d1cedbd5e3e00789d8ddefea6d7 /Makefile
parent2299479ef5ff3b9c73a2da1b1152fdaa4d18dca3 (diff)
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 <dengler@linutronix.de>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile85
1 files changed, 52 insertions, 33 deletions
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