Makefile
changeset 74 69323ee4fd3a
parent 73 7ed63a934571
child 75 540d83fc281e
equal deleted inserted replaced
73:7ed63a934571 74:69323ee4fd3a
    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 RST_FILES := $(filter-out HEADER.rst,$(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
    48         $(HTML_DIR)/index.html $(HTML_DIR)/iframe.html
    59 HG_SRV_NAME := hg.defun.work
    59 HG_SRV_NAME := hg.defun.work
    60 HG_SRV_USER := user
    60 HG_SRV_USER := user
    61 LOCAL_DIR := /srv/www/tips
    61 LOCAL_DIR := /srv/www/tips
    62 
    62 
    63 ifneq '' '$(filter deploy%,$(MAKECMDGOALS))'
    63 ifneq '' '$(filter deploy%,$(MAKECMDGOALS))'
    64   $(shell rm -f HEADER.rst)
    64   $(shell rm -f $(HTML_DIR)/rst.tmpl)
    65 endif
    65 endif
    66 
    66 
    67 .PHONY: deploy
    67 .PHONY: deploy
    68 deploy: deploy2defun-web deploy2defun-hg deploy2sf-web deploy2sf-hg
    68 deploy: deploy2defun-web deploy2defun-hg deploy2sf-web deploy2sf-hg
    69 
    69 
    96 all:
    96 all:
    97 
    97 
    98 .PHONY: html
    98 .PHONY: html
    99 html: $(HTML_FILES)
    99 html: $(HTML_FILES)
   100 
   100 
   101 $(HTML_DIR)/%.html: %.rst HEADER.rst rst.css rst-multi.css rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   101 $(HTML_DIR)/%.html: %.rst rst.css rst-multi.css $(HTML_DIR)/rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
   102 	$(RST2HTML) $(RST_FLAGS) --stylesheet=rst.css,rst-multi.css --template=rst.tmpl $*.rst $@
   102 	$(RST2HTML) $(RST_FLAGS) --stylesheet=rst.css,rst-multi.css --template=$(HTML_DIR)/rst.tmpl $*.rst $@
   103 
   103 
   104 $(HTML_DIR)/iframe.html: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
   104 $(HTML_DIR)/iframe.html: $(RST_FILES) $(MAKEFILE_LIST) | $(HTML_DIR)
   105 	{ \
   105 	{ \
   106 echo '<html><head>'; \
   106 echo '<html><head>'; \
   107 echo '<meta charset="utf-8">'; \
   107 echo '<meta charset="utf-8">'; \
   116 done; \
   116 done; \
   117 echo '</ul>'; \
   117 echo '</ul>'; \
   118 echo '</body></html>'; \
   118 echo '</body></html>'; \
   119 } >$@
   119 } >$@
   120 
   120 
   121 HEADER.rst: $(MAKEFILE_LIST)
   121 $(HTML_DIR)/rst.tmpl: rst.tmpl $(MAKEFILE_LIST)
   122 	{ \
   122 	sed -e "s|{date}|$$(date +%F)|" -e "s|{rev}|$$(hg id -i)|"  <$< >$@
   123 echo '.. _About: README.html'; \
       
   124 echo '.. _`Contacts`: http://resume.defun.work/'; \
       
   125 echo '.. _`Oleksandr Gavenko`: http://resume.defun.work/'; \
       
   126 echo '.. _`gavenkoa`: http://resume.defun.work/'; \
       
   127 echo '.. _Licence: README.html#tips-licence'; \
       
   128 echo; \
       
   129 echo '.. container:: header'; \
       
   130 echo; \
       
   131 echo '  [ About_ | Licence_ | `Contacts`_ ]'; \
       
   132 echo '.. container:: header small'; \
       
   133 echo; \
       
   134 echo '  Written by Oleksandr Gavenko (AKA gavenkoa), compiled at ``'`date +%F`'`` from rev ``'`hg id -i`'``.'; \
       
   135 } >$@
       
   136 
   123 
   137 $(HTML_DIR)/index.html: $(HTML_DIR)/README.html $(MAKEFILE_LIST) | $(HTML_DIR)
   124 $(HTML_DIR)/index.html: $(HTML_DIR)/README.html $(MAKEFILE_LIST) | $(HTML_DIR)
   138 	cp $< $@
   125 	cp $< $@
   139 
   126 
   140 $(HTML_DIR)/%.html: %.html $(MAKEFILE_LIST) | $(HTML_DIR)
   127 $(HTML_DIR)/%.html: %.html $(MAKEFILE_LIST) | $(HTML_DIR)
   182 .PHONY: distclean
   169 .PHONY: distclean
   183 distclean: clean
   170 distclean: clean
   184 
   171 
   185 .PHONY: clean
   172 .PHONY: clean
   186 clean:
   173 clean:
   187 	rm -r -f $(DIRS) HEADER.rst
   174 	rm -r -f $(DIRS)
   188 
   175 
   189 ################################################################
   176 ################################################################
   190 # Helper target.
   177 # Helper target.
   191 
   178 
   192 .PHONY: help
   179 .PHONY: help
   199 	\
   186 	\
   200 for f in $(RST_FILES); do \
   187 for f in $(RST_FILES); do \
   201   if grep '^.. -\*- coding: utf-8; -\*-' $$f >/dev/null; then :; else \
   188   if grep '^.. -\*- coding: utf-8; -\*-' $$f >/dev/null; then :; else \
   202     echo $$f:1:" Has no 'coding: utf-8' directive."; \
   189     echo $$f:1:" Has no 'coding: utf-8' directive."; \
   203   fi; \
   190   fi; \
   204   if grep '^.. include:: HEADER.rst' $$f >/dev/null; then :; else \
       
   205     echo $$f:2:" Has no 'include:: HEADER.rst' directive."; \
       
   206   fi; \
       
   207   if grep '^.. contents::' $$f >/dev/null; then :; else \
   191   if grep '^.. contents::' $$f >/dev/null; then :; else \
   208     echo $$f:7:" Has no 'contents::' directive."; \
   192     echo $$f:7:" Has no 'contents::' directive."; \
   209   fi; \
   193   fi; \
   210   if grep '^   :local:' $$f >/dev/null; then :; else \
   194   if grep '^   :local:' $$f >/dev/null; then :; else \
   211     echo $$f:7:" Has no ':local:' directive."; \
   195     echo $$f:7:" Has no ':local:' directive."; \