Makefile
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:41:52 +0200
changeset 1903 901e7394849f
parent 1902 1dd434abf745
child 1907 f4b078cbff20
permissions -rw-r--r--
Decrease intent to increase space usage on mobile.
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'
1110
6e71ffc71972 small fix
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1109
diff changeset
    33
  RST2HTML := 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
1901
12a7d89c74a9 Add template to generate HTML 5 compliant code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1898
diff changeset
    37
RST_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=MathJax
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
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
    43
RST_FILES := $(filter-out HEADER.rst,$(wildcard *.rst))
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
TXT_FILES := $(wildcard *.txt)
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
HTML_DIR := tips-html
1077
509886d148b2 Split values.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1030
diff changeset
    47
RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES))
1103
53b2adcc631e Remove duplication.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1079
diff changeset
    48
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
    49
        $(HTML_DIR)/index.html $(HTML_DIR)/iframe.html
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
TXT__FILES := $(addprefix $(HTML_DIR)/,$(TXT_FILES))
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
    52
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
    53
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
DIRS := $(HTML_DIR)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    55
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    56
################################################################
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    57
# Deploy targets.
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    58
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    59
WWW_SRV_NAME := defun.work
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    60
WWW_SRV_USER := user
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    61
HG_SRV_NAME := hg.defun.work
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    62
HG_SRV_USER := user
1902
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    63
LOCAL_DIR := /srv/www/tips
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    64
1343
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    65
ifneq '' '$(filter deploy%,$(MAKECMDGOALS))'
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    66
  $(shell rm -f HEADER.rst)
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    67
endif
98bd3c148847 Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1341
diff changeset
    68
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    69
.PHONY: deploy
1843
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    70
deploy: deploy2defun-web deploy2defun-hg deploy2sf-web deploy2sf-hg
1786
e96e62e31370 Deploy to defun.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1438
diff changeset
    71
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
    72
# Will be accessible via: http://tips.defun.work/
1786
e96e62e31370 Deploy to defun.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1438
diff changeset
    73
.PHONY: deploy2defun-web
e96e62e31370 Deploy to defun.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1438
diff changeset
    74
deploy2defun-web: html
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    75
	rsync --delete -avP -e ssh tips-html/ $(WWW_SRV_USER)@$(WWW_SRV_NAME):/srv/www/tips/
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    76
1843
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    77
.PHONY: deploy2defun-hg
8ad4fe7443f2 Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1839
diff changeset
    78
deploy2defun-hg:
1883
2e2b67e76e55 Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1843
diff changeset
    79
	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
    80
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
    81
# 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
    82
.PHONY: deploy2sf-web
1367
b36747c6a74e Fix typo in target name.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1366
diff changeset
    83
deploy2sf-web: html
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    84
	rsync --delete -avP -e ssh tips-html/ gavenkoa@frs.sourceforge.net:/home/user-web/g/ga/gavenkoa/htdocs/tips-html/
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    85
1349
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    86
.PHONY: deploy2sf-hg
b4e60ae7e4bf Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1345
diff changeset
    87
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
    88
	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
    89
1902
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    90
.PHONY: deploy2local
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    91
deploy2local: html
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    92
	rsync --delete -avP tips-html/ $(LOCAL_DIR)
1dd434abf745 Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1901
diff changeset
    93
1296
6b365616ac9e Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1111
diff changeset
    94
################################################################
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    95
# Build targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    96
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    97
.PHONY: all
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    98
all:
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    99
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   100
.PHONY: html
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   101
html: $(HTML_FILES) $(TXT__FILES)
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   102
1901
12a7d89c74a9 Add template to generate HTML 5 compliant code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1898
diff changeset
   103
