summaryrefslogtreecommitdiff
path: root/Makefile
blob: 14357e80c7ed36e6914382433a202cdbc3530905 (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
I := include
B := build

MACROS := $(I)/m4/aple.m4
M4_ARGS := $(MACROS)
ifeq ($(findstring pub, $(MAKECMDGOALS)),)
	m4 := $(wildcard *.m4)
	M4_ARGS += -D PUBLIC=false
	DEST := $(B)/internal
else
	m4 := Introduction.m4 Unix_Concepts.m4 Networking.m4 LVM.m4 \
		Filesystems.m4 OS-Level_Virtualization.m4
	M4_ARGS += -D PUBLIC=true
	DEST := $(B)/public
endif

CSS := aple.css

html := $(m4:.m4=.html)
imgs := $(wildcard $(I)/imgs/*.svg)
files := $(html) $(CSS) index.html $(notdir $(imgs)) aple.ico
all: $(addprefix $(DEST)/, $(files))
pub: all

LN_CMD = ln -f $< $@

$(DEST):
	mkdir -p $@

# m4 -> html

MD_CMD = m4 $(M4_ARGS) $< | sed -e '1,/^<html lang="en">/d' \
	| markdown -f tables,links > $@

$(DEST)/Bash.html: Bash.m4 $(MACROS) | $(DEST)
	$(MD_CMD)
$(DEST)/Command_Line_Utilities.html: Command_Line_Utilities.m4 $(MACROS) | $(DEST)
	$(MD_CMD)
$(DEST)/Git.html: Git.m4 $(MACROS) | $(DEST)
	$(MD_CMD)
$(DEST)/Gridengine.html: Gridengine.m4 $(MACROS) | $(DEST)
	$(MD_CMD)

$(DEST)/%.html: %.m4 $(MACROS) | $(DEST)
	m4 $(M4_ARGS) $< > $@

# svg
$(DEST)/%.svg: $(I)/imgs/%.svg | $(DEST)
	$(LN_CMD)

$(DEST)/%.ico: $(I)/imgs/%.svg | $(DEST)
	 convert -level 0%,100%,0.1 $< $@

# style sheet
$(DEST)/$(CSS): $(I)/css/$(CSS) | $(DEST)
	$(LN_CMD)

# index.html
$(DEST)/index.html: $(DEST)/Introduction.html
	$(LN_CMD)

.PHONY: clean
clean:
	rm -rf $(B)
-include Makefile.local