# If no .config on main folder i have to create one 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) HANDOUT_FOLDER := handouts HANDOUT :=$(DEPLOY)/$(HANDOUT_FOLDER) DEFCONF_FOLDER := $(CURDIR)/configs 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 | \ grep -v ./.git | \ grep -v ./kernel-devel/module-basics/vain | \ grep -v ./kernel-devel/module-basics/vain_pci | \ grep -v ./kernel-devel/module-basics/vain_plat | \ grep -v ./examples # Search for all folders with Makfile MAKE_FILES = $(shell find . -mindepth 2 -name Makefile | $(EXCLUDE_PATH)) PATHS = $(dir $(MAKE_FILES)) export build: $(BUILD_REQ) $(Q)mkdir -p $(HANDOUT) $(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) $@;) $(KMCONFIG): cd kconfig-frontends/ && ./configure && make $(KCONFIG): cd kconfig-frontends/ && ./configure && make menuconfig: $(KMCONFIG) $(Q)$(KMCONFIG) Kconfig config: $(KCONFIG) $(Q)$(KCONFIG) --oldaskconfig Kconfig oldconfig: $(KCONFIG) $(Q)cp $@ $(CONFIG_FILE) $(Q)$(KCONFIG) --oldconfig Kconfig clean: $(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) $(Q)cp $(DEFCONF_FOLDER)/$@ $(CONFIG_FILE) $(Q)$(KCONFIG) --oldconfig Kconfig .PHONY: config oldconfig menuconfig build clean mrproper distclean