fancy new Makefile from Bens upstream

This commit is contained in:
Benjamin Kellermann 2013-07-20 00:24:14 +02:00
parent 28ca034820
commit da194305d2
1 changed files with 18 additions and 31 deletions

View File

@ -1,6 +1,5 @@
############################################################################
# based on Makefile by
# Copyright 2009, 2010, 2011 Benjamin Kellermann #
# Copyright 2009-2013 Benjamin Kellermann, John #
# #
# This program is free software: you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the #
@ -23,9 +22,7 @@
############################################################################
# the documents to be compiled by default
#DOC=$(foreach i,$(filter-out $(wildcard *_notes.tex),$(shell grep -l documentclass *.tex)), $(basename $i))
DOC=schleuderbeispiel
DOC=$(foreach i,$(shell grep -l documentclass *.tex), $(basename $i))
# if svgs should be compiled as pdf or png
SVG_TARGET_EXT=pdf
@ -105,8 +102,9 @@ build-dep_%:
$(call checkForPGFrealjobname,$*)
$(VERBOSE)$(LATEXCMD) $*
make $*.bbl
make $*.gls;\
echo TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
if [ "`grep makeglossaries *.tex`" ];then\
make $*.gls;\
fi
$(VERBOSE) $(LATEXCMD) $*
$(VERBOSE) $(LATEXCMD) $*
@ -119,17 +117,10 @@ final: $(foreach i,$(DOC),$i_final.pdf)
mv $*_tmp.pdf $*.pdf
cp $*.pdf $*_final.pdf
publish: $(foreach i,$(DOC),publish_$i)
publish_%: %_final.pdf
scp $(foreach e,bib pdf,$(wildcard $*.$e)) $(PUBLISH)
@echo
@for i in $*.bib $*.pdf; do if [ -f $$i ]; then $(PRINTF) "$(PUBLISH_URL)/$$i\n"; fi; done
clean:
@rm -vf $(foreach ext,$(TEXEXT),*.$(ext))
@rm -vf $(PIC) $(TIKZPIC) $(STY)
@rm -vf $(foreach i,$(DOC),$i_notes.tex)
rm stats/*
distclean: $(foreach i,$(DOC),distclean_$i)
distclean_%: clean
@ -139,7 +130,7 @@ checkForRunningProcess = \
@if [ -f /tmp/$(1)_watch.pid ];then\
WATCHID=`cat /tmp/$(1)_watch.pid`;\
if [ `ps --pid $$WATCHID|wc -l` = 2 ];then\
$(PRINTF) "There is a \"make watch\" running!\n";\
$(PRINTF) "\033[31mThere is a \"make watch\" running!\033[0m\n";\
return 1;\
fi;\
fi
@ -154,7 +145,7 @@ checkForPGFrealjobname = \
fi;\
done;\
if [ "$$PGFREALJOBNAMEOCCURED" = "false" ]; then\
$(PRINTF) "\\pgfrealjobname{} is set to a wrong value! I expected:\n\\pgfrealjobname{$*}\n";\
$(PRINTF) "\033[31m\\pgfrealjobname{} is set to a wrong value! I expected:\n\\pgfrealjobname{$*}\033[0m\n";\
return 1;\
fi;\
fi
@ -173,7 +164,7 @@ ADDITIONALDIRS=$(wildcard ~/texmf/)
endif
watch: $(foreach i,$(DOC),watch_$i)
watch_%: build-dep_%
watch_%: %.pdf
$(call checkForRunningProcess,$*)
$(PRINTF) $$PPID > /tmp/$*_watch.pid
if [ `ls -l *.tex.latexmain|wc -l` != 1 ]; then\
@ -229,12 +220,14 @@ watch_%: build-dep_%
fi;\
if [ $$LACHECK = true ];then lacheck $$FILE; fi;\
cat /tmp/make_watch_duration;\
if [ $$BIBTEX = true ];then $(PRINTF) "I ran BibTeX, therefore compilation took a bit longer.\n"; fi;\
if [ $$GLOSSARIES = true ];then $(PRINTF) "I ran makeglossaries, therefore compilation took a bit longer.\n"; fi;\
notify-send --expire-time=1000 --hint=int:transient:1 -a "LaTeX" "pdflatex compiled successfull" "`cat /tmp/make_watch_duration`";\
if [ $$BIBTEX = true ];then $(PRINTF) "\033[33mI ran BibTeX, therefore compilation took a bit longer.\033[0m\n"; fi;\
if [ $$GLOSSARIES = true ];then $(PRINTF) "\033[33mI ran makeglossaries, therefore compilation took a bit longer.\033[0m\n"; fi;\
$(call cpTmp,$*)\
else\
if [ $$LACHECK = true ];then lacheck $$FILE; fi;\
$(PRINTF) "SOMETHING WENT WRONG, PLEASE CHECK THE CONSOLE!!!\n";\
$(PRINTF) "\033[31mSOMETHING WENT WRONG, PLEASE CHECK THE CONSOLE!!!\033[0m\n";\
notify-send --expire-time=1000 --hint=int:transient:1 "ERROR: pdflatex; Compilefile: $$COMPILEFILE";\
fi;\
done
@ -247,17 +240,11 @@ watchtikz_%: %.pdf
if [ $$? -eq 0 ];then\
cp $*.pdf /tmp/$<;\
else\
$(PRINTF) "SOMETHING WENT WRONG, PLEASE CHECK THE CONSOLE!!!\n";\
$(PRINTF) "\033[31mSOMETHING WENT WRONG, PLEASE CHECK THE CONSOLE!!!\033[0m\n";\
fi;\
done
stats:
mkdir -p stats
rm -rf stats/*
gitstats .git stats
.PHONY: default final clean distclean watch tikzpics $(PICDIR) build-dep stats
.PHONY: default final clean distclean watch tikzpics $(PICDIR) build-dep
.SECONDARY:
@ -265,9 +252,6 @@ stats:
rm -f $@
$(LATEXCMD) $*.ins
%_notes.tex: %.tex
sed -e 's/\\begin{document}/\\usepackage[previewfilename=$*]{bensbeamernotepage}\\begin{document}/g' $< > $@
%.tex: %.tex.erb *.rb
erb $< >$@
@ -292,3 +276,6 @@ $(PICDIR)/%.pdf: $(PICDIR)/%.svg
$(PICDIR)/%.png: $(PICDIR)/%.svg
inkscape --export-png=$@ -w1000 $<
$(PICDIR)/%_gray.png: $(PICDIR)/%.png
convert -colorspace gray $< $@