Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 10 Feb 2018 01:36:16 +0200
changeset 2229 1a0b6597e594
parent 2188 e95731eef030
child 2574 ed399b8e9fca
permissions -rw-r--r--
Mark block quot in HTMLe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1438
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
     1
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
     2
################################################################
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
     3
# Standard GNU Makefile settings.
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
     4
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
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
     6
export PATH := /bin:/usr/bin:${PATH}
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
# Disable built in pattern rules.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
MAKEFLAGS += -r
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
# Disable built in variables.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
MAKEFLAGS += -R
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
# Disable built in suffix rules.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
.SUFFIXES:
1438
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
    14
# Delete target file if command fails.
a53df7bd6722 Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1367
diff changeset
    15
.DELETE_ON_ERROR:
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
# Default target.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
.DEFAULT_GOAL = all
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
################################################################
1030
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    20
# Platform definition.
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    21
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    22
host_os := linux
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    23
ifneq '' '$(WINDIR)'
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    24
  host_os := cygwin
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    25
endif
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    26
target_os := $(host_os)
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    27
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    28
################################################################
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    29
# Build tool definition/switches.
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    30
1110
6e71ffc71972 small fix
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1109
diff changeset
    31
RST2HTML := rst2html
1030
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    32
ifeq '$(host_os)' 'cygwin'
2188
e95731eef030 Fixed: NameError: name 'locale_encoding' is not defined
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2031
diff changeset
    33
  RST2HTML := LC_ALL=en_US.utf8 rst2html.py
1030
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    34
endif
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    35
1109
9885f6be80f0 Add warning flag for RST utils.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1103
diff changeset
    36
RST_WARNING_FLAGS := --halt warning
1917
d5967d76dae5 Set initial header level to <h2> explicitly because after removing
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1913
diff changeset
    37
RST_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=MathJax --initial-header-level=2
1901
12a7d89c74a9 Add template to generate HTML 5 compliant code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1898
diff changeset
    38
RST_FLAGS := $(RST_WARNING_FLAGS) $(RST_RENDER_FLAGS)
1109
9885f6be80f0 Add warning flag for RST utils.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1103
diff changeset
    39
1030
9162afed7eda Port to Debian.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 928
diff changeset
    40
################################################################
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
# Proj dirs/files.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    42
1912
8b81a8f0f692 Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1909
diff changeset
    43
RST_FILES := $(wildcard *.rst)
902
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 := tips-html
1077
509886d148b2 Split values.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1030
diff changeset
    46
RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES))
1103
53b2adcc631e Remove duplication.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1079
diff changeset
    47
HTML_FILES := $(RST_HTML_FILES) \
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
    48
        $(HTML_DIR)/index.html $(HTML_DIR)/iframe.html
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    50
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
    51
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    52
DIRS := $(HTML_DIR)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    53
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
################################################################
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    55
# Deploy targets.
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    56
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
    57
WWW_SRV_NAME := tips.defun.work
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    58
WWW_SRV_USER := user
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    59
HG_SRV_NAME := hg.defun.work
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    60
HG_SRV_USER := user
1902
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    61
LOCAL_DIR := /srv/www/tips
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    62
1343
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    63
ifneq '' '$(filter deploy%,$(MAKECMDGOALS))'
1912
8b81a8f0f692 Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1909
diff changeset
    64
  $(shell rm -f $(HTML_DIR)/rst.tmpl)
1343
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    65
endif
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    66
2012
542525cfb513 For SEO reason I removed tips from SF.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2003
diff changeset
    67
# For SEO reason I removed tips from SF.
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    68
.PHONY: deploy
2012
542525cfb513 For SEO reason I removed tips from SF.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2003
diff changeset
    69
deploy: deploy2defun-web deploy2defun-hg # deploy2sf-web deploy2sf-hg
1786
e96e62e31370 Deploy to defun.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1438
diff changeset
    70
2031
6f913ce241e3 Preserve Google and Bind verification pages on deploy.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2012
diff changeset
    71
RSYNC_FLAGS := --delete -avP -e ssh --exclude "google*.html" --exclude "BingSiteAuth.xml"
6f913ce241e3 Preserve Google and Bind verification pages on deploy.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2012
diff changeset
    72
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
    73
# Will be accessible via: http://tips.defun.work/
1786
e96e62e31370 Deploy to defun.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1438
diff changeset
    74
.PHONY: deploy2defun-web
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
    75
deploy2defun-web: www
2031
6f913ce241e3 Preserve Google and Bind verification pages on deploy.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2012
diff changeset
    76
	rsync $(RSYNC_FLAGS) $(HTML_DIR)/ $(WWW_SRV_USER)@$(WWW_SRV_NAME):/srv/www/tips/
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    77
1843
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    78
.PHONY: deploy2defun-hg
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    79
deploy2defun-hg:
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    80
	hg push ssh://$(HG_SRV_USER)@$(HG_SRV_NAME)//srv/hg/tips || [ $$? = 1 ]
1843
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    81
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
    82
# Will be accessible via: http://gavenkoa.users.sourceforge.net/tips-html/
1349
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    83
.PHONY: deploy2sf-web
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
    84
deploy2sf-web: www
2031
6f913ce241e3 Preserve Google and Bind verification pages on deploy.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2012
diff changeset
    85
	rsync $(RSYNC_FLAGS) $(HTML_DIR)/ gavenkoa@frs.sourceforge.net:/home/user-web/g/ga/gavenkoa/htdocs/tips-html/
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    86
1349
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    87
.PHONY: deploy2sf-hg
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    88
deploy2sf-hg:
1366
c57cd27e840e If 'hg' found no changes it report error code 1. Ignore them as it is valid.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1349
diff changeset
    89
	hg push ssh://gavenkoa@hg.code.sf.net/u/gavenkoa/tips || [ $$? = 1 ]
