You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

250 lines
7.2 KiB

  1. ################################################################################
  2. #
  3. # Makefile for generalized web build
  4. #
  5. ################################################################################
  6. #===============================================================================
  7. # Definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. #===============================================================================
  9. SRCDIR = .
  10. BUILDDIR = build
  11. PUG = pug
  12. PUGFLAGS = --pretty --path .
  13. PUGFLAGS_PROD = --path .
  14. PUGDIR = $(SRCDIR)
  15. TMPLDIR = $(SRCDIR)/assets/templates
  16. SASS = sassc
  17. SASSFLAGS = --line-numbers --style expanded
  18. SASSFLAGS_PROD = --style compressed
  19. SASSEXT = scss
  20. SASSDIR = $(SRCDIR)/assets/style
  21. CSSDIR = $(BUILDDIR)/assets/style
  22. JS = cp
  23. JSFLAGS =
  24. JSFLAGS_PROD =
  25. JSSRCDIR = $(SRCDIR)/assets/scripts
  26. JSDIR = $(BUILDDIR)/assets/scripts
  27. JSVENDOR = cp
  28. JSVENDORFLAGS =
  29. JSVENDORFLAGS_PROD =
  30. JSVENDORSRCDIR = $(SRCDIR)/assets/scripts/vendor
  31. JSVENDORDIR = $(BUILDDIR)/assets/scripts/vendor
  32. JQUERY_VERSION = 1.12.0
  33. IMG = cp
  34. IMGFLAGS =
  35. IMGFLAGS_PROD =
  36. IMGSRCDIR = $(SRCDIR)/assets/media/images
  37. IMGDIR = $(BUILDDIR)/assets/media/images
  38. VID = cp
  39. VIDFLAGS =
  40. VIDFLAGS_PROD =
  41. VIDSRCDIR = $(SRCDIR)/assets/media/video
  42. VIDDIR = $(BUILDDIR)/assets/media/video
  43. FONT = cp
  44. FONTFLAGS =
  45. FONTFLAGS_PROD =
  46. FONTSRCDIR = $(SRCDIR)/assets/fonts
  47. FONTDIR = $(BUILDDIR)/assets/fonts
  48. EXT = cp
  49. EXTFLAGS =
  50. EXTFLAGS_PROD =
  51. EXTDIR = $(SRCDIR)/assets/extras
  52. #===============================================================================
  53. # Files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. #===============================================================================
  55. PUGTEMPLATES = $(shell find $(TMPLDIR) -type f -name \*.pug -print)
  56. PUGFILES = $(shell find $(PUGDIR) -type d -path $(TMPLDIR) -prune -o -type f -name \*.pug -print)
  57. MDFILES = $(shell find $(PUGDIR) -type d -path $(TMPLDIR) -prune -o -type f -name \*.md -print)
  58. HTMLFILES = $(patsubst $(PUGDIR)/%.pug, $(BUILDDIR)/%.html, $(PUGFILES))
  59. SASSFILES = $(wildcard $(SASSDIR)/[^_]*.$(SASSEXT))
  60. SASSSTUBS = $(wildcard $(SASSDIR)/_*.$(SASSEXT))
  61. CSSFILES = $(patsubst $(SASSDIR)/%.$(SASSEXT), $(CSSDIR)/%.css, $(SASSFILES))
  62. JSFILES_SRC = $(wildcard $(JSSRCDIR)/*.js)
  63. JSFILES = $(patsubst $(JSSRCDIR)/%, $(JSDIR)/%, $(JSFILES_SRC))
  64. JSVENDORFILES_SRC = $(wildcard $(JSVENDORSRCDIR)/*.js)
  65. JSVENDORFILES = $(patsubst $(JSVENDORSRCDIR)/%, $(JSVENDORDIR)/%, $(JSVENDORFILES_SRC))
  66. IMGFILES_SRC = $(wildcard $(IMGSRCDIR)/*)
  67. IMGFILES = $(patsubst $(IMGSRCDIR)/%, $(IMGDIR)/%, $(IMGFILES_SRC))
  68. VIDFILES_SRC = $(wildcard $(VIDSRCDIR)/*)
  69. VIDFILES = $(patsubst $(VIDSRCDIR)/%, $(VIDDIR)/%, $(VIDFILES_SRC))
  70. FONTFILES_SRC = $(wildcard $(FONTSRCDIR)/*)
  71. FONTFILES = $(patsubst $(FONTSRCDIR)/%, $(FONTDIR)/%, $(FONTFILES_SRC))
  72. FEEDFILES_SRC = $(wildcard $(EXTDIR)/feed.*)
  73. TXTFILES_SRC = $(wildcard $(EXTDIR)/*.txt)
  74. PNGFILES_SRC = $(wildcard $(EXTDIR)/*.png)
  75. ICOFILES_SRC = $(wildcard $(EXTDIR)/*.ico)
  76. XMLFILES_SRC = $(wildcard $(EXTDIR)/*.xml)
  77. HTACCESS_SRC = $(wildcard $(EXTDIR)/.htaccess)
  78. CNAME_SRC = $(wildcard $(EXTDIR)/CNAME)
  79. FEEDFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(FEEDFILES_SRC))
  80. TXTFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(TXTFILES_SRC))
  81. PNGFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(PNGFILES_SRC))
  82. ICOFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(ICOFILES_SRC))
  83. XMLFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(XMLFILES_SRC))
  84. HTACCESS = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(HTACCESS_SRC))
  85. CNAME = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(CNAME_SRC))
  86. #===============================================================================
  87. # Rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. #===============================================================================
  89. .PHONY: all html css js jsvendor img vid font extras feed production deploy clean
  90. all: html css js jsvendor img vid font extras feed
  91. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  92. html: $(HTMLFILES)
  93. $(HTMLFILES): $(PUGTEMPLATES) $(MDFILES)
  94. $(BUILDDIR)/%.html: $(PUGDIR)/%.pug
  95. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  96. $(PUG) $(PUGFLAGS) -o $(dir $@) $<
  97. if [[ `grep '{{JQUERY_VERSION}}' $@` ]]; then sed -i "s/{{JQUERY_VERSION}}/$(JQUERY_VERSION)/" $@; fi
  98. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  99. css: $(CSSFILES)
  100. $(CSSFILES): $(SASSFILES) $(SASSSTUBS)
  101. $(CSSDIR)/%.css: $(SASSDIR)/%.$(SASSEXT)
  102. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  103. $(SASS) $(SASSFLAGS) $< $@
  104. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  105. js: $(JSFILES)
  106. $(JSFILES): $(JSFILES_SRC)
  107. $(JSDIR)/%.js: $(JSSRCDIR)/%.js
  108. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  109. $(JS) $(JSFLAGS) $< $@
  110. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  111. jsvendor: $(JSVENDORFILES)
  112. $(JSVENDORFILES): $(JSVENDORFILES_SRC)
  113. $(JSVENDORDIR)/%.js: $(JSVENDORSRCDIR)/%.js
  114. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  115. $(JSVENDOR) $(JSVENDORFLAGS) $< $@
  116. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  117. img: $(IMGFILES)
  118. $(IMGFILES): $(IMGFILES_SRC)
  119. $(IMGDIR)/%: $(IMGSRCDIR)/%
  120. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  121. $(IMG) $(IMGFLAGS) $< $@
  122. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  123. vid: $(VIDFILES)
  124. $(VIDFILES): $(VIDFILES_SRC)
  125. $(VIDDIR)/%: $(VIDSRCDIR)/%
  126. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  127. $(VID) $(VIDFLAGS) $< $@
  128. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  129. font: $(FONTFILES)
  130. $(FONTFILES): $(FONTFILES_SRC)
  131. $(FONTDIR)/%: $(FONTSRCDIR)/%
  132. if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
  133. $(FONT) $(FONTFLAGS) $< $@
  134. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  135. extras: $(FEEDFILES) $(TXTFILES) $(PNGFILES) $(ICOFILES) $(XMLFILES) $(HTACCESS) $(CNAME)
  136. $(BUILDDIR)/feed.%: $(EXTDIR)/feed.%
  137. $(EXT) $(EXTFLAGS) $< $@
  138. $(BUILDDIR)/%.txt: $(EXTDIR)/%.txt
  139. $(EXT) $(EXTFLAGS) $< $@
  140. $(BUILDDIR)/%.png: $(EXTDIR)/%.png
  141. $(EXT) $(EXTFLAGS) $< $@
  142. $(BUILDDIR)/%.ico: $(EXTDIR)/%.ico
  143. $(EXT) $(EXTFLAGS) $< $@
  144. $(BUILDDIR)/%.xml: $(EXTDIR)/%.xml
  145. $(EXT) $(EXTFLAGS) $< $@
  146. $(BUILDDIR)/.htaccess: $(EXTDIR)/.htaccess
  147. $(EXT) $(EXTFLAGS) $< $@
  148. $(BUILDDIR)/CNAME: $(EXTDIR)/CNAME
  149. $(EXT) $(EXTFLAGS) $< $@
  150. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  151. feed: $(FEEDFILES_SRC)
  152. $(FEEDFILES_SRC): $(PUGFILES) $(MDFILES)
  153. ./mkfeed.py feed.rss
  154. mv feed.rss extras/feed.rss
  155. ./mkfeed.py feed.atom
  156. mv feed.atom extras/feed.atom
  157. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  158. production: all
  159. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  160. deploy: production
  161. #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  162. clean:
  163. rm -v $(HTMLFILES) \
  164. $(CSSFILES) \
  165. $(JSFILES) \
  166. $(JSVENDORFILES) \
  167. $(IMGFILES) \
  168. $(VIDFILES) \
  169. $(FONTFILES) \
  170. $(FEEDFILES) \
  171. $(TXTFILES) \
  172. $(PNGFILES) \
  173. $(ICOFILES) \
  174. $(XMLFILES) \
  175. $(HTACCESS) \
  176. $(CNAME)