2018-03-20 17:23:05 +01:00
|
|
|
# Makefile for generating pdf from latex files
|
|
|
|
# -dependency support
|
2021-12-03 10:39:14 +01:00
|
|
|
# -pdf generation of svg files
|
2018-03-20 17:23:05 +01:00
|
|
|
# -pdf generation of dot files
|
|
|
|
#
|
|
|
|
# Author : Dominik Meyer <dmeyer@hsu-hh.de>
|
|
|
|
# Date : 2017-11-22
|
|
|
|
# License : GPLv2
|
|
|
|
#
|
2021-12-03 13:26:08 +01:00
|
|
|
SHELL := /bin/bash
|
2018-03-20 17:23:05 +01:00
|
|
|
DEPDIR := .d
|
|
|
|
$(shell mkdir -p $(DEPDIR) >/dev/null)
|
2019-07-31 10:40:16 +02:00
|
|
|
GITDIR = $(shell git rev-parse --show-toplevel)/
|
2018-03-20 17:23:05 +01:00
|
|
|
export $TEXINPUTS
|
|
|
|
|
|
|
|
DEPFLAGS = -M -MP -MF $(DEPDIR)/$*.d
|
|
|
|
|
2019-05-28 13:50:14 +02:00
|
|
|
|
|
|
|
ifneq ("$(wildcard .pdflatex)","")
|
|
|
|
LATEXMK=export TEXINPUTS=$(TEXINPUTS);latexmk -use-make -f $(DEPFLAGS) -pdf $(subst .pdf,.tex,$@) 1>>$(subst .pdf,.log,$@) 2>>$(subst .pdf,.log,$@)
|
|
|
|
else
|
|
|
|
LATEXMK=export TEXINPUTS=$(TEXINPUTS);latexmk -use-make -f $(DEPFLAGS) -pdflua $(subst .pdf,.tex,$@) 1>>$(subst .pdf,.log,$@) 2>>$(subst .pdf,.log,$@)
|
|
|
|
endif
|
2018-03-20 17:23:05 +01:00
|
|
|
|
2021-12-03 13:26:08 +01:00
|
|
|
INKSCAPE_EXIST=$(shell which inkscape >/dev/null;echo $$?)
|
|
|
|
|
|
|
|
ifeq ($(INKSCAPE_EXIST),0)
|
|
|
|
# identify used inkscape version and set command
|
|
|
|
INKSCAPE_BASE=$(shell which inkscape)
|
|
|
|
|
|
|
|
INKSCAPE_VERSION=$(shell $(INKSCAPE_BASE) --version 2>/dev/null | cut -d " " -f 2 | cut -d . -f 1)
|
|
|
|
|
|
|
|
ifeq ($(INKSCAPE_VERSION),0)
|
|
|
|
INKSCAPE = "echo \"$< --export-pdf=$@\" | DISPLAY= $(INKSCAPE_BASE) -D -y 0 --shell >/dev/null"
|
|
|
|
else
|
|
|
|
INKSCAPE = "$(INKSCAPE_BASE) --export-type=pdf -o $@ $<"
|
|
|
|
endif
|
2021-12-03 10:39:14 +01:00
|
|
|
|
|
|
|
endif
|
|
|
|
|
2018-03-20 17:23:05 +01:00
|
|
|
.SECONDARY: .latexmkrc
|
2021-12-03 20:18:38 +01:00
|
|
|
.PHONY: clean watermark IEEE base
|
2018-03-20 17:23:05 +01:00
|
|
|
|
|
|
|
%.pdf : %.dot
|
|
|
|
@echo "**** Generating $@ from dot file $< ****"
|
|
|
|
@dot -Tpdf $< -o $@
|
|
|
|
@touch $@.dep
|
|
|
|
|
2021-12-08 12:27:49 +01:00
|
|
|
%.svg: %.drawio.svg
|
|
|
|
@echo "**** Renaming drawio file $< *****"
|
|
|
|
@cp $< $@
|
|
|
|
@touch $@.dep
|
|
|
|
|
2018-03-20 17:23:05 +01:00
|
|
|
%.pdf: %.svg
|
|
|
|
@echo "**** Generating $@ from svg file $< ****"
|
2021-12-03 13:26:08 +01:00
|
|
|
@if [ $(INKSCAPE_EXIST) != "0" ]; then echo "The inkscape tool required for converting svg --> pdf is missing. Please install it"; exit -1; fi
|
2021-12-03 10:39:14 +01:00
|
|
|
@if [ "$(INKSCAPE_VERSION)" -eq "0" ]; then echo "$<" --export-pdf=$@ | DISPLAY= $(INKSCAPE_BASE) -D -y 0 --shell >/dev/null; fi
|
2021-12-03 13:26:08 +01:00
|
|
|
@if [ "$(INKSCAPE_VERSION)" -eq "1" ]; then $(INKSCAPE_BASE) --export-type=pdf -o $@ $< 1>/dev/null 2>/dev/null; fi
|
2018-03-20 17:23:05 +01:00
|
|
|
@touch $@.dep
|
|
|
|
|
|
|
|
%.pdf: $(DEPDIR)/%.d
|
|
|
|
@echo "**** Generating $@ ****"
|
|
|
|
@if [ -e $(subst .pdf,.log,$@) ]; then rm $(subst .pdf,.log,$@); fi
|
|
|
|
@$(LATEXMK) || ( if [ -e $@ ]; then rm $@; fi; $(LATEXMK))
|
|
|
|
@touch $@
|
|
|
|
@echo "**** log file $(subst .pdf, .log,$@)"
|
|
|
|
|
|
|
|
$(DEPDIR)/%.d: ;
|
|
|
|
.PRECIOUS: $(DEPDIR)/%.d
|
|
|
|
|
2018-03-20 17:32:23 +01:00
|
|
|
IEEE: IEEEtran.cls
|
|
|
|
|
|
|
|
IEEEtran.cls:
|
|
|
|
@wget https://www.ieee.org/documents/ieee-latex-conference-template.zip 1>/dev/null 2>/dev/null
|
|
|
|
@unzip -j ieee-latex-conference-template.zip IEEEtran/IEEEtran.cls >/dev/null
|
|
|
|
@rm ieee-latex-conference-template.zip
|
|
|
|
|
2019-07-21 21:38:23 +02:00
|
|
|
base: .gitignore .latexmkrc ${GITDIR}/.git/hooks/post-commit
|
2018-03-28 13:58:34 +02:00
|
|
|
|
2019-07-21 21:38:23 +02:00
|
|
|
${GITDIR}/.git/hooks/post-commit ${GITDIR}.git/hooks/post-merge ${GITDIR}.git/hooks/post-checkout: ${MakefileBase}/post-commit
|
|
|
|
cp ${MakefileBase}/post-commit ${GITDIR}.git/hooks/
|
|
|
|
cp ${MakefileBase}/post-commit ${GITDIR}.git/hooks/post-merge
|
|
|
|
cp ${MakefileBase}/post-commit ${GITDIR}.git/hooks/post-checkout
|
|
|
|
chmod u+x ${GITDIR}/.git/hooks/*
|
|
|
|
${GITDIR}/.git/hooks/post-commit
|
2018-03-20 17:38:04 +01:00
|
|
|
|
|
|
|
.gitignore:
|
|
|
|
@echo *.pdf >> .gitignore
|
|
|
|
@echo *.aux >> .gitignore
|
|
|
|
@echo *.bbl >> .gitignore
|
|
|
|
@echo *.bcf >> .gitignore
|
|
|
|
@echo *.blg >> .gitignore
|
|
|
|
@echo *.dvi >> .gitignore
|
|
|
|
@echo *.log >> .gitignore
|
|
|
|
@echo *.run.xml >> .gitignore
|
|
|
|
@echo *.fls >> .gitignore
|
|
|
|
@echo *.*latexmk >> .gitignore
|
|
|
|
@echo *.files >> .gitignore
|
|
|
|
@echo *-blx.bib >> .gitignore
|
|
|
|
@echo *.out >> .gitignore
|
|
|
|
@echo **/*.dep >> .gitignore
|
|
|
|
@echo .d >> .gitignore
|
|
|
|
|
|
|
|
.latexmkrc:
|
2019-07-21 21:38:23 +02:00
|
|
|
@cp ${MakefileBase}/.latexmkrc . >> $@
|
2018-03-20 17:38:04 +01:00
|
|
|
|
2018-03-20 17:23:05 +01:00
|
|
|
watermark.tex:
|
2019-07-21 21:38:23 +02:00
|
|
|
cp ${MakefileBase}/watermark.tex $@
|
2018-03-20 17:23:05 +01:00
|
|
|
|
|
|
|
watermark: all watermark.tex
|
|
|
|
sed -i 's/<email>/$(EMAIL)/g' watermark.tex
|
|
|
|
latexmk -pdf watermark.tex
|
|
|
|
pdftk paper.pdf stamp watermark.pdf output paper_watermark.pdf
|
|
|
|
rm -rf watermark.*
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@-rm -rf .d
|
|
|
|
@-rm -rf *.pdata
|
|
|
|
@-rm -rf *.pdf
|
|
|
|
@-rm -rf *.bcf
|
|
|
|
@-rm -rf *.aux
|
|
|
|
@-rm -rf *.bbl
|
|
|
|
@-rm -rf *.blg
|
|
|
|
@-rm -rf *.dvi
|
|
|
|
@-rm -rf *.ps
|
|
|
|
@-rm -rf *.log
|
|
|
|
@-rm -rf *.run.xml
|
|
|
|
@-rm -rf *.fls
|
|
|
|
@-rm -rf *.*latexmk
|
|
|
|
@-rm -rf *-blx.bib
|
|
|
|
@-rm -rf *.out
|
|
|
|
@-rm -rf *.toc
|
|
|
|
@-rm -rf *.nav
|
|
|
|
@-rm -rf *.snm
|
|
|
|
@-rm -rf *.vrb
|
2019-05-28 13:50:14 +02:00
|
|
|
@-for i in `find . -name '*.dep'`; do f=`echo $$i | sed 's/.dep//'`; rm $$f; rm $$i; done
|
2018-03-20 17:23:05 +01:00
|
|
|
|
|
|
|
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))))
|