1349
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    90
1902
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    91
.PHONY: deploy2local
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    92
deploy2local: html
1925
f753d84e666e Use HTML_DIR variable instead of exact value.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1917
diff changeset
    93
	rsync --delete -avP $(HTML_DIR)/ $(LOCAL_DIR)
1902
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    94
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    95
################################################################
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    96
# Build targets.
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: all
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    99
all:
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   100
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   101
.PHONY: www
2003
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   102
www: html $(HTML_DIR)/sitemap.xml $(HTML_DIR)/robots.txt
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   103
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   104
.PHONY: html
1907
f4b078cbff20 TXT files no longer used.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1902
diff changeset
   105
html: $(HTML_FILES)
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   106
2001
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   107
$(HTML_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(HTML_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   108
	$(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(HTML_DIR)/rst.tmpl $*.rst $@
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   109
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   110
$(HTML_DIR)/iframe.html: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   111
	{ \
1898
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   112
echo '<html><head>'; \
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   113
echo '<meta charset="utf-8">'; \
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   114
echo '<style>'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   115
echo 'a { text-decoration: none; color: hsl(240, 100%, 50%); }'; \
1897
200fac373cf9 Highlight links on hover.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1893
diff changeset
   116
echo 'a:hover { opacity: .5; }'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   117
echo '</style></head><body>'; \
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   118
echo '<ul style="padding-left: 1em;">'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   119
for f in $(sort $(RST_FILES)); do \
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   120
  n=$${f%.rst}; \
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
   121
  printf '<li><a target="_parent" href="%s.html">%s</a></li>\n' $$n $$n; \
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   122
done; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   123
echo '</ul>'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   124
echo '</body></html>'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   125
} >$@
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   126
2003
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   127
$(HTML_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
1912
8b81a8f0f692 Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1909
diff changeset
   128
	sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|"  <$< >$@
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   129
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   130
$(HTML_DIR)/index.html: $(HTML_DIR)/README.html $(MAKEFILE_LIST) | $(HTML_DIR)
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   131
	cp $< $@
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   132
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   133
.PHONY: chm
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
   134
chm: html $(CHM_FILES) $(HTML_DIR)/iframe.html
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   135
	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
   136
2001
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   137
$(HTML_DIR)/%.stp: misc/%.stp $(MAKEFILE_LIST) | $(HTML_DIR)
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   138
	cp $< $@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   139
2001
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   140
$(HTML_DIR)/chm.hhp: misc/chm-hhp.sh $(MAKEFILE_LIST) | $(HTML_DIR)
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   141
	./$<  >$@
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   142
2001
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   143
$(HTML_DIR)/chm.hhc: misc/chm-hhc.sh $(MAKEFILE_LIST) | $(HTML_DIR)
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   144
	./$<  >$@
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   145
1908
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   146
.PHONY: single-html
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   147
single-html: $(HTML_DIR)/single.html
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   148
2001
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   149
$(HTML_DIR)/single.html: $(HTML_DIR)/single.rest www/rst.css www/rst-single.css $(RST_FILES)
4bebef342260 Move template files to separate directories.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2000
diff changeset
   150
	$(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-single.css $(HTML_DIR)/single.rest $@
1908
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   151
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   152
$(HTML_DIR)/single.rest: $(RST_FILES) $(MAKEFILE_LIST)
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   153
	{ \
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   154
echo ".. contents::"; \
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   155
echo "   :local:"; \
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   156
echo; \
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   157
for f in *.rst; do echo ".. include:: ../$$f"; done; \
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   158
} >$@
0260f8ffef35 Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1907
diff changeset
   159
2003
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   160
$(HTML_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
2000
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   161
	{ \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   162
echo '<?xml version="1.0" encoding="UTF-8"?>'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   163
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   164
for f in *.rst iframe; do \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   165
  echo '<url>'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   166
  echo "  <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   167
  echo '  <changefreq>weekly</changefreq>'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   168
  echo '</url>'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   169
done; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   170
echo '</urlset>'; \
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   171
} >$@
7bfe538a4cfe Generate sitemap.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1925
diff changeset
   172
2003
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   173
$(HTML_DIR)/robots.txt: www/robots.txt $(MAKEFILE_LIST) | $(HTML_DIR)
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   174
	cp $< $@
aa322acc9627 Add robots.txt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2001
diff changeset
   175
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   176
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   177
# Init targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   178
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   179
$(DIRS):
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   180
	mkdir -p $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   181
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   182
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   183
# Clean targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   184
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   185
.PHONY: distclean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   186
distclean: clean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   187
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   188
.PHONY: clean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   189
clean:
1912
8b81a8f0f692 Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1909
diff changeset
   190
	rm -r -f $(DIRS)
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   191
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   192
################################################################
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   193
# Helper target.
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   194
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   195
.PHONY: help
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   196
help:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   197
	@echo Supported targets:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   198
	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(MAKEFILE_LIST)
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   199
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   200
.PHONY: check-format-policy
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   201
check-format-policy:
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   202
	\
1909
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   203
for f in $(RST_FILES); do \
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   204
  if grep '^.. -\*- coding: utf-8; -\*-' $$f >/dev/null; then :; else \
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   205
    echo $$f:1:" Has no 'coding: utf-8' directive."; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   206
  fi; \
1909
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   207
  if grep '^.. contents::' $$f >/dev/null; then :; else \
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   208
    echo $$f:7:" Has no 'contents::' directive."; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   209
  fi; \
1909
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   210
  if grep '^   :local:' $$f >/dev/null; then :; else \
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   211
    echo $$f:7:" Has no ':local:' directive."; \
6b76120bd2d3 Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1908
diff changeset
   212
  fi; \
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   213
done
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   214