summaryrefslogtreecommitdiff
path: root/Makefile
blob: b906774f3d4065bd604cd0f39ff97542a0b17fa7 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# If no .config on main folder i have to create one
NONE := $(shell touch .config)
include .config

TOP_DIR         := $(CURDIR)
PATHS           :=

CONFIG_PATH     := $(CURDIR)
CONFIG_FILE     := .config
CONFIG          := $(CONFIG_PATH)/$(CONFIG_FILE)
DEPLOY_FOLDER	:= deploy
DEPLOY          := $(CONFIG_PATH)/$(DEPLOY_FOLDER)
HANDOUT_FOLDER	:= handouts
HANDOUT		:=$(DEPLOY)/$(HANDOUT_FOLDER)
CONFIG_FOLDER	:= configs

BUILD_COMMAND   := xelatex
BUILD_COMMAND_BIB := bibtex
BUILD_DEBUG	:= -halt-on-error --interaction=errorstopmode
BUILD_ARGS      :=
BUILD           := $(BUILD_COMMAND) $(BUILD_DEBUG) $(BUILD_ARGS)
BUILD_BIB	:= $(BUILD_COMMAND_BIB)

KCONFIG_PATH	:= ./kconfig-frontends/frontends
KCONFIG 	:= $(KCONFIG_PATH)/conf/conf
KMCONFIG	:= $(KCONFIG_PATH)/mconf/mconf

MASTER_PRES	:= tmp_master_pres
MASTER_HANDOUT	:= tmp_master_handout
MASTER_END	:= .tex

HANDOUT_PREFIX	:= handout_
PRES_PREFIX	:= pres_

# 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:
	mkdir -p $(HANDOUT)
	for dir in $(PATHS) ; do \
		($(MAKE) -C $$dir -f $(CURDIR)/modules.mk $@ >> log.txt); \
	done
ifdef CONFIG_BUILD_MASTER_PRES
	($(MAKE) -C ./ -f Makefile build_master_pres  >> log.txt);
endif
ifdef CONFIG_BUILD_MASTER_HANDOUT
	($(MAKE) -C ./ -f Makefile build_master_handout  >> log.txt);
endif

$(KMCONFIG):
	cd kconfig-frontends/ && ./configure && make
	
$(KCONFIG):
	cd kconfig-frontends/ && ./configure && make

menuconfig: $(KMCONFIG)
	$(KMCONFIG)  Kconfig

config: $(KCONFIG)
	$(KCONFIG) --oldaskconfig Kconfig

oldconfig: $(KCONFIG)
	cp $@ $(CONFIG_FILE)
	$(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 $@  >> 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

build_master_pres: clean_master_pres
	@echo "Build masterpres with: "$(obj-y)
	for dir in $(PATHS) ; do \
		($(MAKE) -C $$dir -f $(CURDIR)/modules.mk build_master_pres  >> log.txt); \
		($(MAKE) -C $$dir -f $(CURDIR)/modules.mk build_master_pres_end  >> log.txt); \
	done
	rm -rf pdf
	rm -f *.aux
	rm -f *.log
	rm -f *.nav
	rm -f *.toc
	rm -f *.pdf
	rm -f *.snm
	rm -f *.bbl
	rm -f *.blg
	rm -f *.out
	rm -f *.vrb

vorlesung::
	mv configpres.tex _configpres.tex
	touch configpres.tex
	mv tailpres.tex _tailpres.tex
	touch tailpres.tex
	pdflatex vorl1.tex
	pdflatex vorl1.tex
	pdflatex vorl2.tex
	pdflatex vorl2.tex
	pdflatex vorl3.tex
	pdflatex vorl3.tex
	pdflatex vorl.tex
	pdflatex vorl.tex
	rm configpres.tex tailpres.tex
	mv _configpres.tex configpres.tex
	mv _tailpres.tex tailpres.tex
	mv confighandout.tex _confighandout.tex
	touch confighandout.tex
	mv tailhandout.tex _tailhandout.tex
	touch tailhandout.tex
	TEXINPUTS=`pwd`/wise:.:$(TEXINPUTS) pdflatex handout.tex
	TEXINPUTS=`pwd`/wise:.:$(TEXINPUTS) pdflatex handout.tex
	rm confighandout.tex tailhandout.tex
	mv _confighandout.tex confighandout.tex
	mv _tailhandout.tex tailhandout.tex


pres::
	mv configpres.tex _configpres.tex
	touch configpres.tex
	mv tailpres.tex _tailpres.tex
	touch tailpres.tex
	pdflatex pres_master.tex
	bibtex pres_master.aux
	pdflatex pres_master.tex
	pdflatex pres_master.tex
	rm configpres.tex tailpres.tex
	mv _configpres.tex configpres.tex
	mv _tailpres.tex tailpres.tex
book::
	mv confighandout.tex _confighandout.tex
	touch confighandout.tex
	mv tailhandout.tex _tailhandout.tex
	touch tailhandout.tex
	TEXINPUTS=`pwd`/wise:.:$(TEXINPUTS) pdflatex handout_master.tex
	bibtex handout_master.tex
	TEXINPUTS=`pwd`/wise:.:$(TEXINPUTS) pdflatex handout_master.tex
	TEXINPUTS=`pwd`/wise:.:$(TEXINPUTS) pdflatex handout_master.tex
	rm confighandout.tailhandout.tex
	mv _confighandout.tex confighandout.tex
	mv _tailhandout.tex tailhandout.tex
pdf::
	rm -rf pdf
	mkdir -p pdf/pres
	mkdir -p pdf/handout
	mkdir -p pdf/hints
	find . -name pres_*.pdf | xargs cp -t pdf/pres
	find . -name hints_*.pdf | xargs cp -t pdf/hints
	find . -name handout_*.pdf | xargs cp -t pdf/handout
	cd pdf/pres && \
	pdfsam-console -o `pwd`/../pres.pdf -d `pwd` concat
	cd pdf/hints && \
	pdfsam-console -o `pwd`/../hints.pdf -d `pwd` concat
	cd pdf/handout && \
	pdfsam-console -o `pwd`/../handout.pdf -d `pwd` concat