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

################################################################################
#
# Makefile for generalized web build
#
################################################################################
#===============================================================================
# Definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#===============================================================================
SRCDIR = .
BUILDDIR = build
PUG = pug
PUGFLAGS = --pretty --path .
PUGFLAGS_PROD = --path .
PUGDIR = $(SRCDIR)
TMPLDIR = $(SRCDIR)/assets/templates
SASS = sassc
SASSFLAGS = --line-numbers --style expanded
SASSFLAGS_PROD = --style compressed
SASSEXT = scss
SASSDIR = $(SRCDIR)/assets/style
CSSDIR = $(BUILDDIR)/assets/style
JS = cp
JSFLAGS =
JSFLAGS_PROD =
JSSRCDIR = $(SRCDIR)/assets/scripts
JSDIR = $(BUILDDIR)/assets/scripts
JSVENDOR = cp
JSVENDORFLAGS =
JSVENDORFLAGS_PROD =
JSVENDORSRCDIR = $(SRCDIR)/assets/scripts/vendor
JSVENDORDIR = $(BUILDDIR)/assets/scripts/vendor
JQUERY_VERSION = 1.12.0
IMG = cp
IMGFLAGS =
IMGFLAGS_PROD =
IMGSRCDIR = $(SRCDIR)/assets/media/img
IMGDIR = $(BUILDDIR)/assets/media/img
VID = cp
VIDFLAGS =
VIDFLAGS_PROD =
VIDSRCDIR = $(SRCDIR)/assets/media/vid
VIDDIR = $(BUILDDIR)/assets/media/vid
FONT = cp
FONTFLAGS =
FONTFLAGS_PROD =
FONTSRCDIR = $(SRCDIR)/assets/fonts
FONTDIR = $(BUILDDIR)/assets/fonts
EXT = cp
EXTFLAGS =
EXTFLAGS_PROD =
EXTDIR = $(SRCDIR)/assets/extras
#===============================================================================
# Files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#===============================================================================
PUGTEMPLATES = $(shell find $(TMPLDIR) -type f -name \*.pug -print)
PUGFILES = $(shell find $(PUGDIR) -type d -path $(TMPLDIR) -prune -o -type f -name \*.pug -print)
MDFILES = $(shell find $(PUGDIR) -type d -path $(TMPLDIR) -prune -o -type f -name \*.md -print)
HTMLFILES = $(patsubst $(PUGDIR)/%.pug, $(BUILDDIR)/%.html, $(PUGFILES))
SASSFILES = $(wildcard $(SASSDIR)/[^_]*.$(SASSEXT))
SASSSTUBS = $(wildcard $(SASSDIR)/_*.$(SASSEXT))
CSSFILES = $(patsubst $(SASSDIR)/%.$(SASSEXT), $(CSSDIR)/%.css, $(SASSFILES))
JSFILES_SRC = $(wildcard $(JSSRCDIR)/*.js)
JSFILES = $(patsubst $(JSSRCDIR)/%, $(JSDIR)/%, $(JSFILES_SRC))
JSVENDORFILES_SRC = $(wildcard $(JSVENDORSRCDIR)/*.js)
JSVENDORFILES = $(patsubst $(JSVENDORSRCDIR)/%, $(JSVENDORDIR)/%, $(JSVENDORFILES_SRC))
IMGFILES_SRC = $(wildcard $(IMGSRCDIR)/*)
IMGFILES = $(patsubst $(IMGSRCDIR)/%, $(IMGDIR)/%, $(IMGFILES_SRC))
VIDFILES_SRC = $(wildcard $(VIDSRCDIR)/*)
VIDFILES = $(patsubst $(VIDSRCDIR)/%, $(VIDDIR)/%, $(VIDFILES_SRC))
FONTFILES_SRC = $(wildcard $(FONTSRCDIR)/*)
FONTFILES = $(patsubst $(FONTSRCDIR)/%, $(FONTDIR)/%, $(FONTFILES_SRC))
FEEDFILES_SRC = $(wildcard $(EXTDIR)/feed.*)
TXTFILES_SRC = $(wildcard $(EXTDIR)/*.txt)
PNGFILES_SRC = $(wildcard $(EXTDIR)/*.png)
ICOFILES_SRC = $(wildcard $(EXTDIR)/*.ico)
XMLFILES_SRC = $(wildcard $(EXTDIR)/*.xml)
HTACCESS_SRC = $(wildcard $(EXTDIR)/.htaccess)
CNAME_SRC = $(wildcard $(EXTDIR)/CNAME)
FEEDFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(FEEDFILES_SRC))
TXTFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(TXTFILES_SRC))
PNGFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(PNGFILES_SRC))
ICOFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(ICOFILES_SRC))
XMLFILES = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(XMLFILES_SRC))
HTACCESS = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(HTACCESS_SRC))
CNAME = $(patsubst $(EXTDIR)/%, $(BUILDDIR)/%, $(CNAME_SRC))
#===============================================================================
# Rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#===============================================================================
.PHONY: all html css js jsvendor img vid font extras feed production deploy clean
all: html css js jsvendor img vid font extras feed
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
html: $(HTMLFILES)
$(HTMLFILES): $(PUGTEMPLATES)
$(BUILDDIR)/%.html: $(PUGDIR)/%.pug
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(PUG) $(PUGFLAGS) -o $(dir $@) $<
if [[ `grep '{{JQUERY_VERSION}}' $@` ]]; then sed -i "s/{{JQUERY_VERSION}}/$(JQUERY_VERSION)/" $@; fi
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
css: $(CSSFILES)
$(CSSFILES): $(SASSFILES) $(SASSSTUBS)
$(CSSDIR)/%.css: $(SASSDIR)/%.$(SASSEXT)
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(SASS) $(SASSFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
js: $(JSFILES)
$(JSFILES): $(JSFILES_SRC)
$(JSDIR)/%.js: $(JSSRCDIR)/%.js
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(JS) $(JSFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
jsvendor: $(JSVENDORFILES)
$(JSVENDORFILES): $(JSVENDORFILES_SRC)
$(JSVENDORDIR)/%.js: $(JSVENDORSRCDIR)/%.js
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(JSVENDOR) $(JSVENDORFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
img: $(IMGFILES)
$(IMGFILES): $(IMGFILES_SRC)
$(IMGDIR)/%: $(IMGSRCDIR)/%
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(IMG) $(IMGFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
vid: $(VIDFILES)
$(VIDFILES): $(VIDFILES_SRC)
$(VIDDIR)/%: $(VIDSRCDIR)/%
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(VID) $(VIDFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
font: $(FONTFILES)
$(FONTFILES): $(FONTFILES_SRC)
$(FONTDIR)/%: $(FONTSRCDIR)/%
if [[ ! -d $(dir $@) ]]; then mkdir -p $(dir $@); fi
$(FONT) $(FONTFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
extras: $(FEEDFILES) $(TXTFILES) $(PNGFILES) $(ICOFILES) $(XMLFILES) $(HTACCESS) $(CNAME)
$(BUILDDIR)/feed.%: $(EXTDIR)/feed.%
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/%.txt: $(EXTDIR)/%.txt
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/%.png: $(EXTDIR)/%.png
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/%.ico: $(EXTDIR)/%.ico
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/%.xml: $(EXTDIR)/%.xml
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/.htaccess: $(EXTDIR)/.htaccess
$(EXT) $(EXTFLAGS) $< $@
$(BUILDDIR)/CNAME: $(EXTDIR)/CNAME
$(EXT) $(EXTFLAGS) $< $@
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
feed: $(FEEDFILES_SRC)
$(FEEDFILES_SRC): $(PUGFILES) $(MDFILES)
./mkfeed.py feed.rss
mv feed.rss extras/feed.rss
./mkfeed.py feed.atom
mv feed.atom extras/feed.atom
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
production: all
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
deploy: production
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
clean:
rm -v $(HTMLFILES) \
$(CSSFILES) \
$(JSFILES) \
$(JSVENDORFILES) \
$(IMGFILES) \
$(VIDFILES) \
$(FONTFILES) \
$(FEEDFILES) \
$(TXTFILES) \
$(PNGFILES) \
$(ICOFILES) \
$(XMLFILES) \
$(HTACCESS) \
$(CNAME)