38 RST_FLAGS := $(RST_WARNING_FLAGS) $(RST_RENDER_FLAGS) |
38 RST_FLAGS := $(RST_WARNING_FLAGS) $(RST_RENDER_FLAGS) |
39 |
39 |
40 ################################################################ |
40 ################################################################ |
41 # Proj dirs/files. |
41 # Proj dirs/files. |
42 |
42 |
|
43 BUILD_DIR := _ |
|
44 SITE_DIR := $(BUILD_DIR)/site |
|
45 |
43 RST_FILES := $(wildcard *.rst) |
46 RST_FILES := $(wildcard *.rst) |
44 |
47 |
45 HTML_DIR := tips-html |
48 RST_HTML_FILES := $(patsubst %.rst,$(SITE_DIR)/%.html,$(RST_FILES)) |
46 RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES)) |
|
47 HTML_FILES := $(RST_HTML_FILES) |
49 HTML_FILES := $(RST_HTML_FILES) |
48 |
|
49 DIRS := $(HTML_DIR) |
|
50 |
50 |
51 ################################################################ |
51 ################################################################ |
52 # Deploy targets. |
52 # Deploy targets. |
53 |
53 |
54 WWW_SRV_NAME := tips.defun.work |
54 WWW_SRV_NAME := cooking.defun.work |
55 WWW_SRV_USER := user |
55 WWW_SRV_USER := user |
56 HG_SRV_NAME := hg.defun.work |
56 HG_SRV_NAME := hg.defun.work |
57 HG_SRV_USER := user |
57 HG_SRV_USER := user |
58 LOCAL_DIR := /srv/www/tips |
58 LOCAL_DIR := /srv/www/cooking |
59 |
59 |
60 ifneq '' '$(filter deploy%,$(MAKECMDGOALS))' |
60 ifneq '' '$(filter deploy%,$(MAKECMDGOALS))' |
61 $(shell rm -f $(HTML_DIR)/rst.tmpl) |
61 $(shell rm -f $(BUILD_DIR)/rst.tmpl) |
62 endif |
62 endif |
63 |
63 |
64 # For SEO reason I removed tips from SF. |
|
65 .PHONY: deploy |
64 .PHONY: deploy |
66 deploy: deploy2defun-web deploy2defun-hg # deploy2sf-web deploy2sf-hg |
65 deploy: deploy2defun |
67 |
66 |
68 # Will be accessible via: http://tips.defun.work/ |
67 .PHONY: deploy2defun |
|
68 deploy2defun: deploy2defun-web deploy2defun-hg |
|
69 |
|
70 # Will be accessible via: http://cooking.defun.work/ |
69 .PHONY: deploy2defun-web |
71 .PHONY: deploy2defun-web |
70 deploy2defun-web: www |
72 deploy2defun-web: www |
71 rsync --delete -avP -e ssh $(HTML_DIR)/ $(WWW_SRV_USER)@$(WWW_SRV_NAME):/srv/www/tips/ |
73 rsync --delete -avP -e ssh $(SITE_DIR)/ $(WWW_SRV_USER)@$(WWW_SRV_NAME):/srv/www/cooking/ |
72 |
74 |
73 .PHONY: deploy2defun-hg |
75 .PHONY: deploy2defun-hg |
74 deploy2defun-hg: |
76 deploy2defun-hg: |
75 hg push ssh://$(HG_SRV_USER)@$(HG_SRV_NAME)//srv/hg/tips || [ $$? = 1 ] |
77 hg push ssh://$(HG_SRV_USER)@$(HG_SRV_NAME)//srv/hg/cooking || [ $$? = 1 ] |
76 |
|
77 # Will be accessible via: http://gavenkoa.users.sourceforge.net/tips-html/ |
|
78 .PHONY: deploy2sf-web |
|
79 deploy2sf-web: www |
|
80 rsync --delete -avP -e ssh $(HTML_DIR)/ gavenkoa@frs.sourceforge.net:/home/user-web/g/ga/gavenkoa/htdocs/tips-html/ |
|
81 |
|
82 .PHONY: deploy2sf-hg |
|
83 deploy2sf-hg: |
|
84 hg push ssh://gavenkoa@hg.code.sf.net/u/gavenkoa/tips || [ $$? = 1 ] |
|
85 |
78 |
86 .PHONY: deploy2local |
79 .PHONY: deploy2local |
87 deploy2local: html |
80 deploy2local: html | $(LOCAL_DIR) |
88 rsync --delete -avP $(HTML_DIR)/ $(LOCAL_DIR) |
81 rsync --delete -avP $(SITE_DIR)/ $(LOCAL_DIR) |
89 |
82 |
90 ################################################################ |
83 ################################################################ |
91 # Build targets. |
84 # Build targets. |
92 |
85 |
93 .PHONY: all |
86 .PHONY: all |
94 all: |
87 all: |
95 |
88 |
96 .PHONY: www |
89 .PHONY: www |
97 www: html $(HTML_DIR)/sitemap.xml $(HTML_DIR)/robots.txt |
90 www: html $(SITE_DIR)/sitemap.xml $(SITE_DIR)/robots.txt |
98 |
91 |
99 .PHONY: html |
92 .PHONY: html |
100 html: $(HTML_FILES) |
93 html: $(HTML_FILES) |
101 |
94 |
102 $(HTML_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(HTML_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR) |
95 $(SITE_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(BUILD_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(SITE_DIR) |
103 $(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(HTML_DIR)/rst.tmpl $*.rst $@ |
96 $(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(BUILD_DIR)/rst.tmpl $*.rst $@ |
104 |
97 |
105 $(HTML_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR) |
98 $(BUILD_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(BUILD_DIR) |
106 sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|" <$< >$@ |
99 sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|" <$< >$@ |
107 |
100 |
108 .PHONY: single-html |
101 # .PHONY: single-html |
109 single-html: $(HTML_DIR)/single.html |
102 # single-html: $(HTML_DIR)/single.html |
110 |
103 |
111 $(HTML_DIR)/single.html: $(HTML_DIR)/single.rest www/rst.css www/rst-single.css $(RST_FILES) |
104 # $(HTML_DIR)/single.html: $(HTML_DIR)/single.rest www/rst.css www/rst-single.css $(RST_FILES) |
112 $(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-single.css $(HTML_DIR)/single.rest $@ |
105 # $(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-single.css $(HTML_DIR)/single.rest $@ |
113 |
106 |
114 $(HTML_DIR)/single.rest: $(RST_FILES) $(MAKEFILE_LIST) |
107 # $(HTML_DIR)/single.rest: $(RST_FILES) $(MAKEFILE_LIST) |
115 { \ |
108 # { \ |
116 echo ".. contents::"; \ |
109 # echo ".. contents::"; \ |
117 echo " :local:"; \ |
110 # echo " :local:"; \ |
118 echo; \ |
111 # echo; \ |
119 for f in *.rst; do echo ".. include:: ../$$f"; done; \ |
112 # for f in *.rst; do echo ".. include:: ../$$f"; done; \ |
120 } >$@ |
113 # } >$@ |
121 |
114 |
122 $(HTML_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR) |
115 $(SITE_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(SITE_DIR) |
123 { \ |
116 { \ |
124 echo '<?xml version="1.0" encoding="UTF-8"?>'; \ |
117 echo '<?xml version="1.0" encoding="UTF-8"?>'; \ |
125 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \ |
118 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \ |
126 for f in $(RST_FILES); do \ |
119 for f in $(RST_FILES); do \ |
127 echo '<url>'; \ |
120 echo '<url>'; \ |
128 echo " <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \ |
121 echo " <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \ |
129 echo ' <changefreq>weekly</changefreq>'; \ |
122 echo ' <changefreq>monthly</changefreq>'; \ |
130 echo '</url>'; \ |
123 echo '</url>'; \ |
131 done; \ |
124 done; \ |
132 echo '</urlset>'; \ |
125 echo '</urlset>'; \ |
133 } >$@ |
126 } >$@ |
134 |
127 |
135 $(HTML_DIR)/robots.txt: www/robots.txt $(MAKEFILE_LIST) | $(HTML_DIR) |
128 $(SITE_DIR)/robots.txt: www/robots.txt $(MAKEFILE_LIST) | $(SITE_DIR) |
136 cp $< $@ |
129 cp $< $@ |
137 |
130 |
138 ################################################################ |
131 ################################################################ |
139 # Init targets. |
132 # Init targets. |
140 |
133 |
141 $(DIRS): |
134 $(BUILD_DIR) $(SITE_DIR) $(LOCAL_DIR): |
142 mkdir -p $@ |
135 mkdir -p $@ |
143 |
136 |
144 ################################################################ |
137 ################################################################ |
145 # Clean targets. |
138 # Clean targets. |
146 |
139 |
147 .PHONY: distclean |
140 .PHONY: distclean |
148 distclean: clean |
141 distclean: clean |
|
142 rm -r -f $(LOCAL_DIR) |
149 |
143 |
150 .PHONY: clean |
144 .PHONY: clean |
151 clean: |
145 clean: |
152 rm -r -f $(DIRS) |
146 rm -r -f $(BUILD_DIR) |
153 |
147 |
154 ################################################################ |
148 ################################################################ |
155 # Helper target. |
149 # Helper target. |
156 |
150 |
157 .PHONY: help |
151 .PHONY: help |