From 5fc352517d82a11fa619a349af9985ae5dffbacf Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Tue, 13 Aug 2019 19:10:55 +0200 Subject: ... --- Makefile | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a48ac73 --- /dev/null +++ b/Makefile @@ -0,0 +1,65 @@ +################################################################################ +## Document Parameters ######################################################### +################################################################################ +# Name of the main file, without the .tex extension. +DOCUMENT_FILENAME ?= main + +################################################################################ +## Binaries #################################################################### +################################################################################ +PDFLATEX ?= pdflatex + +################################################################################ +## Deducing Main Target ######################################################## +################################################################################ +ifeq ($(strip $(PDFVIEWER)),) +main_target: compile + +else +main_target: view + +endif + +################################################################################ +## Basic Makefile Shenanigans ################################################## +################################################################################ +COMMA =, + +################################################################################ +## Localising Relevant Files ################################################### +################################################################################ +TEX_FILES = $(shell find ${CURDIR} -iname \*.tex) + +################################################################################ +## Making the Actual PDF ####################################################### +################################################################################ +$(DOCUMENT_FILENAME).pdf: $(TEX_FILES) Makefile + $(PDFLATEX) $(DOCUMENT_FILENAME).tex + $(PDFLATEX) $(DOCUMENT_FILENAME).tex + grep -i "\\(Reference\\|Citation\\).*undefined" \ + $(DOCUMENT_FILENAME).log || true + +################################################################################ +## Secondary Targets ########################################################### +################################################################################ +view: compile + $(PDFVIEWER) $(DOCUMENT_FILENAME).pdf + +compile: $(DOCUMENT_FILENAME).pdf + $(MAKE) clean_mess + +edit: + $(EDITOR) $(TEX_FILES) + +clean: + rm -f \ + $(filter-out $(DOCUMENT_FILENAME).tex,$(wildcard $(DOCUMENT_FILENAME).*)) + +################################################################################ +clean_mess: + rm -f \ + $(filter-out $(DOCUMENT_FILENAME).tex, \ + $(filter-out $(DOCUMENT_FILENAME).pdf, \ + $(wildcard $(DOCUMENT_FILENAME)\.*) \ + ) \ + ) -- cgit v1.2.3-70-g09d2