-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
4238 lines (3965 loc) · 143 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
# Copyright 2004 Chris Monson ([email protected])
# 2011 Andrew McNabb
# 2013 Krishna Kumar
# 2017 Holger Nahrstaedt
# Latest version available at http://www.bouncingchairs.net/oss
#
# This file is part of ``Chris Monson's Free Software''.
#
# ``Chris Monson's Free Software'' is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, Version 2.
#
# ``Chris Monson's Free Software'' is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with ``Chris Monson's Free Software''; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# It is also available on the web at http://www.gnu.org/copyleft/gpl.html
#
# Note that using this makefile to build your documents does NOT place them
# under the GPL unless you, the author, specifically do so. In other words,
# I, Chris Monson, the copyright holder and author of this makefile,
# consider it impossible to ``link'' to this makefile in any way covered by
# the GPL.
#
#
# TO OBTAIN INSTRUCTIONS FOR USING THIS FILE, RUN:
# make help
#
fileinfo := LaTeX Makefile
author := Chris Monson
version := 2.2.1-alpha10
#
.DEFAULT_GOAL := all
# Note that the user-global version is imported *after* the source directory,
# so that you can use stuff like ?= to get proper override behavior.
.PHONY: Makefile GNUmakefile Makefile.ini $(HOME)/.latex-makefile/Makefile.ini
-include Makefile.ini
-include $(HOME)/.latex-makefile/Makefile.ini
# Better names for these things
.PHONY: Variables.ini $(HOME)/.latex-makefile/Variables.ini
-include Variables.ini
-include $(HOME)/.latex-makefile/Variables.ini
#
# This can be pdflatex or latex - you can change this by adding the following line to your Makefile.ini:
# BUILD_STRATEGY := latex
BUILD_STRATEGY ?= pdflatex
#BIB_STRATEGY ?= biblatex
BIB_STRATEGY ?= bibtex
# This can be used to pass extra options to latex.
LATEX_OPTS ?=
#
# Sets LC_ALL=C, by default, so that the locale-aware tools, like sort, be
# # immune to changes to the locale in the user environment.
export LC_ALL ?= C
#
#
# If you specify sources here, all other files with the same suffix
# will be treated as if they were _include_ files.
#onlysources.tex ?= main.tex
#onlysources.lhs ?=
#onlysources.tex.sh ?=
#onlysources.tex.pl ?=
#onlysources.tex.py ?=
#onlysources.rst ?=
#onlysources.mp ?=
#onlysources.fig ?=
#onlysources.gpi ?=
#onlysources.dot ?=
#onlysources.xvg ?=
#onlysources.svg ?=
#onlysources.eps.gz ?=
#onlysources.eps ?=
#
# If you list files here, they will be treated as _include_ files
#includes.tex ?= file1.tex file2.tex
#includes.lhs ?=
#includes.tex.sh ?=
#includes.tex.pl ?=
#includes.tex.py ?=
#includes.rst ?=
#includes.mp ?=
#includes.fig ?=
#includes.gpi ?=
#includes.dot ?=
#includes.xvg ?=
#includes.svg ?=
#includes.eps.gz ?=
#includes.eps ?=
#
# If you list files or wildcards here, they will *not* be cleaned - default is
# to allow everything to be cleaned.
#neverclean ?= *.pdf
#
# Alternatively (recommended), you can add those lines to a Makefile.ini file
# and it will get picked up automatically without your having to edit this
# Makefile.
#
# KNOWN ISSUES:
# * The following occurs:
# file with: \usepackage{named}\bibliographystyle{named}
# Compile
# change to: \usepackage{apalike}\bibliographystyle{apalike}
# Compile again -- BARF!
#
# The workaround: make clean-nographics; make
#
# Note that we may not be able to fix this. LaTeX itself barfs
# on this, not the makefile. The very first invocation of LaTeX
# (when something like this has happened) reads the existing .aux
# file and discovers invalid commands like \citeauthoryear that
# are only valid in the package that was just removed. It then
# tries to parse them and explodes. It's not at all clear to me
# how to fix this. I tried removing the .aux files on the first
# run of LaTeX, but that necessarily requires more subsequent
# rebuilds on common edits. There does not appear to be a
# graceful solution to this issue.
#
#
# CHANGES:
# Holger Nahrstaedt (2017-09-25):
# * Bumped version to 2.2.1-alpha10
# * Added XELATEX and LUALATEX to BUILD_STRATEGY
# * New option BIB_STRATEGY, can be biblatex or bibtex
# * Added all Authors to Copyright section
# * Added asymptote file generation
# * Added shell-escape to pdflatex, xelatex and lualatex
# Krishna Kumar (2013-11-27):
# * Added PS to rm_ext to remove PS files generated during LaTeX output
# Krishna Kumar (2013-11-26):
# * Changed PS_EMBED_OPTION ?= -dPDFSETTINGS=/prepress from /printer
#
# Chris Monson (2012-06-25):
# * Bumped version to 2.2.1-alpha9
# * Built with Holger Dell's changes to fix multiple unnecessary compilations.
# Chris Monson (2011-11-10):
# * Issue 144: Help patch from girard.nicolas applied
# Andrew McNabb (2011-09-30):
# * Bumped version to 2.2.1-alpha8
# * Issue 141: No font embedding for gnuplot when not doing pdf
# * Syntax error fixed for gpi handling code
# Chris Monson (2011-09-06):
# * Issue 140: clean mlt*, mlf*, and mtc* files
# * Issue 136: initial support for metapost files
# Chris Monson (2011-08-09):
# * Bumped version to 2.2.1-alpha7
# * Issue 138: existing .eps files now included correctly
# * Issue 139: added missing backslash to ps build rule
# Chris Monson (2011-07-20):
# * Added LATEX_OPTS
# Chris Monson (2011-06-23):
# * Bumped version to 2.2.1-alpha6
# * Issue 133: Set jobname to fix .fls generation to always have the source name
# * Removed unnecessary (?) double-invocation of cygpath
# Chris Monson (2011-06-16):
# * Added support for keeping .rst and .lhs tex intermediates around.
# * Separated scripts from source generation files (rst and lhs)
# * Fixed run-script problem for lhs2tex (was invoked incorrectly)
# * Issue 133: Fixed typo from literate Haskell support
# Chris Monson (2011-06-13):
# * Bumped version to 2.2.1-alpha5
# * Fixed problems with detecting graphics for very long source names.
# Chris Monson (2011-06-13):
# * Issue 134: name of self corrected for dependency graph
# * Issue 133: Added literate Haskell support (lhs2tex)
# Chris Monson (2011-05-31):
# * Rewrote specials (%%COMMENTS) to be easier to extend and parse.
# Chris Monson (2011-05-11):
# * Bumped version to 2.2.1-alpha4
# * Issue 129: nomenclature dependency fix
# Chris Monson (2011-05-09):
# * Bumped version to 2.2.1-alpha3
# * Issue 112: Cygpath fixes
# Chris Monson (2011-04-27):
# * Bumped version to 2.2.1-alpha2
# * Issue 126: Broken log parsing for latex pipeline
# * Fixed month in recent changes (had May, should be April)
# * Noticed problems with some existing parsing (colorizing errors, notably) and
# fixed them.
# * New test case for specified graphic extensions.
# * Added .bb generation for .eps files (when extensionless in latex pipeline)
# Chris Monson (2011-04-22):
# * Bumped version to 2.2.1-alpha1
# * Issue 105: add support for format file detection and compilation
# Chris Monson (2011-04-20):
# * Bumped version to 2.2.0 (release!)
# Chris Monson (2011-04-19):
# * Bumped version to 2.2.0-rc15
# * Issue 125: infinite recursion with nomenclature files
# * Issue 125: removed .d as a target for .nls in get-log-index
# * Cleaned up invocation of run-makeindex to take an optional .ist instead of flags.
# Chris Monson (2011-04-06):
# * Bumped version to 2.2.0-rc14
# * Issue 121: Added Targets.ini and corresponding help text for it.
# * Issue 121: Added Variables.ini (Makefile.ini still works, though).
# * Issue 121: Added .DEFAULT_GOAL optional setting.
# * Issue 120: xindy compatibility
# Chris Monson (2011-03-16):
# * Bumped version to 2.2.0-rc13
# * Fixed a bug in kspewhich invocation - random characters and a missing pipe.
# * Added font embedding to gnuplot output.
# Chris Monson (2011-03-15):
# * Bumped version to 2.2.0-rc12
# * Issue 119: Annoying warning from which if Gnuplot not installed.
# * Fixed catchall error output to show more info from the log. Cutting off the
# first line is too jarring.
# * Issue 118: Better glossary support
# Chris Monson (2011-03-03):
# * Bumped version to 2.2.0-rc11
# * Issue 112: Fixed regression introduced by use of cygpath (ugly warnings)
# Chris Monson (2011-02-03):
# * Bumped version to 2.2.0-rc10
# * Issue 112: Added path normalization for cygwin systems
# * Fixed a bug in get-missing-inputs where we weren't specifying target files
# Chris Monson (2011-01-24):
# * Issue 111: Added .jpeg as a possible image extension
# Chris Monson (2011-01-21):
# * Issue 110: Long filenames not produced correctly in .d file
# * Fixed problem with unknown control sequence error parsing
# * Fixed problem with \r in fatal output (was interpreted as LF by echo)
# * Removed a spurious "hi"
# Chris Monson (2011-01-14):
# * Bumped version to 2.2.0-rc8
# * Issue 107: Removed comment with embedded newline, fixing MinGW on Windows 7.
# Chris Monson (2011-01-07):
# * Emit an error if .gpi.d files have dependencies with : in the name
# Chris Monson (2011-01-05):
# * Bumped version to 2.2.0-rc7
# * Issue 106: existing graphic dependencies not generated correctly
# Chris Monson (2011-01-04):
# * Issue 106: not cleaning eps log files properly
# * Issue 106: not rebuilding after creating .pdf graphics from .eps
# * Issue 94: svg going unnecessarily through eps (can't reproduce)
# Chris Monson (2010-12-31):
# * Issue 100: make hanging because of faulty graphics detection (sed bug)
# * Issue 108: do not ignore fatal errors from pdftex
# Chris Monson (2010-12-23):
# * Added gpi_global to gnuplot dependencies so that changes are detected
# Chris Monson (2010-12-20):
# * Updated build file to be smarter about Python version detection
# * Created a bunch of test files and supporting scripts
# * Issue 72: added apacite capaability (thanks to matkarat)
# Chris Monson (2010-11-23):
# * Changed to multi-part makefile build (split out sed scripts)
# * Added build script and supporting infrastructure
# * Updated test directory format
# * Added notes about needed test cases
# * Changed to use -file-line-error and fixed multiple inclusion/error bugs
# * Added run_sed.py to allow easy testing of sed scripts outside of make
# Chris Monson (2010-11-11):
# * Bumped version to 2.2.0-rc7
# * issue 92: broken hyperref driver detection fixed
# * issue 101: Broken inkscape conversion
# * issue 102: Broken specification of font size for gnuplot pdfcairo
# * Added KEEP_TEMP so that we can avoid deleting useful temporaries for debugging
# * Restructured gnuplot code to be easier to follow
# * Fixed a bug in convert-gpi where we were using $< instead of $1
# Chris Monson (2010-11-03):
# * Bumped version to 2.2.0-rc6
# * issue 96: Fix sed errors when using make variables in substitutions
# Chris Monson (2010-07-28):
# * Bumped version to 2.2.0-rc5 (rc4 is broken)
# * Bail out when we find the use of the import.sty package
# * Issue 90: Add -z to dvips invocation
# * Issue 67: Add xelatex support (thanks to Nikolai Prokoschenko for the patch!)
# * Issue 85: Add warning about make 3.80
# Chris Monson (2010-06-20):
# * Bumped version to 2.2.0-rc3
# * Attempt to fix bug with ! error detection (issue 88)
# * Added svg->pdf direct support (issue 89)
# Chris Monson (2010-04-28):
# * Bumped version to 2.2.0-rc2
# * Fixed %._show target
# Chris Monson (2010-04-08):
# * Bumped version to 2.2.0-rc1
# * Added back in the rst_style_file stuff that got broken when switching
# rst -> tex to use the script mechanism
# Chris Monson (2010-03-23):
# * Bumped version to 2.2.0-beta8
# * Work on issue 76: bad backtick escape for some sed versions, failure
# to clear out the hold buffer when outputting MISSING comment.
# - Backed out 2>&1 to &> (doesn't work in sh)
# - Backed out using . to source variables
# Chris Monson (2010-03-22):
# * Bumped version to 2.2.0-beta7
# * Issue 72: Fix latex/bibtex invocation order for annotated bib styles
# * Fixed informational output to reflect which LaTeX run we're on
# * Fixed graphic detection to include graphics that are already there in
# .d files
# * Tightened up the .d file output to only make .d depend on graphic
# *source* files. This means that building foo.d no longer
# builds all of the graphics files on which foo.tex depends.
# Had to use .SECONDEXPANSION trickery to make it work.
# * Changed get-graphics to only accept a stem.
# * Fixed build-once logic for scripted .tex to work better
# * Made get-inputs sed script more maintainable.
# * Moved Makefile.ini import up higher.
# * Changed bare stems to not recursively invoke make
# * Updated diff output to be more silent everywhere
# * Added a MISSING comment to the .d file if stuff isn't found - forces
# removal of .1st.make file, which often forces it to try again.
# * Fixed broken graphics-target function
# * Added sleep to .d file generation when stuff is missing - if it
# builds too fast, make doesn't realize it needs to be reloaded,
# and thus never discovers some deeper dependencies (especially
# evident when graphics are included from scripted include
# files).
# Chris Monson (2010-03-17):
# * Bumped version to 2.2.0-beta6
# * Fixed bareword builds to actually work (requires static patterns)
# * Fixed colorization to work with new paragraph stuff
# Chris Monson (2010-03-17):
# * Bumped version to 2.2.0-beta5
# * Fixed graphic detection to be much more focused - splits log file
# into paragraphs before doing pattern matching.
# * Fixed make foo to work properly (recursively calls make foo.pdf)
# * Fixed gpi -> pdf generation to not waste time building .eps *after*
# the pdf already exists.
# * Changed log copies to include MAKE_RESTARTS as part of the name.
# * Fixed missing include file detection (also makes use of the paragraph
# stuff) to detect missing scripted include files.
# Chris Monson (2010-03-16):
# * Bumped version to 2.2.0-beta4
# * issue 70: .pdf not moved out of the way properly on first
# compilation, resulting in early error detection failure.
# * issue 74: fixed broken error on missing .aux files: the
# implementation was masking real errors.
# Chris Monson (2010-03-15):
# * Bumped version to 2.2.0-beta3
# * issue 71: Made the tput dependency optional
# * issue 73: Made .tex targets not pull in .d files (building them from
# scripts should not require a .d)
# * issue 74: Output a much saner error when a .aux file is not produced
# (e.g., when you are typing "make" without arguments in a
# directory with included .tex files that are not named with
# ._include_.)
# Chris Monson (2010-03-11):
# * Bumped version to 2.2.0-beta2
# * Fixed clean-graphics to get rid of intermediate .eps files that may
# be hanging around
# * Added an automatic setting to use eps terminals in pdflatex mode for
# gnuplot if it doesn't understand pdf.
# * issue 66: Removed grayscale generation via magic suffix. Grayscale
# generation is now only available via GRAY=1
# * issue 68: Added explicit handling of LC_ALL for locale-aware tools
# like "sort"
# Chris Monson (2010-03-10):
# * Bumped version to 2.2.0-beta1
# * Fixed success message to handle output message in different places
# * Added name of produced file to success message
# Chris Monson (2010-03-10):
# * Bumped version to 2.2.0-alpha3
# * Added meaningful error message for wrong hyperref options
# * Added meaningful error message for incorrect graphics extensions
# Chris Monson (2010-03-09):
# * Bumped version to 2.2.0-alpha2
# * Updated graphics handling (gnuplot and fig generate pdf natively)
# * Changed xmgrace to output monochrome natively
# Chris Monson (2010-03-09):
# * Bumped version to 2.2.0-alpha1 - major change!
# * Support pdflatex natively and by default (issue 6 - a long time coming)
# * Add ability to have a single $HOME/.latex-makefile/Makefile.ini for
# all invocations
# * Reworked graphic inclusion detection so that extensions need not be
# specified for either build strategy (e.g.,
# \includegraphics{test1.eps} -> \includegrahpics{test1})
# * Changed log format to include filenames and line numbers
# Chris Monson (2010-02-04):
# * Bumped version to 2.1.43
# * All of the following are for issue 63 (thanks to mojoh81):
# * Added documentation about fixing Makefile.ini default target
# * Added perl and python script targets
# * Fixed run logic to allow included .tex files to be scripted (the
# run-again logic now detects missing .tex files, and the MV
# command has been switched out for a command that only invokes
# MV if the files exist)
# * Changed scripted generation to only run once per make invocation
# * Added dependency on expr
# Chris Monson (2010-01-19):
# * Bumped version to 2.1.42
# * issue 62: Added .brf extension to cleanable files (backrefs)
# Chris Monson (2010-01-07):
# * Bumped version to 2.1.41
# * issue 60: bad makeindex runs now error out on subsequent tries
# Chris Monson (2009-12-01):
# * Bumped version to 2.1.40
# * issue 36: build all indices (for e.g., splitidx usage)
# * issue 59: clean up all generated files (including indices)
# Chris Monson (2009-11-23):
# * Bumped version to 2.1.39
# * issue 57: change ps2pdf invocations to just use gs directly
# Chris Monson (2009-11-19):
# * Bumped version to 2.1.38
# * issue 57: Added some limited support for Cygwin (spaces in filenames)
# Chris Monson (2009-11-15):
# * Bumped version to 2.1.37
# * Removed svninfo, since this is now managed by mercurial
# * Fixed typo in changelist
# * Issue 52: added jpg->eps conversion (thanks to brubakee)
# * Issue 54: fix missing Overfull colorization due to lack of a blank
# line preceding the first error.
# * Issue 51: remove head.tmp and body.tmp in make clean invocation
# * Issue 56: maintain multiple versions of log files (for debugging)
# Chris Monson (2009-11-14):
# * Bumped version to 2.1.36
# * Issues 53 and 49: added .brf, .mtc, and .maf to the cleanables
# Chris Monson (2009-11-05):
# * Bumped version to 2.1.35
# * Added nomenclature support (see issue 48)
# Chris Monson (2009-10-29):
# * Bumped version to 2.1.34
# * Fixed _out_ creation bug introduced in 2.1.33 (it was always created)
# * Fixed erroneous help output for $HOME in BINARY_TARGET_DIR
# * Changed contact email address - bring on the spam!
# Chris Monson (2009-10-21):
# * Bumped version to 2.1.33
# * Fixed issue 46, adding support for dot2tex (thanks to fdemesmay)
# * Made all_files.* settable in Makefile.ini (using ?= instead of :=)
# * Fixed issue 47, thanks to fdemesmay: add binary copy directory, copy
# dvi, pdf, and ps if it exists
# Chris Monson (2009-09-25):
# * Bumped version to 2.1.32
# * Fixed so that a changed lol file will cause a rebuild
# * Added .lol files to the cleanable list
# Chris Monson (2009-09-08):
# * Bumped version to 2.1.31
# * Closed issue 43: evince doesn't notice pdf change w/out touch
# Chris Monson (2009-08-28):
# * Bumped version to 2.1.30
# * Closed issue 39: Capture multi-line log warnings/errors to output
# Chris Monson (2009-08-26):
# * Bumped version to 2.1.29
# * Closed issue 42: add svg support using inkscape
# Chris Monson (2009-08-17):
# * Bumped version to 2.1.28
# * Patch from paul.biggar for issue 38: package warnings are overlooked
# Chris Monson (2009-08-07):
# * Bumped version to 2.1.27
# * Included patch for issue 37 - removes pdf/ps files before copying,
# allowing some broken viewers to see changes properly.
# Chris Monson (2009-05-15):
# * Bumped version to 2.1.26
# * Included patch for issue 9 from favonia - detects .fig changes for
# pstex files during regular compilation, so long as the pstex
# has been built at least once with make all-pstex.
# Chris Monson (2009-03-27):
# * Bumped version to 2.1.25
# * Cleaned up a bunch of variable setting stuff - more stuff is now
# settable from Makefile.ini
# * Cleaned up documentation for various features, especially settable
# variables.
# * issue 28: support for png -> eps conversion (it even looks good!)
# * issue 29: support for "neverclean" files in Makefile.ini
# * issue 30: make ps2pdf14 the default - fall back when not there
# Chris Monson (2009-03-09):
# * Bumped version to 2.1.24
# * issue 27: xmgrace support (thanks to rolandschulzhd)
# Chris Monson (2008-10-23):
# * Bumped version to 2.1.23
# * issue 23: fixed _check_programs to not use bash string subs
# Chris Monson (2008-09-02):
# * Bumped version to 2.1.22
# * Appled patch from Holger <[email protected]> to add include
# sources and some documentation updates.
# * Updated backup_patterns to be a bit more aggressive (also thanks to
# Holger)
# Chris Monson (2008-08-30):
# * Bumped version to 2.1.21
# * Added ability to specify onlysources.* variables to indicate the only
# files that should *not* be considered includes. Thanks to Holger
# <[email protected]> for this patch.
# * Added an automatic include of Makefile.ini if it exists. Allows
# settings to be made outside of this makefile.
# Chris Monson (2008-05-21):
# * Bumped version to 2.1.20
# * Added manual pstex compilation support (run make all-pstex first)
# * Removed all automatic pstex support. It was totally breaking
# everything and is very hard to incorporate into the makefile
# concept because it requires LaTeX to *fail* before it can
# determine that it needs the files.
# Chris Monson (2008-04-17):
# * Bumped version to 2.1.19
# * Changed the pstex build hack to be on by default
# Chris Monson (2008-04-09):
# * Bumped version to 2.1.18
# * issue 16: fixed pstex build problems, seems nondeterministic. Added
# gratuitious hack for testing: set PSTEX_BUILD_ALL_HACK=1.
# Chris Monson (2008-04-09):
# * Bumped version to 2.1.17
# * issue 20: fixed accumulation of <pid>*.make files - wildcard was
# refusing to work on files that are very recently created.
# Chris Monson (2008-04-02):
# * Bumped version to 2.1.16
# * issue 19: Removed the use of "type" to fix broken "echo" settings
# Chris Monson (2008-03-27):
# * Bumped version to 2.1.15
# * issue 18: Favors binary echo over builtin, as binary understands -n
# * issue 16: Fixed handling of missing pstex_t files in the log
# * issue 9: Added .SECONDARY target for .pstex files
# Chris Monson (2008-03-21):
# * Bumped version to 2.1.14
# * Fixed broken aux file flattening, which caused included bibs to be
# missed.
# Chris Monson (2008-03-20):
# * Bumped version to 2.1.13
# * Changed error output colorization to show errors for missing files
# that are not graphics files.
# Chris Monson (2008-03-20):
# * Bumped version to 2.1.12
# * Fixed a regression introduced in r28 that makes bibtex fail when
# there is no index file present
# Chris Monson (2008-03-03):
# * Bumped version to 2.1.11
# * Fixed issue 11 (handle index files, reported by abachn)
# * Cleaned up some comments and help text
# Chris Monson (2008-01-24):
# * Bumped version to 2.1.10
# * Fixed to work when 'sh' is a POSIX shell like 'dash'
# Chris Monson (2007-12-12):
# * Bumped version to 2.1.9
# * Fixed documentation and dependency graph for pstex files
# Chris Monson (2007-12-12):
# * Bumped version to 2.1.8
# * Added basic pstex_t support for fig files (Issue 9 by favonia)
# I still suggest that psfrag be used instead.
# Chris Monson (2007-10-16):
# * Bumped version to 2.1.7
# * Removed todo item: allow other comment directives for rst conversion
# * Added ability to use global rst style file _rststyle_._include_.tex
# * Added help text to that effect
# Chris Monson (2007-05-20):
# * Bumped version to 2.1.6
# * Changed default paper size for rst files
# * Added todo item: fix paper size for rst files
# * Added todo item: allow other comment directives for rst conversion
# Chris Monson (2007-04-02):
# * Bumped version to 2.1.5
# * Addressed Issue 7, incorrect .gpi.d generation in subdirectories
# Chris Monson (2007-03-28):
# * Bumped version to 2.1.4
# * Fixed syntax error in dot output
# Chris Monson (2007-03-01):
# * Bumped version to 2.1.3
# * Added reST to the included documentation
# * Fixed graphics and script generation to be settable in the
# environment.
# Chris Monson (2007-02-23):
# * Bumped version to 2.1.2
# * Added the ability to generate .tex files from .rst files
# Chris Monson (2006-10-17):
# * Bumped version to 2.1.1
# * Fixed includes from subdirectories (sed-to-sed slash escape problem)
# Chris Monson (2006-10-05):
# * Bumped version to 2.1.0 (pretty serious new feature added)
# * New feature: bib files can now be anywhere on the BIBINPUTS path
# * New programs: kpsewhich (with tetex) and xargs (BSD)
# Chris Monson (2006-09-28):
# * Bumped version to 2.0.9
# * Added ability to parse more than one bibliography
# Chris Monson (2006-06-01):
# * Bumped version to 2.0.8
# * Added .vrb to the list of cleaned files
# Chris Monson (2006-04-26):
# * Bumped version to 2.0.7
# * Fixed so that clean-nographics does not remove .gpi.d files
# * Removed jpg -> eps hack (not working properly -- just pre-convert)
# * Fixed so that postscript grayscale can be done with BSD sed
# Chris Monson (2006-04-25):
# * Bumped version to 2.0.6
# * Fixed so that changed toc, lot, lof, or out causes a rebuild
# Chris Monson (2006-04-17):
# * Bumped version to 2.0.5
# * Added jpg -> eps conversion target
# Chris Monson (2006-04-12):
# * Bumped version to 2.0.4
# * Fixed BSD sed invocation to not use \| as a branch delimiter
# * Added a comment section on what is and is not allowed in BSD sed
# * Made paper size handling more robust while I was at it
# * Fixed postscript RGB grayscale to use a weighted average
# * Fixed postscript HSB grayscale to convert to RGB first
# * Fixed a problem with rebuilding .bbl files
# Chris Monson (2006-04-11):
# * Bumped version to 2.0.3
# * Fixed some BSD sed problems: can't use \n in substitutions
# Chris Monson (2006-04-10):
# * Bumped version to 2.0.2
# * Once again removed ability to create .tex files from scripts
# * \includeonly works again
# Chris Monson (2006-04-09):
# * Bumped version to 2.0.1
# * Fixed grayscale postscript handling to be more robust
# * Added ability to generate ._gray_. files from eps and eps.gz
# * Added ability to clean ._gray_.eps files created from .eps files
# Chris Monson (2006-04-07):
# * Bumped version to 2.0.0
# * Removed clunky ability to create included .tex files from scripts
# * Added note in the help about included tex scripting not working
# * Fixed the .eps generation to delete %.gpihead.make when finished
# * Abandoned designs to use shell variables to create sed scripts
# * Abandoned __default__.tex.sh idea: it causes recursion with %: .
# * Removed web page to-do. All items are now complete.
# * Added better grayscale conversion for dot figures (direct ps fixup).
# * Include files can now be scripted (at the expense of \includeonly).
# * Updated dependency graph to contain better node names.
# Chris Monson (2006-04-06):
# * Bumped version to 2.0b3
# * Top level includes now fail if there is no rule to build them
# * A helpful message is printed when they do fail
# * Grayscale has been changed to be ._gray_, other phonies use _ now, too
# * Grayscale handling has been completed
# * Changed _include_stems target to _includes target.
# * Fixed _includes target to be useful by itself.
# * Removed the ability to specify clean and build targets at once
# * Verified that epsfig works fine with current code
# * Fixed included scripts so that they are added to the dep files
# * Fixed so that graphics includes don't happen if they aren't for gpi
# * Fixed dot output to allow grayscale.
# Chris Monson (2006-04-05):
# * Bumped version to 2.0b2
# * Removed automatic -gray output. It needs fixing in a bad way.
# * Revamped dependency creation completely.
# * Fixed conditional inclusion to actually work (test.nobuild.d, test.d).
# * Fixed clean target to remove log targets
# * Added the 'monochrome' word for gray gpi output
# * Added a _check_gpi_files target that checks for common problems
# * Changed the _version target into the version target (no _)
# * Added better handling of grayscale files. Use the .gray.pdf target.
# * Fixed testing for rebuilds
# Chris Monson (2006-04-04):
# * Bumped version to 2.0b1
# * Changed colorization of output
# * Made .auxbbl and .auxtex .make files secondary targets
# * Shortened and simplified the final latex invocation loop
# * Added version-specific output ($$i vs. $$$$i) in latex loop
# * Added a build message for the first .dvi run (Building .dvi (0))
# * Removed some build messages that most people don't care about.
# * Simplified procedure for user-set colors -- simple text specification
# * Fixed diff output to...not output.
# * Fixed rerun bug -- detect not only when preceded with LaTeX Warning
# * Sped up gpi plotting
# * Added error handling and colorized output for gpi failure
# * Documented color changing stuff.
# * Now sort the flattened aux file to avoid false recompilation needs
# * Added clean-nographics target
# * Don't remove self.dvi file if self.aux is missing in the log
# * Clarified some code. Did some very minor adjusting.
# Chris Monson (2006-04-03):
# * Bumped version to 2.0a7
# * Added .dvi and .ps files as secondary files.
# * Fixed handling of multiple run detection when includeonly is in use.
# * Added code to flatten .aux files.
# * Added more files as .SECONDARY prerequisites to avoid recompilation.
# * Fixed the inputs generation to be much simpler and to use pipes.
# * Added the dependency graph directly into the makefile.
# * Changed flatten-aux to remove \@writefile \relax \newlabel, etc.
# * Undid pipe changes with sed usage (BSD sed doesn't know -f-).
# * Added a _check_programs target that tells you what your system has.
# * Fixed an error in colorization that made unnecessary errors appear
# * Added view targets.
# * Updated help text.
# * Augmented cookies so that .aux can trigger .bbl and .dvi rebuilds
# * Added more informative error handling for dvips and ps2pdf
# Chris Monson (2006-04-02):
# * Bumped version to 2.0a6
# * Added indirection to .bbl dependencies to avoid rebuilding .bbl files
# * Streamlined the diff invocation to eliminate an existence test
# * Removed special shell quote escape variables
# * Moved includes to a more prominent location
# * Fixed .inputs.make to not contain .aux files
# * Fixed embedding to use a file instead of always grepping.
# * Added *.make.temp to the list of cleanable files
# * Fixed Ruby. It should now be supported properly.
# * Now differentiate between all, default, and buildable files.
# * Fixed to bail out on serious errors.
# * Revised the handling of includable files. Still working on it.
# Chris Monson (2006-03-31):
# * Bumped version to 2.0a5
# * Fixed a bug with LaTeX error detection (there can be spaces)
# * Added .bbl support, simplifying everything and making it more correct
# * Refactored some tests that muddy the code
# * Did a little cleanup of some shell loops that can safely be make loops
# * Added support for graphviz .dot files
# * Made _all_programs output easier to read
# * Added the ruby support that has long been advertised
# * Font embedding was screwed up for PostScript -- now implicit
# * Changed the generation of -gray.gpi files to a single command
# * Changed any make-generated file that is not included from .d to .make
# Chris Monson (2006-03-30):
# * Bumped version to 2.0a4
# * Fixed a bug with very long graphics file names
# * Added a todo entry for epsfig support
# * Fixed a bug paper size bug: sometimes more than one entry appears
# * Fixed DVI build echoing to display the number instead of process ID
# * DVI files are now removed on first invocation if ANY file is missing
# * Added a simple grayscale approach: if a file ends with -gray.gpi, it
# is created from the corresponding .gpi file with a special
# comment ##GRAY in its header, which causes coloring to be
# turned off.
# * Fixed a bug in the handling of .tex.sh files. For some reason I had
# neglected to define file stems for scripted output.
# * Removed a trailing ; from the %.graphics dependencies
# * Added dvips embedding (I think it works, anyway)
# Chris Monson (2006-03-29):
# * Bumped version to 2.0a3
# * Fixed error in make 3.79 with MAKEFILE_LIST usage
# * Added the presumed filename to the _version output
# * Added a vim macro for converting sed scripts to make commands
# * Added gpi dependency support (plotting external files and loading gpi)
# * Allow .gpi files to be ignored if called .include.gpi or .nobuild.gpi
# * Fixed sed invocations where \+ was used. BSD sed uses \{1,\}.
# Chris Monson (2006-03-28):
# * Bumped version to 2.0a2
# * Added SHELL_DEBUG and VERBOSE options
# * Changed the default shell back to /bin/sh (unset, in other words)
# * Moved .PHONY declarations closer to their targets
# * Moved help text into its own define block to obtain better formatting
# * Removed need for double-entry when adding a new program invocation
# * Moved .SECONDARY declaration closer to its relevant occurrence
# * Commented things more heavily
# * Added help text about setting terminal and output in gnuplot
# * Created more fine-grained clean targets
# * Added a %.graphics target that generates all of %'s graphics
# * Killed backward-compatible graphics generation (e.g., eps.gpi=gpi.eps)
# * For now, we're just GPL 2, not 3. Maybe it will change later
# * Made the version and svninfo into variables
# Chris Monson (2006-03-27):
# * Bumped version to 2.0a1
# * Huge, sweeping changes -- automatic dependencies
#
# IMPORTANT!
#
# When adding to the following list, do not introduce any blank lines. The
# list is extracted for documentation using sed and is terminated by a blank
# line.
#
# EXTERNAL PROGRAMS:
# = ESSENTIAL PROGRAMS =
# == Basic Shell Utilities ==
CAT ?= cat
CP ?= cp -f
DIFF ?= diff
ECHO ?= echo
EGREP ?= egrep
ENV ?= env
EXPR ?= expr
MV ?= mv -f
SED ?= sed
SORT ?= sort
TOUCH ?= touch
UNIQ ?= uniq
WHICH ?= which
XARGS ?= xargs
SLEEP ?= sleep
# == LaTeX (tetex-provided) ==
BIBTEX ?= bibtex
BIBER ?= biber
DVIPS ?= dvips
LATEX ?= latex
PDFLATEX ?= pdflatex --shell-escape
XELATEX ?= xelatex --shell-escape
LUALATEX ?= lualatex --shell-escape
EPSTOPDF ?= epstopdf
MAKEINDEX ?= makeindex
XINDY ?= xindy
KPSEWHICH ?= kpsewhich
GS ?= gs
# = OPTIONAL PROGRAMS =
# == For MikTex under Cygwin, to get path names right
CYGPATH ?= cygpath
# == Makefile Color Output ==
TPUT ?= tput
# == TeX Generation ==
PERL ?= perl
PYTHON ?= python
RST2LATEX ?= rst2latex.py
LHS2TEX ?= lhs2tex
# == EPS Generation ==
CONVERT ?= convert # ImageMagick
DOT ?= dot # GraphViz
DOT2TEX ?= dot2tex # dot2tex - add options (not -o) as needed
MPOST ?= mpost # MetaPost
FIG2DEV ?= fig2dev # XFig
GNUPLOT ?= gnuplot # GNUplot
INKSCAPE ?= inkscape # Inkscape (svg support)
XMGRACE ?= xmgrace # XMgrace
PNGTOPNM ?= pngtopnm # From NetPBM - step 1 for png -> eps
PPMTOPGM ?= ppmtopgm # From NetPBM - (gray) step 2 for png -> eps
PNMTOPS ?= pnmtops # From NetPBM - step 3 for png -> eps
GUNZIP ?= gunzip # GZipped EPS
ASYMPTOTE ?= asy
# == Beamer Enlarged Output ==
PSNUP ?= psnup
# == Viewing Stuff ==
VIEW_POSTSCRIPT ?= gv
VIEW_PDF ?= xpdf
VIEW_GRAPHICS ?= display
# Xindy glossaries
XINDYLANG ?= english
XINDYENC ?= utf8
# If cygpath is present, then we create a path-norm function that uses it,
# otherwise the function is just a no-op. Issue 112 has details.
USE_CYGPATH := $(if $(shell $(WHICH) $(CYGPATH) 2>/dev/null),yes,)
define path-norm
$(if $(USE_CYGPATH),$(shell $(CYGPATH) -u "$1"),$1)
endef
# Command options for embedding fonts and postscript->pdf conversion
PS_EMBED_OPTIONS ?= -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -dSubsetFonts=true -dMaxSubsetPct=100
PS_COMPATIBILITY ?= 1.4
# If set to something, will cause temporary files to not be deleted immediately
KEEP_TEMP ?=
# Defaults for GPI
DEFAULT_GPI_EPS_FONTSIZE ?= 22
DEFAULT_GPI_PDF_FONTSIZE ?= 12
# Style file for ReST
RST_STYLE_FILE ?= $(wildcard _rststyle_._include_.tex)
# This ensures that even when echo is a shell builtin, we still use the binary
# (the builtin doesn't always understand -n)
FIXED_ECHO := $(if $(findstring -n,$(shell $(ECHO) -n)),$(shell which echo),$(ECHO))
ECHO := $(if $(FIXED_ECHO),$(FIXED_ECHO),$(ECHO))
define determine-gnuplot-output-extension
$(if $(shell $(WHICH) $(GNUPLOT) 2>/dev/null),
$(if $(findstring unknown or ambiguous, $(shell $(GNUPLOT) -e "set terminal pdf" 2>&1)),
eps, pdf),
none)
endef
GNUPLOT_OUTPUT_EXTENSION ?= $(strip $(call determine-gnuplot-output-extension))
# Internal code should use this because of :=. This means that the potentially
# expensive script invocation used to determine whether pdf is available will
# only be run once.
GPI_OUTPUT_EXTENSION := $(strip $(GNUPLOT_OUTPUT_EXTENSION))
# Note, if the terminal *does* understand fsize, then we expect this call to
# create a specific error here: "fsize: expecting font size". Otherwise, we
# assume that fsize is not understood.
GPI_FSIZE_SYNTAX := $(strip \
$(if \
$(filter pdf,$(GPI_OUTPUT_EXTENSION)),\
$(if \
$(findstring fsize: expecting font size,$(shell $(GNUPLOT) -e "set terminal pdf fsize" 2>&1)),\
fsize FONTSIZE,\
font ",FONTSIZE"),\
FONTSIZE))
# Directory into which we place "binaries" if it exists.
# Note that this can be changed on the commandline or in Makefile.ini:
#
# Command line:
# make BINARY_TARGET_DIR=$HOME/pdfs myfile.pdf
#
# Also, you can specify a relative directory (relative to the Makefile):
# make BINARY_TARGET_DIR=pdfs myfile.pdf
#
# Or, you can use Makefile.ini:
#
# BINARY_TARGET_DIR := $(HOME)/bin_out
#
BINARY_TARGET_DIR ?= _out_
RESTARTS := $(if $(MAKE_RESTARTS),$(MAKE_RESTARTS),0)
# SH NOTES
#
# On some systems, /bin/sh, which is the default shell, is not linked to
# /bin/bash. While bash is supposed to be sh-compatible when invoked as sh, it
# just isn't. This section details some of the things you have to stay away
# from to remain sh-compatible.
#
# * File pattern expansion does not work for {}
# * [ "$x" = "$y" ] has to be [ x"$x" x"$y" ]
# * &> for stderr redirection doesn't work, use 2>&1 instead
#
# BSD SED NOTES
#
# BSD SED is not very nice compared to GNU sed, but it is the most
# commonly-invoked sed on Macs (being based on BSD), so we have to cater to
# it or require people to install GNU sed. It seems like the GNU
# requirement isn't too bad since this makefile is really a GNU makefile,
# but apparently GNU sed is much less common than GNU make in general, so
# I'm supporting it here.
#
# Sad experience has taught me the following about BSD sed:
#
# * \+ is not understood to mean \{1,\}
# * \| is meaningless (does not branch)
# * \n cannot be used as a substitution character
# * ? does not mean \{0,1\}, but is literal
# * a\ works, but only reliably for a single line if subsequent lines
# have forward slashes in them (as is the case in postscript)
#
# For more info (on the Mac) you can consult
#
# man -M /usr/share/man re_format
#
# And look for the word "Obsolete" near the bottom.
#
# EXTERNAL PROGRAM DOCUMENTATION SCRIPT
#
# $(call output-all-programs,[<output file>])
define output-all-programs
[ -f '$(this_file)' ] && \
$(SED) \
-e '/^[[:space:]]*#[[:space:]]*EXTERNAL PROGRAMS:/,/^$$/!d' \
-e '/EXTERNAL PROGRAMS/d' \
-e '/^$$/d' \
-e '/^[[:space:]]*#/i\ '\
-e 's/^[[:space:]]*#[[:space:]][^=]*//' \
$(this_file) $(if $1,> '$1',) || \
$(ECHO) "Cannot determine the name of this makefile."
endef
# If they misspell gray, it should still work.
GRAY ?= $(call get-default,$(GREY),)
#
# Utility Functions and Definitions
#
#
# Transcript
# For debug/testing purposes: writes a message to
# filename.transcript.make for each command that was run, including
# some human-readable justification for why it had to be run.
# For example: "Running latex (log-file indicated that this is necessary)"
# Set WRITE_TRANSCRIPT to something to activate
WRITE_TRANSCRIPT ?=
# Set reason for the next run call
# $(call set-run-reason,message)
set-run-reason = export run_reason="$1"
# Log command to the transcript file
# $(call set-run-reason,command,job_name)
define transcript
$(if $(WRITE_TRANSCRIPT), \
$(ECHO) "Running $1 ($$run_reason)" >> $2.transcript.make; \
export run_reason="", \
$(sh_true))
endef
# Don't call this directly - it is here to avoid calling wildcard more than
# once in remove-files.
remove-files-helper = $(if $1,$(RM) $1,$(sh_true))
# $(call remove-files,file1 file2)
remove-files = $(call remove-files-helper,$(wildcard $1))
# Removes all cleanable files in the given list
# $(call clean-files,file1 file2 file3 ...)
# Works exactly like remove-files, but filters out files in $(neverclean)
clean-files = \
$(call remove-files-helper,$(call cleanable-files,$(wildcard $1)))
# Outputs all generated files to STDOUT, along with some others that are
# created by these (e.g., .idx files end up producing .ilg and .ind files).
# Discovered by reading *.fls OUTPUT lines and producing corresponding .ind
# filenames as needed.
#
# $(call get-generated-names,<source recorder file (*.fls)>)
define get-generated-names
[ -f '$1' ] && \
$(SED) \
-e '/^OUTPUT /{' \
-e ' s///' \
-e ' p' \
-e ' s/\.idx/\.ind/p' \
-e ' s/\.ind/\.ilg/p' \
-e '}' \
-e 'd' \
'$1' \
| $(SORT) | $(UNIQ)
endef
# This removes files without checking whether they are there or not. This
# sometimes has to be used when the file is created by a series of shell
# commands, but there ends up being a race condition: make doesn't know about
# the file generation as quickly as the system does, so $(wildcard ...) doesn't
# work right. Blech.
# $(call remove-temporary-files,filenames)
remove-temporary-files = $(if $(KEEP_TEMP),:,$(if $1,$(RM) $1,:))
# Create an identifier from a file name
# $(call cleanse-filename,filename)
cleanse-filename = $(subst .,_,$(subst /,__,$1))
# Escape dots
# $(call escape-fname-regex,str)