-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (43 loc) · 1.26 KB
/
Makefile
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
SUBDIRS := $(wildcard */.)
OUTPUT_DIR := output
# remove output directory from subdirs
SUBDIRS := $(filter-out $(OUTPUT_DIR)/.,$(SUBDIRS))
ifndef VERBOSE
MAKEFLAGS += --no-print-directory --silent -j
endif
.PHONY: all $(SUBDIRS) compile clean new
all: $(SUBDIRS)
$(OUTPUT_DIR):
mkdir -p $(OUTPUT_DIR)
$(SUBDIRS):
if [ $@ != $(OUTPUT_DIR) ]; then \
echo -e "Building \033[0;34m$@\033[0m"; \
cp template.typ $@; \
cp subdir.mak $@/Makefile; \
$(MAKE) -C $@ all; \
fi
compile: all $(OUTPUT_DIR)
for dir in $(SUBDIRS); do \
echo -e "Compiling \033[0;34m$$dir\033[0m"; \
$(MAKE) -C $$dir compile; \
done
clean:
for dir in $(SUBDIRS); do \
echo -e "Cleaning \033[0;34m$$dir\033[0m"; \
$(MAKE) -C $$dir clean; \
rm -rf $$dir/Makefile; \
rm -rf $$dir/template.typ; \
done
echo -e "Cleaning \033[0;34m$(OUTPUT_DIR)\033[0m"; \
rm -rf output
rm -rf *.pdf
new:
mkdir -p $(NAME)
mkdir -p $(NAME)/assets
echo "title: \"$(NAME)\"" > $(NAME)/metadata.yaml
echo "template: \"template.typ\"" >> $(NAME)/metadata.yaml
echo "# $(NAME)" > $(NAME)/$(NAME).md
echo "" >> $(NAME)/$(NAME).md
echo "Created new directory \`$(NAME)\` with \`$(NAME).md\` and \`metadata.yaml\`" >> $(NAME)/$(NAME).md
echo "" >> $(NAME)/$(NAME).md
echo "## done" >> $(NAME)/$(NAME).md