author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 09 May 2023 16:49:07 +0300 | |
changeset 91 | cbb01f06b349 |
parent 88 | dcb712a32f02 |
permissions | -rw-r--r-- |
44
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
1 |
|
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
2 |
################################################################ |
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
3 |
# Standard GNU Makefile settings. |
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
4 |
|
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
SHELL = /bin/sh |
3
194bc8d6504a
Add work-around for PATH. Under Windows find.exe going in collision with
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2
diff
changeset
|
6 |
export PATH := /bin:/usr/bin:${PATH} |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
# Disable built in pattern rules. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
MAKEFLAGS += -r |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
# Disable built in variables. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
MAKEFLAGS += -R |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
# Disable built in suffix rules. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
.SUFFIXES: |
44
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
14 |
# Delete target file if command fails. |
e7fc05196363
Delete target file if command fails.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
40
diff
changeset
|
15 |
.DELETE_ON_ERROR: |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
# Default target. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
.DEFAULT_GOAL = all |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
################################################################ |
7 | 20 |
# Platform definition. |
21 |
||
22 |
host_os := linux |
|
23 |
ifneq '' '$(WINDIR)' |
|
24 |
host_os := cygwin |
|
25 |
endif |
|
26 |
target_os := $(host_os) |
|
27 |
||
28 |
################################################################ |
|
29 |
# Build tool definition/switches. |
|
30 |
||
12 | 31 |
RST2HTML := rst2html |
7 | 32 |
ifeq '$(host_os)' 'cygwin' |
12 | 33 |
RST2HTML := rst2html.py |
7 | 34 |
endif |
35 |
||
11
00d3a2f1f32b
Add warning flag for RST utils.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
10
diff
changeset
|
36 |
RST_WARNING_FLAGS := --halt warning |
76
2100455aae72
Set initial header level to <h2> explicitly because after removing
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
75
diff
changeset
|
37 |
RST_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=MathJax --initial-header-level=2 |
68
46721724e2a3
Add template to generate HTML 5 compliant code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
67
diff
changeset
|
38 |
RST_FLAGS := $(RST_WARNING_FLAGS) $(RST_RENDER_FLAGS) |
11
00d3a2f1f32b
Add warning flag for RST utils.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
10
diff
changeset
|
39 |
|
7 | 40 |
################################################################ |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
# Proj dirs/files. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
42 |
|
88
dcb712a32f02
Build to 'dist' directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
86
diff
changeset
|
43 |
BUILD_DIR := dist |
86 | 44 |
SITE_DIR := $(BUILD_DIR)/site |
45 |
||
74
69323ee4fd3a
Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
73
diff
changeset
|
46 |
RST_FILES := $(wildcard *.rst) |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
47 |
|
86 | 48 |
RST_HTML_FILES := $(patsubst %.rst,$(SITE_DIR)/%.html,$(RST_FILES)) |
83
41a9c64f3fb7
Clean up after moving cooking.rst from tips project. Remove iframe, fix build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
82
diff
changeset
|
49 |
HTML_FILES := $(RST_HTML_FILES) |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
50 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
51 |
################################################################ |
14
a36529d7dc2b
Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
52 |
# Deploy targets. |
a36529d7dc2b
Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
53 |
|
86 | 54 |
WWW_SRV_NAME := cooking.defun.work |
61
cba303c0ad38
Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
60
diff
changeset
|
55 |
WWW_SRV_USER := user |
cba303c0ad38
Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
60
diff
changeset
|
56 |
HG_SRV_NAME := hg.defun.work |
cba303c0ad38
Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
60
diff
changeset
|
57 |
HG_SRV_USER := user |
86 | 58 |
LOCAL_DIR := /srv/www/cooking |
61
cba303c0ad38
Allow customising connection settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
60
diff
changeset
|
59 |
|
22
a2914ae81c6d
Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
60 |
ifneq '' '$(filter deploy%,$(MAKECMDGOALS))' |
86 | 61 |
$(shell rm -f $(BUILD_DIR)/rst.tmpl) |
22
a2914ae81c6d
Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
62 |
endif |
a2914ae81c6d
Update build info for deploy targets.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
63 |
|
14
a36529d7dc2b
Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
64 |
.PHONY: deploy |
86 | 65 |
deploy: deploy2defun |
57 | 66 |
|
86 | 67 |
.PHONY: deploy2defun |
68 |
deploy2defun: deploy2defun-web deploy2defun-hg |
|
69 |
||
70 |
# Will be accessible via: http://cooking.defun.work/ |
|
57 | 71 |
.PHONY: deploy2defun-web |
78 | 72 |
deploy2defun-web: www |
86 | 73 |
rsync --delete -avP -e ssh $(SITE_DIR)/ $(WWW_SRV_USER)@$(WWW_SRV_NAME):/srv/www/cooking/ |
14
a36529d7dc2b
Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
74 |
|
60
387dd3541a06
Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
59
diff
changeset
|
75 |
.PHONY: deploy2defun-hg |
387dd3541a06
Point to defun.work to grab sources.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
59
diff
changeset
|
76 |
deploy2defun-hg: |
86 | 77 |
hg push ssh://$(HG_SRV_USER)@$(HG_SRV_NAME)//srv/hg/cooking || [ $$? = 1 ] |
36
7fb39a216cef
Push sources on 'deploy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
35
diff
changeset
|
78 |
|
69
f82b136921b7
Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
79 |
.PHONY: deploy2local |
86 | 80 |
deploy2local: html | $(LOCAL_DIR) |
81 |
rsync --delete -avP $(SITE_DIR)/ $(LOCAL_DIR) |
|
69
f82b136921b7
Deploy to local WEB server.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
82 |
|
14
a36529d7dc2b
Add 'deploy2sourceforge' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
83 |
################################################################ |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
84 |
# Build targets. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
85 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
86 |
.PHONY: all |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
87 |
all: |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
88 |
|
78 | 89 |
.PHONY: www |
86 | 90 |
www: html $(SITE_DIR)/sitemap.xml $(SITE_DIR)/robots.txt |
78 | 91 |
|
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
92 |
.PHONY: html |
71
ca442493062e
TXT files no longer used.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
69
diff
changeset
|
93 |
html: $(HTML_FILES) |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
94 |
|
86 | 95 |
$(SITE_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(BUILD_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(SITE_DIR) |
96 |
$(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(BUILD_DIR)/rst.tmpl $*.rst $@ |
|
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
97 |
|
86 | 98 |
$(BUILD_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(BUILD_DIR) |
74
69323ee4fd3a
Remove HEADER.rst because that info now added to HTML template.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
73
diff
changeset
|
99 |
sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|" <$< >$@ |
17
c7017f58585c
Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
16
diff
changeset
|
100 |
|
86 | 101 |
# .PHONY: single-html |
102 |
# single-html: $(HTML_DIR)/single.html |
|
72
6cc2c19c8995
Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
71
diff
changeset
|
103 |
|
86 | 104 |
# $(HTML_DIR)/single.html: $(HTML_DIR)/single.rest www/rst.css www/rst-single.css $(RST_FILES) |
105 |
# $(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-single.css $(HTML_DIR)/single.rest $@ |
|
72
6cc2c19c8995
Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
71
diff
changeset
|
106 |
|
86 | 107 |
# $(HTML_DIR)/single.rest: $(RST_FILES) $(MAKEFILE_LIST) |
108 |
# { \ |
|
109 |
# echo ".. contents::"; \ |
|
110 |
# echo " :local:"; \ |
|
111 |
# echo; \ |
|
112 |
# for f in *.rst; do echo ".. include:: ../$$f"; done; \ |
|
113 |
# } >$@ |
|
72
6cc2c19c8995
Generate single HTML build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
71
diff
changeset
|
114 |
|
86 | 115 |
$(SITE_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(SITE_DIR) |
78 | 116 |
{ \ |
117 |
echo '<?xml version="1.0" encoding="UTF-8"?>'; \ |
|
118 |
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \ |
|
83
41a9c64f3fb7
Clean up after moving cooking.rst from tips project. Remove iframe, fix build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
82
diff
changeset
|
119 |
for f in $(RST_FILES); do \ |
78 | 120 |
echo '<url>'; \ |
121 |
echo " <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \ |
|
86 | 122 |
echo ' <changefreq>monthly</changefreq>'; \ |
78 | 123 |
echo '</url>'; \ |
124 |
done; \ |
|
125 |
echo '</urlset>'; \ |
|
126 |
} >$@ |
|
127 |
||
86 | 128 |
$(SITE_DIR)/robots.txt: www/robots.txt $(MAKEFILE_LIST) | $(SITE_DIR) |
80 | 129 |
cp $< $@ |
130 |
||
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
131 |
################################################################ |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
132 |
# Init targets. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
133 |
|
86 | 134 |
$(BUILD_DIR) $(SITE_DIR) $(LOCAL_DIR): |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
135 |
mkdir -p $@ |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
136 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
137 |
################################################################ |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
138 |
# Clean targets. |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
139 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
140 |
.PHONY: distclean |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
141 |
distclean: clean |
86 | 142 |
rm -r -f $(LOCAL_DIR) |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
143 |
|
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
144 |
.PHONY: clean |
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
145 |
clean: |
86 | 146 |
rm -r -f $(BUILD_DIR) |
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
147 |
|
5 | 148 |
################################################################ |
149 |
# Helper target. |
|
0
6ee132e4cd5f
Build html version of tips.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
150 |
|
35
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
151 |
.PHONY: help |
5 | 152 |
help: |
153 |
@echo Supported targets: |
|
154 |
@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*= \1=;p;}' $(MAKEFILE_LIST) |
|
155 |
||
35
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
156 |
.PHONY: check-format-policy |
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
157 |
check-format-policy: |
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
158 |
\ |
73
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
159 |
for f in $(RST_FILES); do \ |
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
160 |
if grep '^.. -\*- coding: utf-8; -\*-' $$f >/dev/null; then :; else \ |
35
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
161 |
echo $$f:1:" Has no 'coding: utf-8' directive."; \ |
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
162 |
fi; \ |
73
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
163 |
if grep '^.. contents::' $$f >/dev/null; then :; else \ |
35
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
164 |
echo $$f:7:" Has no 'contents::' directive."; \ |
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
165 |
fi; \ |
73
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
166 |
if grep '^ :local:' $$f >/dev/null; then :; else \ |
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
167 |
echo $$f:7:" Has no ':local:' directive."; \ |
7ed63a934571
Check for presents of :local: keyword.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
72
diff
changeset
|
168 |
fi; \ |
35
648d3bf5204d
Add 'check-format-policy' target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
169 |
done |
5 | 170 |