Initial commit.
[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) $< | markdown -f tables,links > $@
33
34 $(DEST)/Bash.html: Bash.m4 $(MACROS) | $(DEST)
35         $(MD_CMD)
36 $(DEST)/Command_Line_Utilities.html: Command_Line_Utilities.m4 $(MACROS) | $(DEST)
37         $(MD_CMD)
38 $(DEST)/Git.html: Git.m4 $(MACROS) | $(DEST)
39         $(MD_CMD)
40 $(DEST)/Gridengine.html: Gridengine.m4 $(MACROS) | $(DEST)
41         $(MD_CMD)
42
43 $(DEST)/%.html: %.m4 $(MACROS) | $(DEST)
44         m4 $(M4_ARGS) $< > $@
45
46 # svg
47 $(DEST)/%.svg: $(I)/imgs/%.svg | $(DEST)
48         $(LN_CMD)
49
50 $(DEST)/%.ico: $(I)/imgs/%.svg | $(DEST)
51          convert -level 0%,100%,0.1 $< $@
52
53 # style sheet
54 $(DEST)/$(CSS): $(I)/css/$(CSS) | $(DEST)
55         $(LN_CMD)
56
57 # index.html
58 $(DEST)/index.html: $(DEST)/Introduction.html
59         $(LN_CMD)
60
61 .PHONY: clean
62 clean:
63         rm -rf $(B)
64 -include Makefile.local