1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# If no .config on main folder i have to create one
PHONY :=
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
DEPLOYHANDOUT := $(DEPLOY)/$(HANDOUT_FOLDER)
PRINTOUT_FOLDER := printouts
DEPLOYPRINTOUT := $(DEPLOY)/$(PRINTOUT_FOLDER)
DEFCONF_FOLDER := $(CURDIR)/configs
BUILD_COMMAND := latexmk
BUILD_SUBCMD := xelatex
BUILD_ARGS := -f -halt-on-error -$(BUILD_SUBCMD) -bibtex
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
PHONY += all
all: build
PHONY += build
build: check
ifdef CONFIG_BUILD_MICROCONSULT
$(Q)touch .lxformat_microconsult
else
$(Q)rm -f .lxformat_microconsult
endif
ifdef CONFIG_BUILD_HANDOUTS
$(Q)mkdir -p $(DEPLOYHANDOUT)
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) buildhandouts;)
endif
ifdef CONFIG_BUILD_PRINTOUTS
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) clean_texfiles;)
$(Q)touch .lxformat_print
$(Q)mkdir -p $(DEPLOYPRINTOUT)
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) buildprintouts;)
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) clean_texfiles;)
$(Q)rm -f .lxformat_print
endif
$(Q)rm -f .lxformat_print
$(Q)mkdir -p $(DEPLOY)
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) build;)
$(KMCONFIG):
cd kconfig-frontends/ && ./configure --enable-mconf && make
$(KCONFIG):
cd kconfig-frontends/ && ./configure && make
CHECK_COMMAND = $(shell command -v $(BUILD_COMMAND) 2> /dev/null)
CHECK_SUBCMD = $(shell command -v $(BUILD_SUBCMD) 2> /dev/null)
CHECK_FILES = $(shell find $(CURDIR) -name \*\.tex -exec grep -lP '\t' \{\} \;)
PHONY += check
check: ;
ifeq ($(CHECK_COMMAND),)
$(error install required tool: $(BUILD_COMMAND))
endif
ifeq ($(CHECK_SUBCMD),)
$(error install required tool: $(BUILD_SUBCMD))
endif
ifneq ($(CHECK_FILES),)
$(warning remove tabs from tex-files: $(CHECK_FILES))
endif
PHONY += menuconfig
menuconfig: $(KMCONFIG)
$(Q)$(KMCONFIG) Kconfig
PHONY += config
config: $(KCONFIG)
$(Q)$(KCONFIG) --oldaskconfig Kconfig
PHONY += oldconfig
oldconfig: $(KCONFIG)
$(Q)cp $@ $(CONFIG_FILE)
$(Q)$(KCONFIG) --oldconfig Kconfig
PHONY += clean
clean:
$(Q)$(foreach dir,$(PATHS),$(MODMK) -C $(dir) $@_texfiles;)
$(Q)rm -rf $(DEPLOY_FOLDER) .lxformat_print
PHONY += mrproper
mrproper: clean
$(Q)echo [CLEAN] $@
$(Q)rm -f $(CONFIG)
$(Q)rm -f $(CONFIG_OLD)
$(MAKE) -C kconfig-frontends clean
PHONY += distclean
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: $(PHONY)
|