Makefile
changeset 83 41a9c64f3fb7
parent 82 79761f22308d
child 84 898facea8832
equal deleted inserted replaced
82:79761f22308d 83:41a9c64f3fb7
    42 
    42 
    43 RST_FILES := $(wildcard *.rst)
    43 RST_FILES := $(wildcard *.rst)
    44 
    44 
    45 HTML_DIR := tips-html
    45 HTML_DIR := tips-html
    46 RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES))
    46 RST_HTML_FILES := $(patsubst %.rst,$(HTML_DIR)/%.html,$(RST_FILES))
    47 HTML_FILES := $(RST_HTML_FILES) \
    47 HTML_FILES := $(RST_HTML_FILES)
    48         $(HTML_DIR)/index.html $(HTML_DIR)/iframe.html
       
    49 
    48 
    50 CHM_FILES := $(addprefix $(HTML_DIR)/,chm.hhp chm.hhc chm.stp)
    49 CHM_FILES := $(addprefix $(HTML_DIR)/,chm.hhp chm.hhc chm.stp)
    51 
    50 
    52 DIRS := $(HTML_DIR)
    51 DIRS := $(HTML_DIR)
    53 
    52 
   103 html: $(HTML_FILES)
   102 html: $(HTML_FILES)
   104 
   103 
   105 $(HTML_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(HTML_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   104 $(HTML_DIR)/%.html: %.rst www/rst.css www/rst-multi.css $(HTML_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   106 	$(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(HTML_DIR)/rst.tmpl $*.rst $@
   105 	$(RST2HTML) $(RST_FLAGS) --stylesheet=www/rst.css,www/rst-multi.css --template=$(HTML_DIR)/rst.tmpl $*.rst $@
   107 
   106 
   108 $(HTML_DIR)/iframe.html: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
       
   109 	{ \
       
   110 echo '<html><head>'; \
       
   111 echo '<meta charset="utf-8">'; \
       
   112 echo '<style>'; \
       
   113 echo 'a { text-decoration: none; color: hsl(240, 100%, 50%); }'; \
       
   114 echo 'a:hover { opacity: .5; }'; \
       
   115 echo '</style></head><body>'; \
       
   116 echo '<ul style="padding-left: 1em;">'; \
       
   117 for f in $(sort $(RST_FILES)); do \
       
   118   n=$${f%.rst}; \
       
   119   printf '<li><a target="_parent" href="%s.html">%s</a></li>\n' $$n $$n; \
       
   120 done; \
       
   121 echo '</ul>'; \
       
   122 echo '</body></html>'; \
       
   123 } >$@
       
   124 
       
   125 $(HTML_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   107 $(HTML_DIR)/rst.tmpl: www/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   126 	sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|"  <$< >$@
   108 	sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|"  <$< >$@
   127 
       
   128 $(HTML_DIR)/index.html: $(HTML_DIR)/README.html $(MAKEFILE_LIST) | $(HTML_DIR)
       
   129 	cp $< $@
       
   130 
   109 
   131 .PHONY: chm
   110 .PHONY: chm
   132 chm: html $(CHM_FILES) $(HTML_DIR)/iframe.html
   111 chm: html $(CHM_FILES) $(HTML_DIR)/iframe.html
   133 	cd $(HTML_DIR); for file in *.html; do sed -i '/<\?xml.*\?>/d' $$file; done
   112 	cd $(HTML_DIR); for file in *.html; do sed -i '/<\?xml.*\?>/d' $$file; done
   134 
   113 
   157 
   136 
   158 $(HTML_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
   137 $(HTML_DIR)/sitemap.xml: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
   159 	{ \
   138 	{ \
   160 echo '<?xml version="1.0" encoding="UTF-8"?>'; \
   139 echo '<?xml version="1.0" encoding="UTF-8"?>'; \
   161 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \
   140 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; \
   162 for f in *.rst iframe; do \
   141 for f in $(RST_FILES); do \
   163   echo '<url>'; \
   142   echo '<url>'; \
   164   echo "  <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \
   143   echo "  <loc>http://$(WWW_SRV_NAME)/$${f%.rst}.html</loc>"; \
   165   echo '  <changefreq>weekly</changefreq>'; \
   144   echo '  <changefreq>weekly</changefreq>'; \
   166   echo '</url>'; \
   145   echo '</url>'; \
   167 done; \
   146 done; \