# *** DO NOT EDIT THIS FILE EXCEPT IN THE PROJECT HOME DIRECTORY *** # Relative path to the project home directory. # For makefile in every directory other than $(PROJECT_HOME) this is # automatically set by "make makefiles" PROJECT_HOME = ../. SHELL = /bin/bash CD = cd -P EXTRA_TEX_PREAMBLE = -include $(PROJECT_HOME)/makefile.project # The path to this project subdir, relative to $(PROJECT_HOME). # For makefile in every directory other than $(PROJECT_HOME) # this is automatically set by "make makefiles". PROJECT_PATH = ./HW6 EXCLUDE_SUBDIRS += . .. CVS .svn $(wildcard gen-*) src PROJECT_SUBDIRS = $(filter-out $(EXCLUDE_SUBDIRS),$(notdir $(shell find . -maxdepth 1 -type d -not -name ".*.tmp"))) SUBDIR_MAKEFILES = $(addsuffix /makefile,$(PROJECT_SUBDIRS)) MD_MACROS = $(PROJECT_HOME)/include/md-macros.m4 MD += $(wildcard *.md) M4D += $(wildcard *.m4d) GEN_MD = $(M4D:.m4d=.md) MD_HTML += $(M4D:.m4d=.html) MD_HTML += $(MD:.md=.html) MD_HTML := $(sort $(MD_HTML)) #MD_PDF += $(MD:.md=.pdf) #don't gen pdf by default HTMLOPTS += --standalone --smart --gladtex PDPDFOPTS += --smart SUBDIR_DEPS += $(MD_HTML) $(MD_PDF) PUBLISH_RSYNC_FILTERS = \ --filter="+ gen-images*/" \ --filter="- gen-*" \ --filter="- *private*" \ --filter='- src/' \ --filter='- scripts/' \ --filter='- .svn/' \ --filter='- E*/' \ --filter='+ *.html' \ --filter='+ *.css' \ --filter='+ *.png' \ --filter='+ *.gif' \ --filter='+ *.jpg' \ --filter='+ *.JPG' \ --filter='+ *.avi' \ --filter='+ *.pdf' \ --filter='+ *.java' \ --filter='+ *.c' \ --filter='+ *.h' \ --filter='+ *.cpp' \ --filter='+ *.hpp' \ --filter='+ makefile' \ --filter='+ *.exe' \ --filter='+ bin/**' \ --filter='+ *.tri' \ --filter='+ *.stl' \ --filter='+ *.dae' \ --filter='+ *.ply' \ --filter='+ *.rts' \ --filter='+ .ht*' \ --filter='+ */' \ --filter='- *' # function to make a target recursively # first argument is target to make # second argument is "true" to continue on fail, "false" to stop on fail recursively-make = $(foreach DIR,$(PROJECT_SUBDIRS),[ ! -d $(DIR) ] || pushd $(DIR) > /dev/null && ( $(MAKE) $(1) || $(2) ) && popd > /dev/null && ) true # function to make something from $(PROJECT_HOME) make-from-project-home = \ @echo making $(1) from $(PROJECT_HOME); \ $(CD) $(PROJECT_HOME) && $(MAKE) $(1) # recursively make something %.recursive: # @echo recursively making $(basename $@) $(MAKE) $(basename $@) $(call recursively-make,$@,true) -include makefile.dir default: subdir .PHONY: FORCE FORCE: gen-header.html: FORCE echo "" > $@ gen-footer.html: FORCE echo "
" > $@ gen-header.tex: FORCE echo "\usepackage{amsmath} \usepackage{amssymb}" > $@ echo $(EXTRA_TEX_PREAMBLE) > $@ %.md: %.m4d makefile $(MD_MACROS) m4 -P "-I$(PROJECT_HOME)/include" $(MD_MACROS) $< > $@ %.htex: %.md makefile gen-header.html gen-footer.html $(EXTRA_HTML_DEPS) pandoc $(HTMLOPTS) -H gen-header.html -A gen-footer.html -o $@ $< %.html: %.htex if [[ ! -d gen-images-$(basename $@) ]]; then mkdir gen-images-$(basename $@); fi gladtex -p $(EXTRA_TEX_PREAMBLE) -d gen-images-$(basename $@) $< if [[ `ls gen-images-$(basename $@)/*.png 2> /dev/null | wc -l` == 0 ]]; then $(RM) -rf gen-images-$(basename $@); fi %.pdf: %.md $(CSS) makefile gen-header.tex markdown2pdf $(PDPDFOPTS) -H gen-header.tex -o $@ $< %.pdf: %.svg inkscape -z -T -A ./$@ $< %.pdf: %.png convert $< -density 300 $@ %.pdf: %.jpg convert $< -density 300 $@ %.pdf: %.tex FORCE pdflatex $< .PHONY: clean clean: $(EXTRA_CLEAN_DEPS) rm -f $(GEN_MD) $(MD_HTML) $(MD_PDF) *~ gen-*.html gen-*.tex *.htex rm -rf gen-images-* # whitespace regex WS = [ \t]* $(SUBDIR_MAKEFILES): makefile @if [ -e $@ ] && [ `grep -c "DO NOT EDIT" $@ 2> /dev/null ` -eq 0 ]; \ then echo "$@ exists but is not generated, skipping"; \ else echo "(re)making $@" && \ $(RM) $@ && \ sed \ -e 's|^$(WS)PROJECT_HOME$(WS)=$(WS)\(.*\)$(WS)|PROJECT_HOME = ../\1|' \ -e 's/^$(WS)PROJECT_PATH$(WS)=$(WS)\(.*\)$(WS)/PROJECT_PATH = \1\/$(subst /,,$(dir $@))/' \ -e 's/^$(WS)if-root-package$(WS)=.*/if-root-package = $$(2)/' \ makefile > $@; fi .PHONY: makefiles makefiles: $(SUBDIR_MAKEFILES) @echo making makefiles @$(call recursively-make,makefiles,true) .PHONY: subdir subdir: $(EXTRA_SUBDIR_DEPS) $(SUBDIR_DEPS) .PHONY: project-announce project-announce: @echo making project .PHONY: project project: project-announce $(call make-from-project-home,subdir.recursive) .PHONY: project-clean project-clean: $(call make-from-project-home,clean.recursive) .PHONY: publish publish: $(call make-from-project-home,publish.impl) .PHONY: publish.impl publish.impl: rsync -Crav --progress --chmod='go+r' --copy-links $(PUBLISH_RSYNC_FILTERS) * $(PUBLISH_DEST) .PHONY: show-settings show-settings: @echo "PROJECT_HOME=$(PROJECT_HOME)" @echo "PROJECT_PATH=$(PROJECT_PATH)" @echo "PROJECT_SUBDIRS=$(PROJECT_SUBDIRS)" @echo "SUBDIR_MAKEFILES=$(SUBDIR_MAKEFILES)" @echo "EXTRA_HTML_DEPS=$(EXTRA_HTML_DEPS)" @echo "MD=$(MD)" @echo "M4D=$(M4D)" @echo "GEN_MD=$(GEN_MD)" @echo "MD_HTML=$(MD_HTML)" @echo "MD_PDF=$(MD_PDF)"