-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
2407 lines (2082 loc) · 69.1 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# @file Makefile
#
# Makefile for typesetting LaTeX documents. Requires GNU Make 3.81 on Linux.
# See "make help".
#
# This file is provided under the MIT License:
#
# MIT License
#
# Copyright (c) 2018-2024 Takahiro Ueda
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
MAKEFILE4LATEX_VERSION = 0.11.2-dev
define help_message
Makefile for LaTeX ($(MAKEFILE4LATEX_VERSION))
Usage
make [<targets...>]
Targets
all (default):
Build all documents in the current directory.
all-recursive:
Build all documents in the source tree.
dvi, ps, pdf, eps, svg, jpg, png:
Build all documents with the specified file format in the current directory.
help:
Show this message.
clean:
Delete all files created by this Makefile.
mostlyclean:
Delete only intermediate files created by this Makefile.
pretty:
Run code prettifiers for source files in the current directory.
lint:
Run linters for source files in the current directory.
dist:
Create tar-gzipped archives for arXiv submission.
watch:
Watch the changes and automatically rebuild documents.
upgrade:
Upgrade the setup.
See also
https://github.com/tueda/makefile4latex
endef
# The default target of this Makefile tries to create this type of files from
# all *.tex:
# - dvi
# - ps
# - pdf (default)
default_target = pdf
# The toolchain for typesetting:
# - latex_dvips
# - latex_dvipdf
# - platex_dvips
# - platex_dvipdfmx
# - uplatex_dvips
# - uplatex_dvipdfmx
# - pdflatex (default)
# - xelatex
# - lualatex
# - luajitlatex
# Aliases:
# - latex -> latex_dvips
# - platex -> platex_dvips
# - uplatex -> uplatex_dvips
TOOLCHAIN = pdflatex
# Specify a commit range for latexdiff.
DIFF =
# Number of iterations for typesetting.
MAXREPEAT = 5
# Build directory.
BUILDDIR =
# Use latex-dev if DEV is defined.
DEV =
# (for debugging) Keep temporary directories if its value is non-empty.
KEEP_TEMP =
# Specify the color mode in the output:
# - always
# - never
# - auto (default)
COLOR =
# Specify whether *-eps-converted-to.pdf files are moved to BUILDDIR.
# - always
# - never
# - auto (default)
USE_BUILDDIR_FOR_EPSTOPDF =
# Files not to be included in a distribution.
NODISTFILES =
# Extra files to be included in a distribution.
EXTRADISTFILES =
# Files to be copied in "anc" directory in a distribution.
ANCILLARYFILES =
# Additional files to mostly-clean.
MOSTLYCLEANFILES =
# Additional files to clean.
CLEANFILES =
# Additional directories to mostly-clean.
MOSTLYCLEANDIRS =
# Additional directories to clean.
CLEANDIRS = .cache _cache cache
# Prerequisite Make targets in the current directory.
PREREQUISITE =
# Prerequisite Make targets in subdirectories.
PREREQUISITE_SUBDIRS = NONE
# Postprocessing Make targets.
POSTPROCESS =
# List of prettifier commands/rules, invoked by "make pretty".
PRETTIFIERS = latexindent
# List of linter commands/rules, invoked by "make lint".
LINTS = chktex
# List of test scripts/rules, invoked by "make check".
TESTS =
# Options for test scripts. Called as $(call TESTS_OPT,test_name,test_param).
TESTS_OPT =
# List of command line parameters for test scripts. If not empty, test scripts
# will be executed for each parameter.
TESTS_PARAMS =
# The following variables will be guessed if empty.
# XXX: in the current implementation, $(init_toolchain) overrides some of them.
TARGET =
SUBDIRS =
LATEX =
DVIPS =
DVIPDF =
PS2PDF =
DVISVGM =
PDFTOPPM =
GS =
BIBTEX =
BIBER =
SORTREF =
MAKEINDEX =
MAKEGLOSSARIES =
BIB2GLS =
LATEXINDENT =
CHKTEX =
ASPELL =
HUNSPELL =
TEXTLINT =
REDPEN =
KPSEWHICH =
AXOHELP =
PDFCROP =
EBB =
EXTRACTBB =
CONVBKMK =
LATEXPAND =
LATEXDIFF =
SOFFICE =
WGET =
CURL =
# Command options.
LATEX_OPT = -interaction=nonstopmode -halt-on-error
PDFLATEX_DVI_OPT = -output-format=dvi
DVIPS_OPT = -Ppdf -z
DVIPDF_OPT =
PS2PDF_OPT = -dPDFSETTINGS=/prepress -dEmbedAllFonts=true
DVISVGM_OPT = -n
PDFTOPPM_OPT = -singlefile
PDFTOPPM_JPG_OPT = -jpeg
PDFTOPPM_PNG_OPT = -png
GS_OPT =
BIBTEX_OPT =
BIBER_OPT =
SORTREF_OPT =
MAKEINDEX_OPT =
MAKEGLOSSARIES_OPT =
BIB2GLS_OPT =
LATEXINDENT_OPT = -l -wd -s
CHKTEX_OPT =
ASPELL_OPT =
HUNSPELL_OPT =
TEXTLINT_OPT = --cache
REDPEN_OPT =
KPSEWHICH_OPT =
AXOHELP_OPT =
PDFCROP_OPT =
EBB_OPT =
EXTRACTBB_OPT =
CONVBKMK_OPT = -g
LATEXPAND_OPT = --expand-usepackage
LATEXDIFF_OPT =
SOFFICE_OPT =
WGET_OPT =
CURL_OPT =
# ANSI escape code for colorization.
CL_NORMAL = [0m
CL_NOTICE = [32m
CL_WARN = [35m
CL_ERROR = [31m
.SUFFIXES:
.SUFFIXES: .log .bb .xbb .pdf .odt .eps .ps .jpg .png .svg .dvi .fmt .tex .cls .sty .ltx .dtx
DEPDIR = .dep
DIFFDIR = .diff
# $(call cache,VARIABLE) expands $(VARIABLE) with caching.
# See https://www.cmcrossroads.com/article/makefile-optimization-eval-and-macro-caching
cache = $(if $(is_cached-$1),,$(eval is_cached-$1 := 1)$(eval cached_val-$1 := $($1)))$(cached_val-$1)
# $(call type,EXEC-FILE) gives the path to the executable if found,
# otherwise empty.
type = $(if $(strip $1),$(strip \
$(eval type_retval := $(shell which '$(strip $1)' 2>/dev/null)) \
$(if $(filter-out $(firstword $(type_retval)),$(type_retval)), \
$(eval type_retval := '$(type_retval)') \
) \
$(type_retval) \
))
# $(call switch,STRING,STRING1,VALUE1,STRING2,VALUE2,...) evaluates the value of
# VALUEi corresponding to the first STRINGi that matches to STRING.
# Limitation: up to 4 STRING-VALUE pairs.
switch = \
$(if $(filter $2,$1),$3, \
$(if $(filter $4,$1),$5, \
$(if $(filter $6,$1),$7, \
$(if $(filter $8,$1),$9, \
) \
) \
) \
)
# $(call pathsearch,PROG-NAME,NOERROR-IF-NOT-FOUND,NAME1,...) tries to find
# the given executable.
# Limitation: up to 7 NAMEs.
pathsearch = $(strip \
$(eval retval := ) \
$(call pathsearch_impl,$3,$4,$5,$6,$7,$8,$9) \
$(if $2$(retval),,$(eval retval := \
$(call error_message,$1 not found); \
exit 1; :)) \
$(retval) \
)
pathsearch_impl = \
$(if $(retval),,$(eval retval := $(call type,$1))) \
$(if $(retval),,$(if $(strip $2 $3 $4 $5 $6 $7 $8 $9),$(call pathsearch_impl,$2,$3,$4,$5,$6,$7,$8,$9)))
# $(target) gives all targets.
target = $(call cache,target_impl)
target_impl = $(strip \
$(target_impl_from_ltx) \
$(target_impl_from_tex) \
)
target_impl_from_ltx = $(srcltxfiles:.ltx=.fmt)
target_impl_from_tex = $(strip \
$(eval retval := ) \
$(if $(retval),,$(eval retval := $(TARGET))) \
$(if $(retval),,$(eval retval := $(srctexfiles:.tex=.$(default_target)))) \
$(retval) \
)
# $(target_basename) gives the result of $(basename $(target)).
target_basename = $(call cache,target_basename_impl)
target_basename_impl = $(basename $(target))
# $(srctexfiles) gives all LaTeX source files.
# They have the ".tex" file extension and
# (1) contain "documentclass", or
# (2) begin with "%&" (including a format file).
srctexfiles = $(call cache,srctexfiles_impl)
srctexfiles_impl = $(strip $(sort \
$(shell grep documentclass -l *.tex 2>/dev/null) \
$(shell awk 'FNR==1{if ($$0~"%&") print FILENAME;}' *.tex 2>/dev/null) \
))
# $(srcltxfiles) gives all .ltx files.
srcltxfiles = $(call cache,srcltxfiles_impl)
srcltxfiles_impl = $(wildcard *.ltx)
# $(srcdtxfiles) gives all .dtx files.
srcdtxfiles = $(call cache,srcdtxfiles_impl)
srcdtxfiles_impl = $(wildcard *.dtx)
ifneq ($(DIFF),)
# $(diff_target) gives all latexdiff target files.
diff_target = $(call cache,diff_target_impl)
diff_target_impl = $(strip $(shell \
$(call get_rev,$(DIFF),_rev1,_rev2,false); \
if [ -n "$$_rev1" ]; then \
for _f in $(srctexfiles); do \
if [ -z "$$_rev2" ]; then \
if git show "$$_rev1:./$$_f" >/dev/null 2>&1; then \
echo $${_f%.*}-diff.$(default_target); \
fi; \
else \
if git show "$$_rev1:./$$_f" >/dev/null 2>&1 && git show "$$_rev2:./$$_f" >/dev/null 2>&1; then \
echo $${_f%.*}-diff.$(default_target); \
fi ; \
fi; \
done; \
fi \
))
# $(call get_rev,REV-STR,REV1-VAR,REV2-VAR) decomposes the given Git revision(s)
# into 2 variables.
# $(call get_rev,REV-STR,REV1-VAR,REV2-VAR,false) performs the same but without
# checking the revision string.
get_rev = \
$(if $4,, \
if [ -z "$1" ]; then \
$(call error_message,Git revision not given); \
exit 1; \
fi; \
) \
$2=; \
$3=; \
if expr "$1" : '.*[^.]\.\.[^.]' >/dev/null; then \
$2=$$(expr "$1" : '\(.*[^.]\)\.\.'); \
$3=$$(expr "$1" : '.*[^.]\.\.\([^.].*\)'); \
elif expr "$1" : '.*[^.]\.\.$$' >/dev/null; then \
$2=$$(expr "$1" : '\(.*[^.]\)\.\.'); \
else \
$2="$1"; \
fi; \
if [ -n "$$$2" ]; then \
if git cat-file -e "$$$2" 2>/dev/null; then :; else \
$(call error_message,invalid Git revision: $$$2); \
exit 1; \
fi; \
fi; \
if [ -n "$$$3" ]; then \
if git cat-file -e "$$$3" 2>/dev/null; then :; else \
$(call error_message,invalid Git revision: $$$3); \
exit 1; \
fi; \
fi
endif
# $(subdirs) gives all subdirectories.
subdirs = $(call cache,subdirs_impl)
subdirs_impl = $(strip \
$(eval retval := ) \
$(if $(retval),,$(eval retval := $(SUBDIRS))) \
$(if $(retval),,$(eval retval := $(dir $(wildcard */Makefile)))) \
$(retval) \
)
# $(call run_testsuite,PREFIX) runs all rules for targets starting with PREFIX
# in the current Makefile.
# $(run_testsuite) is equivalent to $(call run_testsuite,test_).
run_testsuite = \
for test in $(call all_testsuite,$(if $1,$1,test_)); do \
echo "Testing $$test..."; \
$(MAKE) --silent clean; \
$(MAKE) --always-make --no-print-directory $$test || exit 1; \
done
all_testsuite = $(shell $(MAKE) -pq _FORCE | sed -n '/^$1/p' | sed 's/:.*//')
assert_true = \
$(if $(strip $1),:,false)
assert_false = \
$(if $(strip $1),false,:)
assert_eq = \
$(if $(and $(findstring $1,$2),$(findstring $2,$1)),echo '$1==$2';:,echo '$1!=$2';false)
assert_success = \
$(strip $1)
assert_fail = \
if { $(strip $1); }; then false; else :; fi
# $(is_texlive) is "1" if TeX Live is used, otherwise empty.
is_texlive = $(call cache,is_texlive_impl)
is_texlive_impl = $(strip \
$(shell $(TEX) --version 2>/dev/null | grep -q 'TeX Live' && echo 1) \
)
# $(is_miktex) is "1" if MiKTeX is used, otherwise empty.
is_miktex = $(call cache,is_miktex_impl)
is_miktex_impl = $(strip \
$(shell $(TEX) --version 2>/dev/null | grep -q 'MiKTeX' && echo 1) \
)
# $(has_gnu_grep) is "1" if GNU grep is available, otherwise empty.
has_gnu_grep = $(call cache,has_gnu_grep_impl)
has_gnu_grep_impl = $(strip \
$(shell grep --version 2>/dev/null | grep -q 'GNU' && echo 1) \
)
# $(call rule_exists,RULE) is "1" if RULE exists, otherwise empty.
rule_exists = \
$(shell $(MAKE) -n $1 >/dev/null 2>&1 && echo 1)
# $(call uppercase,STR) converts STR to uppercase.
uppercase = \
$(shell echo '$1' | tr a-z A-Z)
# $(call lowercase,STR) converts STR to lowercase.
lowercase = \
$(shell echo '$1' | tr A-Z a-z)
# $(call sanitize,STR) replaces special characters in STR with underscores.
sanitize = \
$(shell echo '$1' | sed 's/[^a-zA-Z0-9]/_/g')
# $(init_toolchain) initializes the toolchain.
init_toolchain = $(call cache,init_toolchain_impl)
init_toolchain_impl = $(strip \
$(eval $(init_toolchain_$(TOOLCHAIN))) \
$(if $(typeset_mode),,$(error unknown TOOLCHAIN=$(TOOLCHAIN))) \
)
init_toolchain_latex = \
$(init_toolchain_latex_dvips)
init_toolchain_latex_dvips = \
$(eval typeset_mode = dvips) \
$(eval tex_format = latex)
init_toolchain_latex_dvipdf = \
$(eval typeset_mode = dvipdf) \
$(eval tex_format = latex)
init_toolchain_platex = \
$(init_toolchain_platex_dvips)
init_toolchain_platex_dvips = \
$(eval typeset_mode = dvips_convbkmk) \
$(eval tex_format = platex) \
$(eval LATEX = platex) \
$(eval BIBTEX = pbibtex) \
$(eval MAKEINDEX = mendex)
init_toolchain_platex_dvipdfmx = \
$(eval typeset_mode = dvipdf) \
$(eval tex_format = platex) \
$(eval LATEX = platex) \
$(eval DVIPDF = dvipdfmx) \
$(eval BIBTEX = pbibtex) \
$(eval MAKEINDEX = mendex)
init_toolchain_uplatex = \
$(init_toolchain_uplatex_dvips)
init_toolchain_uplatex_dvips = \
$(eval typeset_mode = dvips_convbkmk) \
$(eval tex_format = uplatex) \
$(eval LATEX = uplatex) \
$(eval BIBTEX = upbibtex) \
$(eval MAKEINDEX = upmendex)
init_toolchain_uplatex_dvipdfmx = \
$(eval typeset_mode = dvipdf) \
$(eval tex_format = uplatex) \
$(eval LATEX = uplatex) \
$(eval DVIPDF = dvipdfmx) \
$(eval BIBTEX = upbibtex) \
$(eval MAKEINDEX = upmendex)
init_toolchain_pdflatex = \
$(eval typeset_mode = pdflatex) \
$(eval tex_format = pdflatex) \
$(eval LATEX = pdflatex)
init_toolchain_xelatex = \
$(eval typeset_mode = pdflatex) \
$(eval tex_format = xelatex) \
$(eval LATEX = xelatex)
init_toolchain_lualatex = \
$(eval typeset_mode = pdflatex) \
$(eval tex_format = lualatex) \
$(eval LATEX = lualatex) \
$(eval BIBTEX = upbibtex) \
$(eval MAKEINDEX = upmendex)
init_toolchain_luajitlatex = \
$(eval typeset_mode = pdflatex) \
$(eval tex_format = luajitlatex) \
$(eval LATEX = luajittex) \
$(eval LATEX_OPT := --fmt=luajitlatex.fmt $(LATEX_OPT)) \
$(eval BIBTEX = upbibtex) \
$(eval MAKEINDEX = upmendex)
# The typeset mode: "dvips" or "dvips_convbkmk" or "dvipdf" or "pdflatex".
typeset_mode =
# The TeX format.
tex_format =
# $(call pathsearch2,PROG-NAME,VAR-NAME,NAME1,...) is basically pathsearch after
# calling init_toolchain.
pathsearch2 = $(strip \
$(init_toolchain) \
$(call pathsearch,$1,,$($2),$3,$4,$5,$6,$7,$8,$9) \
)
# $(latex)
latex = $(call cache,latex_impl)
latex_impl = $(strip \
$(latex_noopt) $(LATEX_OPT) \
$(if $(findstring -recorder,$(LATEX_OPT)),,-recorder) \
)
# (latex_noopt) doesn't include $(LATEX_OPT).
latex_noopt = $(call cache,latex_noopt_impl)$(if $(BUILDDIR), -output-directory=$(BUILDDIR))
latex_noopt_impl = $(init_toolchain)$(call pathsearch,latex$(if $(DEV),-dev),,$(LATEX)$(if $(DEV),-dev),latex$(if $(DEV),-dev))
# $(dvips)
dvips = $(call cache,dvips_impl) $(DVIPS_OPT)
dvips_impl = $(call pathsearch2,dvips,DVIPS,dvips,dvipsk)
# $(dvipdf)
dvipdf = $(call cache,dvipdf_impl) $(DVIPDF_OPT)
dvipdf_impl = $(call pathsearch2,dvipdf,DVIPDF,dvipdf,dvipdfm,dvipdfmx)
# $(ps2pdf)
ps2pdf = $(call cache,ps2pdf_impl) $(PS2PDF_OPT)
ps2pdf_impl = $(call pathsearch2,ps2pdf,PS2PDF,ps2pdf)
# $(dvisvgm)
dvisvgm = $(call cache,dvisvgm_impl) $(DVISVGM_OPT)
dvisvgm_impl = $(call pathsearch2,dvisvgm,DVISVGM,dvisvgm)
# $(pdftoppm)
pdftoppm = $(call cache,pdftoppm_impl) $(PDFTOPPM_OPT)
pdftoppm_impl = $(call pathsearch2,pdftoppm,PDFTOPPM,pdftoppm)
# $(gs)
gs = $(call cache,gs_impl) $(GS_OPT)
gs_impl = $(call pathsearch2,gs,GS,gs,gswin32,gswin64,gsos2)
# $(bibtex)
bibtex = $(call cache,bibtex_impl) $(BIBTEX_OPT)
bibtex_impl = $(call pathsearch2,bibtex,BIBTEX,bibtex)
# $(biber)
biber = $(call cache,biber_impl) $(BIBER_OPT)
biber_impl = $(call pathsearch2,biber,BIBER,biber)
# $(sortref)
sortref = $(call cache,sortref_impl) $(SORTREF_OPT)
sortref_impl = $(call pathsearch2,sortref,SORTREF,sortref)
# $(makeindex)
makeindex = $(call cache,makeindex_impl) $(MAKEINDEX_OPT)
makeindex_impl = $(call pathsearch2,makeindex,MAKEINDEX,makeindex)
# $(makeglossaries)
makeglossaries = $(call cache,makeglossaries_impl) $(MAKEGLOSSARIES_OPT)
makeglossaries_impl = $(call pathsearch2,makeglossaries,MAKEGLOSSARIES,makeglossaries)
# $(bib2gls)
bib2gls = $(call cache,bib2gls_impl) $(BIB2GLS_OPT)
bib2gls_impl = $(call pathsearch2,bib2gls,BIB2GLS,bib2gls)
# $(latexindent)
latexindent = $(call cache,latexindent_impl) $(LATEXINDENT_OPT)
latexindent_impl = $(call pathsearch2,latexindent,LATEXINDENT,latexindent)
# $(chktex)
chktex = $(call cache,chktex_impl) $(CHKTEX_OPT)
chktex_impl = $(call pathsearch2,chktex,CHKTEX,chktex)
# $(aspell)
aspell = $(call cache,aspell_impl) $(ASPELL_OPT)
aspell_impl = $(call pathsearch2,aspell,ASPELL,aspell)
# $(hunspell)
hunspell = $(call cache,hunspell_impl) $(HUNSPELL_OPT)
hunspell_impl = $(call pathsearch2,hunspell,HUNSPELL,hunspell)
# $(textlint)
textlint = $(call cache,textlint_impl) $(TEXTLINT_OPT)
textlint_impl = $(call pathsearch2,textlint,TEXTLINT,node_modules/.bin/textlint,\
$(shell git rev-parse --show-toplevel 2>/dev/null)/node_modules/.bin/textlint,\
$(shell git rev-parse --show-superproject-working-tree 2>/dev/null)/node_modules/.bin/textlint,\
../node_modules/.bin/textlint,\
../../node_modules/.bin/textlint,\
textlint)
# $(redpen)
redpen = $(call cache,redpen_impl) $(REDPEN_OPT)
redpen_impl = $(call pathsearch2,redpen,REDPEN,redpen)
# $(kpsewhich)
kpsewhich = $(call cache,kpsewhich_impl) $(KPSEWHICH_OPT)
kpsewhich_impl = $(call pathsearch2,kpsewhich,KPSEWHICH,kpsewhich)
# $(axohelp)
axohelp = $(call cache,axohelp_impl) $(AXOHELP_OPT)
axohelp_impl = $(call pathsearch2,axohelp,AXOHELP,axohelp)
# $(pdfcrop)
pdfcrop = $(call cache,pdfcrop_impl) $(PDFCROP_OPT)
pdfcrop_impl = $(call pathsearch2,pdfcrop,PDFCROP,pdfcrop)
# $(ebb)
ebb = $(call cache,ebb_impl) $(EBB_OPT)
ebb_impl = $(call pathsearch2,ebb,EBB,ebb)
# $(extractbb)
extractbb = $(call cache,extractbb_impl) $(EXTRACTBB_OPT)
extractbb_impl = $(call pathsearch2,extractbb,EXTRACTBB,extractbb)
# $(convbkmk)
convbkmk = $(call cache,convbkmk_impl) $(CONVBKMK_OPT)
convbkmk_impl = $(call pathsearch2,convbkmk,CONVBKMK,convbkmk)
# $(latexpand)
latexpand = $(call cache,latexpand_impl) $(LATEXPAND_OPT)
latexpand_impl = $(call pathsearch2,latexpand,LATEXPAND,latexpand)
# $(latexdiff)
latexdiff = $(call cache,latexdiff_impl) $(LATEXDIFF_OPT)
latexdiff_impl = $(call pathsearch2,latexdiff,LATEXDIFF,latexdiff)
# $(download) <OUTPUT-FILE> <URL>
download = $(strip \
$(if $(_download_wget_found)$(_download_curl_found),,$(call _download_init)) \
$(if $(_download_wget_found), \
$(_download_wget_found) $(WGET_OPT) -O \
, \
$(if $(_download_curl_found), \
$(_download_curl_found) $(CURL_OPT) -L -o \
, \
$(call error_message,both wget and curl not found); exit 1; \
) \
) \
)
_download_init = $(strip \
$(if $(_download_wget_found),,$(eval _download_wget_found := $(call pathsearch,wget,true,$(WGET),wget))) \
$(if $(_download_wget_found)$(_download_curl_found),,$(eval _download_curl_found := $(call pathsearch,curl,true,$(CURL),curl))) \
)
_download_wget_found =
_download_curl_found =
# $(soffice)
soffice = $(call cache,soffice_impl) $(SOFFICE_OPT)
soffice_impl = $(call pathsearch2,soffice,SOFFICE, \
soffice, \
/cygdrive/c/Program Files/LibreOffice 6/program/soffice, \
/cygdrive/c/Program Files (x86)/LibreOffice 6/program/soffice, \
/cygdrive/c/Program Files/LibreOffice 5/program/soffice, \
/cygdrive/c/Program Files (x86)/LibreOffice 5/program/soffice, \
/cygdrive/c/Program Files/LibreOffice 4/program/soffice, \
/cygdrive/c/Program Files (x86)/LibreOffice 4/program/soffice \
)
# $(Makefile) gives the name of this Makefile.
Makefile = $(call cache,Makefile_impl)
Makefile_impl = $(firstword $(MAKEFILE_LIST))
# $(mostlycleanfiles) gives all intermediately generated files, to be deleted by
# "make mostlyclean".
# .aux - LaTeX auxiliary file
# .auxlock - TikZ externalization aux file lock
# .ax1 - axodraw2 auxiliary (axohelp input) file
# .ax2 - axohelp output file
# .bak[0-9]* - latexindent backup file
# .bbl - BibTeX output file
# .bcf - by biblatex package
# .blg - BibTeX log file
# .end - ?
# .fls - LaTeX recorder file
# .fmt - TeX format file
# .glg - glossary log file
# .glo - glossary entries
# .gls - glossary output
# .glsdefs - glossary output
# .glstex - by bib2gls
# .idx - index entries
# .ilg - index log file
# .ind - index output
# .ist - index style file
# .lof - list of figures
# .log - (La)TeX log file
# .lot - list of tables
# .nav - Beamer navigation items
# .out - Beamer outlines
# .run.xml - by logreq package
# .snm - Beamer page labels
# .spl - by elsarticle class
# .toc - table of contents
# .*.vrb - Beamer verbatim materials
# .xdy - by xindy
# Notes.bib - by revtex package
# *-blx.aux - by biblatex package
# -blx.bib - by biblatex package
# _ref.tex - by sortref
# .bmc - by dviout
# .pbm - by dviout
# -eps-converted-to.pdf - by epstopdf
# -indent.log - by latexindent+makefile4latex
mostlycleanfiles = $(call cache,mostlycleanfiles_impl)
mostlycleanfiles_impl = $(wildcard $(strip \
$(srctexfiles:.tex=.aux) \
$(srctexfiles:.tex=.auxlock) \
$(srctexfiles:.tex=.ax1) \
$(srctexfiles:.tex=.ax2) \
$(srctexfiles:.tex=.bak[0-9]*) \
$(srctexfiles:.tex=.bbl) \
$(srctexfiles:.tex=.bcf) \
$(srctexfiles:.tex=.blg) \
$(srctexfiles:.tex=.end) \
$(srctexfiles:.tex=.fls) \
$(srctexfiles:.tex=.fmt) \
$(srctexfiles:.tex=.glg) \
$(srctexfiles:.tex=.glo) \
$(srctexfiles:.tex=.gls) \
$(srctexfiles:.tex=.glsdefs) \
$(srctexfiles:.tex=.glstex) \
$(srctexfiles:.tex=.idx) \
$(srctexfiles:.tex=.ilg) \
$(srctexfiles:.tex=.ind) \
$(srctexfiles:.tex=.ist) \
$(srctexfiles:.tex=.lof) \
$(srctexfiles:.tex=.log) \
$(srctexfiles:.tex=.lot) \
$(srctexfiles:.tex=.nav) \
$(srctexfiles:.tex=.out) \
$(srctexfiles:.tex=.run.xml) \
$(srctexfiles:.tex=.snm) \
$(srctexfiles:.tex=.spl) \
$(srctexfiles:.tex=.synctex) \
$(srctexfiles:.tex=.synctex.gz) \
$(srctexfiles:.tex=.toc) \
$(srctexfiles:.tex=.*.vrb) \
$(srctexfiles:.tex=.xdy) \
$(srctexfiles:.tex=Notes.bib) \
$(srctexfiles:.tex=*-blx.aux) \
$(srctexfiles:.tex=*-blx.bbl) \
$(srctexfiles:.tex=*-blx.blg) \
$(srctexfiles:.tex=-blx.bib) \
$(srctexfiles:.tex=_ref.tex) \
$(srcltxfiles:.ltx=.log) \
*.bmc \
*.pbm \
*-convbkmk.ps \
*-eps-converted-to.pdf \
*.bb \
*.xbb \
*_tmp.??? \
*-indent.log \
*/*-eps-converted-to.pdf \
$(srctexfiles:.tex=-figure*.dpth) \
$(srctexfiles:.tex=-figure*.log) \
$(srctexfiles:.tex=-figure*.md5) \
$(srctexfiles:.tex=-figure*.pdf) \
$(srctexfiles:.tex=-diff.dvi) \
$(srctexfiles:.tex=-diff.ps) \
$(srctexfiles:.tex=-diff.pdf) \
$(MOSTLYCLEANFILES) \
))
# $(cleanfiles) gives all generated files to be deleted by "make clean".
cleanfiles = $(call cache,cleanfiles_impl)
cleanfiles_impl = $(wildcard $(strip \
$(srctexfiles:.tex=.tar.gz) \
$(srctexfiles:.tex=.pdf) \
$(srctexfiles:.tex=.ps) \
$(srctexfiles:.tex=.eps) \
$(srctexfiles:.tex=.dvi) \
$(srctexfiles:.tex=.svg) \
$(srctexfiles:.tex=.jpg) \
$(srctexfiles:.tex=.png) \
$(srcltxfiles:.ltx=.fmt) \
$(srcdtxfiles:.dtx=.cls) \
$(srcdtxfiles:.dtx=.sty) \
$(CLEANFILES) \
$(mostlycleanfiles) \
))
# $(color) gives the color mode in the output:
# - always
# - never
# - auto (default)
#
# Usually controlled via $(COLOR) given on the command line or
# in the user configuration files.
#
# For compatibility with previous versions:
# - fall back to $(MAKE_COLORS), if $(COLOR) is empty,
# - allow "none", which is translated to "never".
#
# NOTE: use of MAKE_COLORS is deprecated. In future, MAKE_COLORS might be
# used for customizing colorings, like LS_COLORS or GCC_COLORS.
#
color = $(call cache,color_impl)
color_impl = $(strip \
$(if $(_get_color), \
$(if $(or \
$(findstring always,$(_get_color)), \
$(findstring never,$(_get_color)), \
$(findstring auto,$(_get_color)) \
), \
$(_get_color) \
,$(if $(findstring none,$(_get_color)), \
never \
, \
$(warning unrecognized COLOR=$(_get_color)) \
auto \
)) \
, \
auto \
) \
)
_get_color = $(if $(COLOR),$(COLOR),$(MAKE_COLORS))
# $(color_enabled) is a shell script snippet that returns the exit code 0 if
# coloring is enabled, otherwise returns a non-zero value.
color_enabled = \
$(if $(findstring always,$(color)), \
: \
,$(if $(findstring never,$(color)), \
false \
, \
[ -t 1 ] \
))
# $(call colorize,COMMAND-WITH-COLOR,COMMAND-WITHOUT-COLOR) invokes the first
# command when coloring is enabled, otherwise invokes the second command.
colorize = \
$(if $(findstring always,$(color)), \
$1 \
,$(if $(findstring never,$(color)), \
$2 \
, \
if [ -t 1 ]; then \
$1; \
else \
$2; \
fi \
))
# $(call notification_message,MESSAGE) prints a notification message.
notification_message = \
$(call colorize, \
printf "\033$(CL_NOTICE)$1\033$(CL_NORMAL)\n" >&2 \
, \
echo "$1" >&2 \
)
# $(call warning_message,MESSAGE) prints a warning message.
warning_message = \
$(call colorize, \
printf "\033$(CL_WARN)Warning: $1\033$(CL_NORMAL)\n" >&2 \
, \
echo "Warning: $1" >&2 \
)
# $(call error_message,MESSAGE) prints an error message.
error_message = \
$(call colorize, \
printf "\033$(CL_ERROR)Error: $1\033$(CL_NORMAL)\n" >&2 \
, \
echo "Error: $1" >&2 \
)
# $(call set_title,TITLE) changes the window title. (Default: do nothing.)
set_title = :
# $(call exec,COMMAND) invokes the command with checking the exit status.
# $(call exec,COMMAND,false) invokes the command but skips the check.
# $(call exec,COMMAND,,COLOR_FILTER) and $(call exec,COMMAND,false,COLOR_FILTER)
# use COLOR_FILTER for the stdout.
exec = \
$(if $(and $(findstring not found,$1),$(findstring exit 1,$1)), \
$1 \
, \
failed=false; \
$(call colorize, \
printf "\033$(CL_NOTICE)$1\033$(CL_NORMAL)\n"; \
exec 3>&1; \
pipe_status=`{ { $1 3>&- 4>&-; echo $$? 1>&4; } $(call colorize_output_join,$3) | \
$(call colorize_output,$3) >&3; } 4>&1`; \
exec 3>&-; \
[ "$$pipe_status" = 0 ] || failed=: \
, \
echo "$1"; \
$1 || failed=: \
) \
$(if $2,,; $(check_failed)) \
)
# $(check_failed)
check_failed = $$failed && { [ -n "$$dont_delete_on_failure" ] || rm -f $@; exit 1; }; :
# $(colorize_output) gives sed commands for colorful output.
# $(colorize_output,COLOR_FILTER) gives an application specific filter.
colorize_output = $(colorize_output_$1)
colorize_output_ = cat
# $(colorize_output,COLOR_FILTER) gives "2>&1" to combine the stderr into the stdout, if needed for the COLOR_FILTER.
colorize_output_join = $(if $(colorize_output_$1_join),2>&1,)