Makefile (Source)

default: all
# $^ -> finished $@ at $(shell date)
NEWEST          := $(shell find . -type f -printf '%T@ %p\n' \
| grep -vE '(cache|output|.doit.db|state_data|#|/sentinel)' \
| sort -n | tail -1 | cut -f2- -d' ')
LATEX_MAKEFILES := $(shell find latex -name Makefile)
LATEX_FOLDERS   := $(dir $(LATEX_MAKEFILES))
LATEX_TEX       := $(shell find $(LATEX_FOLDERS) -maxdepth 1 -name [^.]\*.tex)
LATEX_SVGS      := $(patsubst %.tex,%.svg,$(LATEX_TEX))
FILES_SVGS      := $(patsubst latex/%,files/%,$(LATEX_SVGS))
DATE_FOLDERS    := $(wildcard posts/20??/[0-9][0-9]/[0-9][0-9] posts/20??/[0-9][0-9])
DATE_UP_INDEX   := $(patsubst posts/%,files/posts/%/index.html,$(DATE_FOLDERS))
NEAR_ASSET_FOLDERS   := $(shell find pages posts -type d -name assets)
FAR_ASSET_FOLDERS    := $(patsubst %/assets,files/%/assets,$(NEAR_ASSET_FOLDERS))
NEAR_CODE_FOLDERS   := $(shell find pages posts -type d -name code)
FAR_CODE_FOLDERS    := $(patsubst %/code,listings/%/code,$(NEAR_CODE_FOLDERS))
LIST_IGNORED_FILES := git ls-files --ignored --exclude-standard --others
newest:
@echo ================================================================
@echo ================ updated file: $(NEWEST)
@echo ================================================================
deploy:
until $(MAKE) all ; do sleep 1 ; done
../is_clean.py | grep revision | grep clean
git push
$(MAKE) orphan-clean
date | tee output/deploy
until $(MAKE) -B output ; do sleep 1 ; done
nikola deploy
rm -fv output/deploy
all: latex files listings output
# $^ -> finished $@ at $(shell date)
orphan-clean:
nikola orphans | xargs -r rm -v
while find output -type d -empty | xargs rmdir -v 2>/dev/null ; \
do : ; done
clean: latex-clean files-clean listings-clean
rm -rf cache
find output -mindepth 1 -maxdepth 1 | grep -v sentinel | xargs rm -rfv
while find output -type d -empty | xargs rmdir -v 2>/dev/null ; \
do : ; done
# $^ -> finished $@ at $(shell date)
serve: all
cd output && ../../serve_utf8.py
# $^ -> finished $@ at $(shell date)
templates/sentinel.html: $(NEWEST)
../is_clean.py | tee $@
output: templates/sentinel.html
[ -e $@/busy ] && exit 1 || { date | tee $@/busy ; }
make -C python/p-exam
$(MAKE) -B $^
nikola build || { rm $@/busy ; exit 1; }
find $@ -type f | xargs -r chmod 0644
find $@ -type d | xargs -r chmod 0755
../is_clean.py | tee files/sentinel $@/sentinel # for the server
rm -fv $@/busy
touch $@
# $^ -> finished $@ at $(shell date)
continuous: all
while true ; do \
[ -e output/deploy ] || \
$(MAKE) -q -s latex output || \
$(MAKE) newest all; \
/bin/echo -n -e \\r $$(date +"%F %T.%N :") "" ; \
sleep 1; \
done
# $^ -> finished $@ at $(shell date)
tmux: all
./make.py
# $^ -> finished $@ at $(shell date)
latex: $(LATEX_SVGS) $(FILES_SVGS)
touch $@
# $^ -> finished $@ at $(shell date)
files/%.svg : latex/%.svg
ln -rs $< $@
latex/%.svg : latex/%.tex
$(MAKE) -C $(dir $@)
# $^ -> finished $@ at $(shell date)
latex-clean:
$(foreach folder, $(LATEX_FOLDERS), $(MAKE) -C $(folder) clean;)
# $^ -> finished $@ at $(shell date)
files: files/assets files/indices
make -C python/p-exam
touch $@
# $^ -> finished $@ at $(shell date)
files-clean:
$(LIST_IGNORED_FILES) files | xargs -r rm -v
while find files -type d -empty | xargs rmdir -v 2>/dev/null ; \
do : ; done
files/indices: $(DATE_UP_INDEX)
@ls -l $^ > $@
# finished $@ at $(shell date)
files/posts/%/index.html: posts/%
@mkdir -p $(dir $@) && cp -v files/pages/index.html $(dir $@)
files/assets: $(FAR_ASSET_FOLDERS)
@ls -lLd $^ > $@
# finished $@ at $(shell date)
files/%/assets: %/assets
@rm -fv $@
@mkdir -pv $(dir $@)
ln -rs $^ $@
listings: listings/auto
touch $@
# $^ -> finished $@ at $(shell date)
listings/auto: $(FAR_CODE_FOLDERS)
# finished $@ at $(shell date)
listings/%/code : %/code
@rm -fv $@
@mkdir -pv $(dir $(dir $@))
ln -rs $^ $(dir $(dir $@))
@mkdir -pv listings/auto
rm -fv listings/auto/$(notdir $*)
ln -rsv $@ listings/auto/$(notdir $*)
# $^ -> finished $@ at $(shell date)
listings-clean:
rm -rfv listings/auto
$(LIST_IGNORED_FILES) listings | xargs -r rm -v
while find listings -type d -empty | xargs rmdir -v 2>/dev/null ; \
do : ; done