Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 17 Aug 2011 21:14:54 +0300
changeset 6 24914893fd3c
parent 5 3fce7236e888
child 7 6a41484fd3a4
permissions -rw-r--r--
change mode to 644

SHELL = /bin/sh
export PATH := /bin:/usr/bin:${PATH}

# Disable built in pattern rules.
MAKEFLAGS += -r
# Disable built in variables.
MAKEFLAGS += -R
# Disable built in suffix rules.
.SUFFIXES:
# Default target.
.DEFAULT_GOAL = all

################################################################
# Proj dirs/files.

RST_FILES := $(wildcard *.rst)
TXT_FILES := $(wildcard *.txt)

HTML_DIR := tips-html
HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES)) $(HTML_DIR)/index.html $(HTML_DIR)/index-frame.html
TXT__FILES := $(addprefix $(HTML_DIR)/,$(TXT_FILES))

CHM_FILES := $(addprefix $(HTML_DIR)/,chm.hhp chm.hhc chm.stp)

DIRS := $(HTML_DIR)

################################################################
# Build targets.

.PHONY: all
all:

.PHONY: html
html: $(HTML_FILES) $(TXT__FILES)

$(HTML_DIR)/%.html: %.rst rst.css | $(HTML_DIR)
	rst2html.py --stylesheet=rst.css $*.rst $@

$(HTML_DIR)/index.html: index.sh $(filter-out $(HTML_DIR)/index.html,$(HTML_FILES)) | $(HTML_DIR)
	./index.sh frame >$@

$(HTML_DIR)/%.html: %.html | $(HTML_DIR)
	cp $< $@

$(HTML_DIR)/%.txt: %.txt | $(HTML_DIR)
	cp $< $@

.PHONY: chm
chm: html $(CHM_FILES) $(HTML_DIR)/index-chm.html
	cd $(HTML_DIR); for file in *.html; do sed -i '/<\?xml.*\?>/d' $$file; done

$(HTML_DIR)/%.stp: %.stp | $(HTML_DIR)
	cp $< $@

$(HTML_DIR)/chm.hhp: chm-hhp.sh | $(HTML_DIR)
	./chm-hhp.sh >$@

$(HTML_DIR)/chm.hhc: chm-hhc.sh | $(HTML_DIR)
	./chm-hhc.sh >$@

$(HTML_DIR)/index-chm.html: index.sh | $(HTML_DIR)
	./index.sh chm >$@

################################################################
# Init targets.

$(DIRS):
	mkdir -p $@

################################################################
# Clean targets.

.PHONY: distclean
distclean: clean

.PHONY: clean
clean:
	rm -r -f $(DIRS)

################################################################
# Helper target.

help:
	@echo Supported targets:
	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(MAKEFILE_LIST)