Avoid stray '<!DOCTYPE>' text.
[aple.git] / Makefile
1 I := include
2 B := build
3
4 MACROS := $(I)/m4/aple.m4
5 M4_ARGS := $(MACROS)
6 ifeq ($(findstring pub, $(MAKECMDGOALS)),)
7 m4 := $(wildcard *.m4)
8 M4_ARGS += -D PUBLIC=false
9 DEST := $(B)/internal
10 else
11 m4 := Introduction.m4 Unix_Concepts.m4 Networking.m4 LVM.m4 \
12 Filesystems.m4 OS-Level_Virtualization.m4
13 M4_ARGS += -D PUBLIC=true
14 DEST := $(B)/public
15 endif
16
17 CSS := aple.css
18
19 html := $(m4:.m4=.html)
20 imgs := $(wildcard $(I)/imgs/*.svg)
21 files := $(html) $(CSS) index.html $(notdir $(imgs)) aple.ico
22 all: $(addprefix $(DEST)/, $(files))
23 pub: all
24
25 LN_CMD = ln -f $< $@
26
27 $(DEST):
28 mkdir -p $@
29
30 # m4 -> html
31
32 MD_CMD = m4 $(M4_ARGS) $< | sed -e '1,/^<html lang="en">/d' \
33 | markdown -f tables,links > $@
34
35 $(DEST)/Bash.html: Bash.m4 $(MACROS) | $(DEST)
36 $(MD_CMD)
37 $(DEST)/Command_Line_Utilities.html: Command_Line_Utilities.m4 $(MACROS) | $(DEST)
38 $(MD_CMD)
39 $(DEST)/Git.html: Git.m4 $(MACROS) | $(DEST)
40 $(MD_CMD)
41 $(DEST)/Gridengine.html: Gridengine.m4 $(MACROS) | $(DEST)
42 $(MD_CMD)
43
44 $(DEST)/%.html: %.m4 $(MACROS) | $(DEST)
45 m4 $(M4_ARGS) $< > $@
46
47 # svg
48 $(DEST)/%.svg: $(I)/imgs/%.svg | $(DEST)
49 $(LN_CMD)
50
51 $(DEST)/%.ico: $(I)/imgs/%.svg | $(DEST)
52 convert -level 0%,100%,0.1 $< $@
53
54 # style sheet
55 $(DEST)/$(CSS): $(I)/css/$(CSS) | $(DEST)
56 $(LN_CMD)
57
58 # index.html
59 $(DEST)/index.html: $(DEST)/Introduction.html
60 $(LN_CMD)
61
62 .PHONY: clean
63 clean:
64 rm -rf $(B)
65 -include Makefile.local