4 CLEAN_FILE := $(shell pwd)/.clean
7 for file in "$$@"; do \
8 grep "^$$file"'$$' $(CLEAN_FILE) >/dev/null || echo $$file >>$(CLEAN_FILE); \
12 cmd := run() { tput bold; echo -e "--[ $$* ]"; tput sgr0; } && run
13 do := run() { tput bold; echo -e "--[ $$* ]"; tput sgr0; "$$@"; } && run
14 eval := run() { tput bold; echo -e "--[ $$* ]"; tput sgr0; eval "$$@"; } && run
20 $(Q)$(cmd) "rest2latex $< >$@"; \
23 --documentclass=scrreprt \
24 --documentoptions="10pt,a4paper,DIV10" \
25 --table-style=booktabs \
26 --use-verbatim-when-possible \
27 --use-latex-footnotes \
29 --no-section-numbering \
30 --stylesheet=default.sty \
33 > $@ || (rm -f $@; exit 1)
37 $(Q)$(cmd) "rawfilter $< >$@"; \
38 sed -e 's/\.\(png\|gif\|jpg\)/.pdf/g' \
39 -e 's/\[htbp\]/\[tbp\]/g' $< >$@ \
44 $(Q)$(cmd) "rest2html $< >$@"; \
45 up="`echo $< | sed -r -e 's,^[^/]*$$,,' -e 's,/[^/]+$$,/,' -e 's,[^/]+,..,g'`"; \
49 --stylesheet-path="$${up}default.css" \
51 > $@ || (rm -f $@; exit 1)
55 dir="$$(dirname $<)"; \
56 up="echo $$dir | sed -e 's,[^/]\+,..,g"; \
57 [ -n "$$dir" ] && dir="$$dir/"; \
58 stem="$$(basename $*)"; \
59 tex="$$(basename $<)"; \
60 pdf="$$(basename $@)"; \
61 $(clean) $${dir}texput.log; \
64 origfiles="$$(find $$stem.* ! \( -name $$pdf -o -name $$stem.log \) \
65 -maxdepth 0 -printf '%p-%TY%Tm%Td%TH%TM%TS\n')"; \
66 while [ $$repeat -gt 0 ]; do \
67 $(cmd) "pdflatex --interaction nonstopmode $$tex"; \
68 TEXINPUTS=.:$$up: pdflatex --interaction nonstopmode $$tex; \
70 auxfiles=$$((echo $$origfiles | tr ' ' '\n'; \
71 find $$stem.* ! \( -name $$pdf -o -name $$stem.log \) \
72 -maxdepth 0 -printf '%p-%TY%Tm%Td%TH%TM%TS\n') \
73 | sort | uniq -u | sed -e 's/-[0-9]*$$//' | sort -u ); \
74 for f in $$auxfiles; do \
78 [ $$pdfexit -ne 0 ] && exit $$pdfexit; \
79 newauxsum=`md5sum $$auxfiles | md5sum 2>/dev/null`; \
80 [ "$$auxsum" = "$$newauxsum" ] && break; \
81 auxsum="$$newauxsum"; \
82 repeat=$$[ $$repeat - 1 ]; \
84 ) || (rm -f $@; exit 1)
88 $(Q)$(cmd) "(openoffice) sxdtopng $<"; \
89 openoffice -invisible "macro:///Local.Conversion.ConvertDrawToPNG($(shell realpath $<))"
93 $(Q)$(cmd) "(openoffice) sxdtopdf $<"; \
94 openoffice -invisible "macro:///Local.Conversion.ConvertDrawToPDF($(shell realpath $<))"
98 $(Q)$(cmd) "(openoffice) sxctopdf $<"; \
99 openoffice -invisible "macro:///Local.Conversion.ConvertCalcToPDF($(shell realpath $<))"
103 $(Q)$(cmd) "pdftops $< >$@"; \
104 pdftops -eps -nocrop -noshrink -nocenter $< - | pstops - >$@ || (rm -f $@; exit 1)
108 $(Q)$(cmd) "pstopng $< >$@"; \
109 bb=$$(grep -i '^%%BoundingBox:' $< | head -1 | sed -e 's/^%%BoundingBox: *//i'); \
113 pngx=$$(dc -e "$$bbx $(PSTOPNG_DPI) * 8 * 75.45 / p"); \
114 pngy=$$(dc -e "$$bby $(PSTOPNG_DPI) * 8 * 75.45 / p"); \
115 pstopnm -xborder 0 -yborder 0 -portrait -nocrop -stdout -xsize $$pngx -ysize $$pngy $< \
116 | pnmscale -reduce 8 \
118 || (rm -f $@; exit 1)
122 $(Q)$(cmd) "pngtogif $< >$@"
123 $(Q)pngtopnm $< | ppmquant 256 | ppmtogif >$@ || ( rm -f $@; exit 1)
127 $(Q)$(eval) "dot -Tfig $< | fig2dev -L pdf -f Helvetica >$@" || ( rm -f $@; exit 1 )
131 $(Q)$(eval) "neato -Tfig $< | fig2dev -L pdf -f Helvetica >$@" || ( rm -f $@; exit 1 )
135 $(Q)$(do) dia -t eps -e $@ $<
139 $(Q)$(do) epstopdf --outfile=$@ $<
144 $(cmd) "makedep $<"; \
145 base="$$(dirname $<)"; \
146 [ -n "$$base" ] && base="$${base}/"; \
149 [ -r $$1 ] || return; \
150 includes="$$(sed -n -e 's/^.. \+include:: *//' -e T -e p $$1)"; \
151 for include in $$includes; do \
152 echo $$base$$include; \
153 scaninc $$base$$include; \
156 includes="$$(scaninc $<)"; \
157 figures="$$(sed -n -e "s,^.. \+figure:: *,$$base," -e T -e p $< $$includes)"; \
159 echo "$*_Includes := $$(echo $$includes)" >$@; \
160 echo "$*_Figures := $$(echo $$figures)" >>$@; \
161 echo "$*_PDFs := $$(echo $$figures | sed -e 's/\.\(gif\|png\|jpg\)/.pdf/g')" >>$@; \
162 echo '$@: Makefile $< $$($*_Includes)' >>$@; \
163 echo '$*.html: $< $$($*_Includes)' >>$@; \
164 echo '$*_html: $*.html $$($*_Figures)' >>$@; \
165 echo '$*.tex: $< $$($*_Includes)' >>$@; \
166 echo '$*.pdf: $*.tex $$($*_PDFs) $(TEX_STYLE)' >>$@
168 ###########################################################################
171 $(Q)if [ -r $(CLEAN_FILE) ]; then \
172 $(cmd) "xargs rm -f <.clean && rm -f .clean"; \
173 xargs rm -f <$(CLEAN_FILE) && rm -f $(CLEAN_FILE); \
178 # makefile-backslash-column: 100