Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 14 Aug 2011 12:21:24 +0300
changeset 928 05c1f958d465
parent 927 c43baeec3a0e
child 1030 9162afed7eda
permissions -rwxr-xr-x
Add 'help' target.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
# Proj dirs/files.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
RST_FILES := $(wildcard *.rst)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
TXT_FILES := $(wildcard *.txt)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
HTML_DIR := tips-html
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES)) $(HTML_DIR)/index.html $(HTML_DIR)/index-frame.html
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
TXT__FILES := $(addprefix $(HTML_DIR)/,$(TXT_FILES))
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    23
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
    24
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
DIRS := $(HTML_DIR)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
# Build targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    30
.PHONY: all
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    31
all:
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
.PHONY: html
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
html: $(HTML_FILES) $(TXT__FILES)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
905
93b983f80767 fix dependency.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 903
diff changeset
    36
$(HTML_DIR)/%.html: %.rst rst.css | $(HTML_DIR)
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
	rst2html.py --stylesheet=rst.css $*.rst $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
927
c43baeec3a0e Fix dependency.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 923
diff changeset
    39
$(HTML_DIR)/index.html: index.sh $(filter-out $(HTML_DIR)/index.html,$(HTML_FILES)) | $(HTML_DIR)
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    40
	./index.sh frame >$@
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    42
$(HTML_DIR)/%.html: %.html | $(HTML_DIR)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
	cp $< $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
$(HTML_DIR)/%.txt: %.txt | $(HTML_DIR)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
	cp $< $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    48
.PHONY: chm
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    49
chm: html $(CHM_FILES) $(HTML_DIR)/index-chm.html
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    50
	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
    51
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    52
$(HTML_DIR)/%.stp: %.stp | $(HTML_DIR)
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    53
	cp $< $@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    54
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    55
$(HTML_DIR)/chm.hhp: chm-hhp.sh | $(HTML_DIR)
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    56
	./chm-hhp.sh >$@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    57
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    58
$(HTML_DIR)/chm.hhc: chm-hhc.sh | $(HTML_DIR)
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    59
	./chm-hhc.sh >$@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    60
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    61
$(HTML_DIR)/index-chm.html: index.sh | $(HTML_DIR)
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    62
	./index.sh chm >$@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    63
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    64
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    65
# Init targets.
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
$(DIRS):
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    68
	mkdir -p $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    69
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    70
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    71
# Clean targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    72
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    73
.PHONY: distclean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    74
distclean: clean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    75
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    76
.PHONY: clean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    77
clean:
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    78
	rm -r -f $(DIRS)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    79
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    80
################################################################
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    81
# Helper target.
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    82
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    83
help:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    84
	@echo Supported targets:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    85
	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(MAKEFILE_LIST)
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    86
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
    87