author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Fri, 04 Nov 2011 16:12:20 +0200 | |
changeset 1079 | ef0805397b5b |
parent 1077 | 509886d148b2 |
child 1103 | 53b2adcc631e |
permissions | -rw-r--r-- |
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
SHELL = /bin/sh |
923
f3b193a0e566
Add work-around for PATH. Under Windows find.exe going in collision with
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
905
diff
changeset
|
2 |
export PATH := /bin:/usr/bin:${PATH} |
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
# Disable built in pattern rules. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
MAKEFLAGS += -r |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
# Disable built in variables. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
MAKEFLAGS += -R |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
# Disable built in suffix rules. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
.SUFFIXES: |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
# Default target. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
.DEFAULT_GOAL = all |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
################################################################ |
1030 | 14 |
# Platform definition. |
15 |
||
16 |
host_os := linux |
|
17 |
ifneq '' '$(WINDIR)' |
|
18 |
host_os := cygwin |
|
19 |
endif |
|
20 |
target_os := $(host_os) |
|
21 |
||
22 |
################################################################ |
|
23 |
# Build tool definition/switches. |
|
24 |
||
25 |
RST2HTML = rst2html |
|
26 |
ifeq '$(host_os)' 'cygwin' |
|
27 |
RST2HTML = rst2html.py |
|
28 |
endif |
|
29 |
||
30 |
################################################################ |
|
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
# Proj dirs/files. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
RST_FILES := $(wildcard *.rst) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
TXT_FILES := $(wildcard *.txt) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
HTML_DIR := tips-html |
1077 | 37 |
RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES)) |
1079
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
38 |
HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES)) \ |
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
39 |
$(HTML_DIR)/index.html $(HTML_DIR)/frame.html $(HTML_DIR)/frame-index.html |
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
40 |
TXT__FILES := $(addprefix $(HTML_DIR)/,$(TXT_FILES)) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
|
903
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
42 |
CHM_FILES := $(addprefix $(HTML_DIR)/,chm.hhp chm.hhc chm.stp) |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
43 |
|
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
44 |
DIRS := $(HTML_DIR) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
45 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
46 |
################################################################ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
47 |
# Build targets. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
48 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
49 |
.PHONY: all |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
50 |
all: |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
51 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
52 |
.PHONY: html |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
53 |
html: $(HTML_FILES) $(TXT__FILES) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
54 |
|
905 | 55 |
$(HTML_DIR)/%.html: %.rst rst.css | $(HTML_DIR) |
1030 | 56 |
$(RST2HTML) --stylesheet=rst.css $*.rst $@ |
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
57 |
|
1079
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
58 |
$(HTML_DIR)/frame-index.html: index.sh $(RST_HTML_FILES) | $(HTML_DIR) |
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
59 |
./index.sh frame >$@ |
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
60 |
|
1077 | 61 |
$(HTML_DIR)/index.html: index.sh $(RST_HTML_FILES) | $(HTML_DIR) |
1079
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
62 |
./index.sh html >$@ |
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
63 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
64 |
$(HTML_DIR)/%.html: %.html | $(HTML_DIR) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
65 |
cp $< $@ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
66 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
67 |
$(HTML_DIR)/%.txt: %.txt | $(HTML_DIR) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
68 |
cp $< $@ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
69 |
|
903
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
70 |
.PHONY: chm |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
71 |
chm: html $(CHM_FILES) $(HTML_DIR)/index-chm.html |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
72 |
cd $(HTML_DIR); for file in *.html; do sed -i '/<\?xml.*\?>/d' $$file; done |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
73 |
|
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
74 |
$(HTML_DIR)/%.stp: %.stp | $(HTML_DIR) |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
75 |
cp $< $@ |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
76 |
|
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
77 |
$(HTML_DIR)/chm.hhp: chm-hhp.sh | $(HTML_DIR) |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
78 |
./chm-hhp.sh >$@ |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
79 |
|
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
80 |
$(HTML_DIR)/chm.hhc: chm-hhc.sh | $(HTML_DIR) |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
81 |
./chm-hhc.sh >$@ |
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
82 |
|
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
83 |
$(HTML_DIR)/index-chm.html: index.sh | $(HTML_DIR) |
1079
ef0805397b5b
Generate index.html without "target=article" so links open in current browser tab.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1077
diff
changeset
|
84 |
./index.sh html >$@ |
903
9ead7d97be34
Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
902
diff
changeset
|
85 |
|
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
86 |
################################################################ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
87 |
# Init targets. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
88 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
89 |
$(DIRS): |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
90 |
mkdir -p $@ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
91 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
92 |
################################################################ |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
93 |
# Clean targets. |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
94 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
95 |
.PHONY: distclean |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
96 |
distclean: clean |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
97 |
|
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
98 |
.PHONY: clean |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
99 |
clean: |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
100 |
rm -r -f $(DIRS) |
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
101 |
|
928 | 102 |
################################################################ |
103 |
# Helper target. |
|
902
034aeeb2a16d
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
104 |
|
928 | 105 |
help: |
106 |
@echo Supported targets: |
|
107 |
@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*= \1=;p;}' $(MAKEFILE_LIST) |
|
108 |
||
109 |