$(HTML_DIR)/%.html: %.rst HEADER.rst rst.css rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
12a7d89c74a9 Add template to generate HTML 5 compliant code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1898
diff changeset
   104
	$(RST2HTML) $(RST_FLAGS) --stylesheet=rst.css --template=rst.tmpl $*.rst $@
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   105
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   106
$(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
   107
	{ \
1898
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   108
echo '<html><head>'; \
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   109
echo '<meta charset="utf-8">'; \
2a18c31747dc set encoding for iframe navigation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1897
diff changeset
   110
echo '<style>'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   111
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
   112
echo 'a:hover { opacity: .5; }'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   113
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
   114
echo '<ul style="padding-left: 1em;">'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   115
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
   116
  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
   117
  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
   118
done; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   119
echo '</ul>'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   120
echo '</body></html>'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   121
} >$@
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   122
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   123
HEADER.rst: $(MAKEFILE_LIST)
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   124
	{ \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   125
echo '.. raw:: html'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   126
echo; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   127
echo '  <div id="sidebar"><iframe src="iframe.html"></iframe></div>'; \
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   128
echo; \
1341
e45ca3c87690 Fix links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1340
diff changeset
   129
echo '.. _About: README.html'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   130
echo '.. _`Contacts`: http://resume.defun.work/'; \
1839
248ed4d46099 Point to HTTP, as HTTPS uses in-house certificate.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1787
diff changeset
   131
echo '.. _`Oleksandr Gavenko`: http://resume.defun.work/'; \
248ed4d46099 Point to HTTP, as HTTPS uses in-house certificate.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1787
diff changeset
   132
echo '.. _`gavenkoa`: http://resume.defun.work/'; \
1337
2bd47e0a87fa Add About and Licence statements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   133
echo '.. _Licence: README.html#tips-licence'; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   134
echo; \
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   135
echo '.. container:: header'; \
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   136
echo; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   137
echo '  [ About_ | Licence_ | `Contacts`_ ]'; \
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   138
echo '.. container:: header small'; \
1338
4e268948ba99 Sign each document with author name and build info.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1337
diff changeset
   139
echo; \
1891
471406f3c69c Apply consistent color schema. Remove duplicated links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1890
diff changeset
   140
echo '  Written by Oleksandr Gavenko (AKA gavenkoa), compiled at ``'`date +%F`'`` from rev ``'`hg id -i`'``.'; \
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   141
} >$@
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   142
1889
265b8d0f6149 Generate UX friendly index.html with iframe to tips index.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1883
diff changeset
   143
$(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
   144
	cp $< $@
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   145
1111
e1a7f1896571 Add dependency on build script.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1110
diff changeset
   146
$(HTML_DIR)/%.html: %.html $(MAKEFILE_LIST) | $(HTML_DIR)
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   147
	cp $< $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   148
1111
e1a7f1896571 Add dependency on build script.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1110
diff changeset
   149
$(HTML_DIR)/%.txt: %.txt $(MAKEFILE_LIST) | $(HTML_DIR)
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   150
	cp $< $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   151
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   152
.PHONY: chm
1893
da0024f4f068 Remove frame based publishing, stick to iframe. Clean CHM code generation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1891
diff changeset
   153
chm: html $(CHM_FILES) $(HTML_DIR)/iframe.html
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   154
	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
   155
1111
e1a7f1896571 Add dependency on build script.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1110
diff changeset
   156
$(HTML_DIR)/%.stp: %.stp $(MAKEFILE_LIST) | $(HTML_DIR)
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   157
	cp $< $@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   158
1111
e1a7f1896571 Add dependency on build script.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1110
diff changeset
   159
$(HTML_DIR)/chm.hhp: chm-hhp.sh $(MAKEFILE_LIST) | $(HTML_DIR)
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   160
	./chm-hhp.sh >$@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   161
1111
e1a7f1896571 Add dependency on build script.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1110
diff changeset
   162
$(HTML_DIR)/chm.hhc: chm-hhc.sh $(MAKEFILE_LIST) | $(HTML_DIR)
903
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   163
	./chm-hhc.sh >$@
9ead7d97be34 Add chm output format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 902
diff changeset
   164
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   165
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   166
# Init targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   167
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   168
$(DIRS):
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   169
	mkdir -p $@
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   170
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   171
################################################################
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   172
# Clean targets.
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   173
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   174
.PHONY: distclean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   175
distclean: clean
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
.PHONY: clean
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   178
clean:
1334
9bf0d5a1f0cf Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1333
diff changeset
   179
	rm -r -f $(DIRS) HEADER.rst
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   180
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   181
################################################################
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   182
# Helper target.
902
034aeeb2a16d Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   183
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   184
.PHONY: help
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   185
help:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   186
	@echo Supported targets:
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   187
	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(MAKEFILE_LIST)
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   188
1345
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   189
.PHONY: check-format-policy
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   190
check-format-policy:
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   191
	\
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   192
for f in *.rst; do \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   193
  if grep '.. -\*- coding: utf-8; -\*-' $$f >/dev/null; then :; else \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   194
    echo $$f:1:" Has no 'coding: utf-8' directive."; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   195
  fi; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   196
  if grep '.. include:: HEADER.rst' $$f >/dev/null; then :; else \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   197
    echo $$f:2:" Has no 'include:: HEADER.rst' directive."; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   198
  fi; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   199
  if grep '.. contents::' $$f >/dev/null; then :; else \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   200
    echo $$f:7:" Has no 'contents::' directive."; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   201
  fi; \
a1dffeaaf6e4 Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1343
diff changeset
   202
done
928
05c1f958d465 Add 'help' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 927
diff changeset
   203