From 2a06eb8b7e7942a3783453c4027a76dcd61e00bd Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Sun, 5 May 2019 22:07:45 +0200 Subject: [PATCH] makefile for parallel compiling --- MakeFile | 74 -------------------------------------------------------- Makefile | 36 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 74 deletions(-) delete mode 100755 MakeFile create mode 100755 Makefile diff --git a/MakeFile b/MakeFile deleted file mode 100755 index 18b52ae..0000000 --- a/MakeFile +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/make -f -# -# Requires latexmk. -# -# Maxime Bombar - -## This Makefile is used to build pdf from a latex project. Use ```make help``` to display a summary of the rules. -## -## make MyFancyProject.pdf : Builds MyFancyProject.pdf (and auxiliary files) from MyFancyProject.tex and fails if it doesn't exist. -## make MyFancyProject.warn : Displays how many warnings and bad boxes there are when compiling MyFancyProject. -## make MyFancyProject.showwarn : Displays the warnings and bad boxes for MyFancyProject. - -.PHONY: all help clean cleanall -SHELL = /bin/bash - - -# latexmk is a swiss army knife of latex compilation. Option -pdf to output the pdf. -PDFLATEX := latexmk -pdf -shell-escape -CMD = cat $*.log | grep -iE -REGEXBOX := full..hbox -WARNINGS := warning - - -TEXDOCS = $(wildcard *.tex) -PDF := $(patsubst %.tex,%.pdf, $(TEXDOCS)) -OUT := $(patsubst %.tex,%.out, $(TEXDOCS)) -LOG := $(patsubst %.tex,%.log, $(TEXDOCS)) - - -# Prevents some intermediate files to be automatically deleted... -.PRECIOUS: %.log %.pdf Makefile - -%.log: %.tex - $(PDFLATEX) $< - -%.warn: %.log - @echo "${shell echo 'There are $$(( $$($(CMD) $(WARNINGS) | wc -l)-1 ))' warning\(s\)}" - @echo "${shell echo 'There are $$($(CMD) $(REGEXBOX) | wc -l)' bad boxe\(s\)}" - -%.showwarn: %.log - @echo "${shell echo 'There are $$(( $$($(CMD) $(WARNINGS) | wc -l)-1 ))' warning\(s\) for $*:}" - @echo "${shell echo '$$( $(CMD) $(WARNINGS) | tail +2)' }" - @echo "${shell echo $(\n)}" - @echo "${shell echo 'There are $$($(CMD) $(REGEXBOX) | wc -l)' bad boxe\(s\) for $*:}" - @echo "${shell echo '$$( $(CMD) $(REGEXBOX))' }" - -%.pdf: %.log - @echo "${shell echo 'There are $$(( $$($(CMD) $(WARNINGS) | wc -l)-1 ))' warning\(s\)}" - @echo "${shell echo 'There are $$($(CMD) $(REGEXBOX) | wc -l)' bad boxe\(s\)}" - -## make all : Builds every file in the current directory. -all: $(TEXDOCS) - $(PDFLATEX) $^ - -## make rebuild : Cleans and rebuilds every file. -rebuild: cleanall all - -## make clean : Removes every auto-generated file except for pdf. -clean: - @echo -n "aux bbl blg dvi fdb_latexmk fls nav snm tdo toc thm vrb"|xargs -t -d ' ' -n 1 -I {} find . -iname "*.{}" -delete - rm -f $(OUT) - rm -f $(LOG) - find . -iname "*flymake*" -delete - find . -iname "*~" -delete - find . -iname "\#*" -delete - find . -type d -iname 'auto' -exec rm -rf {} + - -## make cleanall : Removes every auto-generated file. -cleanall: clean - rm -f $(PDF) - -## make help : Displays this help. -help: Makefile - @sed -n 's/^##//p' $< diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..410be84 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +#!/usr/bin/make -f +# +# Requires latexmk. +# +.PHONY: all +SHELL = /bin/bash + + +TEX_COMMAND = latexmk -pdf -shell-escape --quiet + +TEX_FILES = $(wildcard **/**/main.tex) + +PDF_FILES = $(TEX_FILES:tex=pdf) + +OUTPUT_FILES = $(subst /,-,$(dir $(PDF_FILES))) + +all: $(PDF_FILES) + @rm -rf ./public + @mkdir public + +$(PDF_FILES): $(TEX_FILES) + cd ./$(dir $@); \ + $(TEX_COMMAND) $(notdir $<); + cd ../../ + cp $@ public/$(subst /,-,$@) + + +clean: + @echo -n " out log aux bbl blg dvi fdb_latexmk fls nav snm tdo toc thm vrb"|xargs -t -d ' ' -n 1 -I {} find . -iname "*.{}" -delete + find . -iname "*flymake*" -delete + find . -iname "*~" -delete + find . -iname "\#*" -delete + find . -type d -iname 'auto' -exec rm -rf {} + + +cleanall: clean + rm -f $(PDF_FILES)