forked from CS234319/safot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
171 lines (146 loc) · 5.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.PHONY: default
# Normally, this file should not be modified. But you are encouraged to read it
# and learn how to modify its behavior by adding to the variables defined here,
# or overriding them altogether.
#
# Settings //vim: /=/,/^\s*$/-! sort -u
DUP = ../Programs/dup
LANG_TOOL = ../Programs/LanguageTool-3.2/languagetool-commandline.jar
LATEX_COMMAND = lualatex
LATEX_FLAGS = -file-line-error- -synctex=1 # -halt-on-error
LATEX = $(LATEX_COMMAND) $(LATEX_FLAGS)
LOCALTEXMF = ~/texmf # Comment or change if necessary.
MAIN = 00
SOURCES = $(wildcard *.sty *.tex) $(LISTINGS) Makefile
TARGETS = $(MAIN).pdf
TMP := $(shell mktemp -d)
latex:
# This is our first target. It would become your default if you include this
# file, without defining an targets before it. It is OK to use a target whose
# main body is defined later.
.PHONY: help
help:
@echo $(if $(need-help),,Type \'$(MAKE) help\' to get help)
need-help := $(filter help,$(MAKECMDGOALS))
define tip
$(if $(need-help),$(warning $1 -- $2))
endef
# Compound:
ifdef LOCALTEXMF
export TEXINPUTS=:$(LOCALTEXMF)
export BIBINPUTS=:$(LOCALTEXMF)
endif
.PHONY: status
status: $(call tip,status,file status, what's made, and what's not.)
@ echo $(words $(SOURCES)) source files:
@ wc -l $(SOURCES)
@ echo $(G0) garbage files, sized $(G1) bytes:
@ wc -l $(garbage)
# Target to be used for compiles when references did not change
.PHONY: view
view: $(call tip,view,open a PDF viewer on made output) $(MAIN).pdf
@ (okular --unique $(MAIN).pdf &> /dev/null > /dev/null &)
.PHONY: clean
clean: $(call tip,clean,\
move all auotmatically-generated-files (currently $(G0)) to /tmp)
@ - [ -z '$(garbage)' ] || mv -f $(garbage) $(TMP)
@ - [ $(G0) -gt 1 ] && echo $(G0) files moved to $(TMP) [$(G1) bytes] || true
@ - [ $(G0) -eq 1 ] && echo $(G0) file moved to $(TMP) [$(G1) bytes] || true
@ - [ $(G0) -eq 0 ] && echo already clean || true
.PHONY: latex
latex: $(call tip,latex, run latex to make $(MAIN).pdf) $(MAIN).pdf
$(LATEX) ./$(MAIN).tex
.PHONY: force
force: $(call tip,force, alias of 'latex')
texfot $(LATEX) ./$(MAIN).tex
$(MAIN).pdf: $(call tip,$(MAIN).pdf,our main latex target) $(SOURCES)
texfot $(LATEX) ./$(MAIN).tex
.PHONY: all
all: $(call tip,all,recreate all targets (currently $(TARGETS))) $(TARGETS)
.PHONY: silent
silent: $(call tip,silent,remake $(MAIN).pdf but silently) $(MAIN).pdf $(SOURCES) Makefile
$(LATEX) -interaction=batchmode $(MAIN).tex
.PHONY: again
again: $(call tip,again,alias for 'silent' remake $(MAIN).pdf but silently) silent
.PHONY: write18
write18: $(call tip,write18,remake $(MAIN).pdf with -shell-escape) $(SOURCES) $(LISTINGS)
$(LATEX) -draftmode -shell-escape ./$(MAIN).tex
.PHONY: bibtex
$(MAIN).blg bibtex: $(call tip,bibtex, regenerate the bibliogrpahy)
$(LATEX) -interaction=batchmode -draftmode $(MAIN).tex
bibtex $(MAIN)
$(LATEX) -interaction=batchmode -draftmode ./$(MAIN).tex
.PHONY: all
all: write18 bibtex latex
.PHONY: warnings
warnings: $(call tip,warnings,present all LaTeX warnings)
$(LATEX) -interaction=batchmode -draftmoe -recorder 00.tex 2>&1 | grep --color=auto -E "Warning|Missing"
.PHONY: lacheck
lacheck: $(call tip,lachek,run lacheck on all sources)
lacheck *.tex
.PHONY: aspell
aspell: $(call tip,aspell,run aspell on all sources)
for f in *.tex ; do if [ $$f != 00.tex ]; then aspell check $$f;fi; done
dup: $(call tip,dup,run dup on all sources)
@ for f in *.tex ; do if [ $$f != 00.tex ]; then echo dup $$f; $(DUP) $$f;fi; done
lt: $(call tip,lt,run language-tool on all sources)
for f in *.tex ; do if [ $$f != 00.tex ]; then echo lt $$f; detex $$f > $(TMP)/$$f | java -jar $(LANG_TOOL) $(TMP)/$$f ; fi; done
.PHONY: rebuild
rebuild: $(call tip,rebuild,same as 'make clean'; try writing 'make rebuild all') clean
.PHONY: anew
anew: $(call tip,anew,same as 'make clean'; try writing 'make anew $(firstword $(TARGETS))') clean
###############################################################################
# Garbage
###############################################################################
# vim: /=/+,/^\s*)\s*)\s*$/-1!column -t | sort -u | awk '{print "\t" $0}'
garbage := $(sort $(wildcard \
*~ \
*.aux \
temp* \
*.backup \
*.bak \
*.bbl \
*.bcf \
*.blg \
*.kernel.lisp \
*.library.lisp \
*.kernel.[0-9]*.lisp \
*.library.[0-9]*.lisp \
*blx.bib \
*.class \
*[dD][eE][lL][mM][eE]* \
*.detexed \
*.dvi \
*.eho \
*.fdb_ \
*.fdb_latexmk \
*.fls \
*.glo \
*gnuplottex-fig[0-9]*.* \
*.heo \
*.ist \
*.listing \
*.lof \
*.log \
*.lop \
*.lot \
*.maf \
*.mtc \
*.mtc[0-9] \
*.mtc[0-9][0-9] \
*.o \
*.out \
*.run.xml \
.*swo \
.*swp \
*.synctex.gz \
$(TARGETS) \
*.toc \
hello.c \
*.vtc \
temp*.* \
))
G0 := $(words $(garbage)) # 0th moment, i.e., garbage count
G1 := $(shell ls -ls $(garbage)| tee $(TMP)/files.lst | awk "{t+=$$$$6}END{print t}")
garbage+:=$(wildcard 00/ )
LATEX_COMMAND=xelatex