-
Notifications
You must be signed in to change notification settings - Fork 0
/
tex.mk.nw
691 lines (606 loc) · 23.6 KB
/
tex.mk.nw
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
\section{Introduction and usage}
\label{tex:Intro}
The aim of this include file is to make building LaTeX documents easier.
First we want to add suffix rules for LaTeX similar to those already in
make(1)~\cite[see][Sect.\ 10.2]{GNUMake} for \eg (plain) TeX and C.
The main goal is to improve the default rules of GNU make; to change from plain
TeX to LaTeX, to change from DVI-format to PDF-format.
We provide several suffix rules:
first, for ordinary documents, \ie to compile a [[.tex]] file to [[.pdf]],
but we also provide suffix rules for [[.dvi]];
second, for classes and packages, \ie to compile
\begin{enumerate*}
\item a DocTeX [[.dtx]] file to [[.pdf]] or [[.dvi]] and
\item an [[.ins]] file to [[.cls]] or [[.sty]].
\end{enumerate*}
The suffix rules we provide here follows the conventions set out
in~\cite[Sect.\ 10.2]{GNUMake}.
To do the main LaTeX compilation, we use the following set up.
We note that [[xelatex]] requires the [[-8bit]] flag to be able to handle tabs
in [[minted]] output.
Although, the option [[-halt-on-error]] seems interesting to stop the
compilation if an error occurs, so that we don't miss it, it doesn't work.
The reason is that [[latexmk]] doesn't stop on error, it just keeps on going.
\TeX{} on the other hand stops that round of execution, but doesn't ask for
input---which it does otherwise.
So the [[-halt-on-error]] option actually makes it more likely that we miss
that an error occurred.
<<variables>>=
LATEX?= latexmk -dvi -use-make -xelatex -8bit
PDFLATEX?= latexmk -pdf -use-make -xelatex -8bit
LATEXFLAGS?=
PREPROCESS.tex?= ${PDFLATEX} ${LATEXFLAGS} $<
PREPROCESS.dtx?= ${PREPROCESS.tex}
TEX_OUTDIR?= ltxobj
COMPILE.tex?= \
${PDFLATEX} ${LATEXFLAGS} -output-directory=${TEX_OUTDIR} $<; \
while (grep "Rerun to get cross" ${TEX_OUTDIR}/${<:.tex=.log}); \
do ${PDFLATEX} ${LATEXFLAGS} -output-directory=${TEX_OUTDIR} $<; \
done
COMPILE.dtx?= ${COMPILE.tex}
@ Thus one would have to change the [[COMPILE.tex]] variable to change format
from PDF to DVI unless a suffix rule is used.
%We note that we add this output directory to the search path for
%prerequisites~\cite[see][Sect.\ 4.5.1]{GNUMake}.
%The reason for this is that we might need some out the objects as prerequisites
%for other files.
Normally, the above is all that is needed.
However, if you need to manually build the bibliography, you can either add the
[[.bbl]] file as a prerequisite or set the following variable to a non-empty
string.
<<variables>>=
TEX_BBL?=
@ Similarly as for the main LaTeX commands, the bibtex(1) command is controlled
by
<<variables>>=
BIBTEX?= bibtexu
BIBTEXFLAGS?=
BIBLIOGRAPHY.aux?= ${BIBTEX} ${BIBTEXFLAGS} $<
@ And, in case we use biblatex, the biber(1) command is controlled by
<<variables>>=
BIBER?= biber
BIBERFLAGS?=
BIBLIOGRAPHY.bcf?= ${BIBER} -O $@ ${BIBERFLAGS} $<
@
Similarly as for the bibliography, to enable indexing you can either manually
add the [[.ind]] file as a prerequisite, or you can set the following variable
to a non-empty string.
<<variables>>=
TEX_IND?=
@ The indexing-related programs are the following.
<<variables>>=
XINDY?= texindy
XINDYFLAGS?=
COMPILE.idx?= ${XINDY} ${OUTPUT_OPTION} ${XINDYFLAGS} $<
MAKEINDEX?= makeindex
MAKEIDXFLAGS?=
COMPILE.nlo?= ${MAKEINDEX} ${OUTPUT_OPTION} ${MAKEIDXFLAGS} -s nomencl.ist $<
@
We also provide support for PythonTeX.
This is enabled by the following variable.
<<variables>>=
TEX_PYTHONTEX?=
@ Then the required command and flags are controlled with the following
variables.
<<variables>>=
PYTHONTEX?= python3 $$(which pythontex)
PYTHONTEXFLAGS?= --interpreter python:python3
@
Finally, we provide targets to easily add external classes as dependencies.
We add the phony targets
\begin{itemize}
\item[[lncs]] for Springer \ac{LNCS},
\item[[biblatex-lncs]] for the \ac{LNCS} bibliography style for the
[[biblatex]] package,
\item[[rfc]] or [[rfc.bib]] for an up-to-date bibliography containing all
\ac{IETF} \acp{RFC},
\item[[popets]] for the style files of the Proceedings of the Privacy Enhancing
Technologies (PoPETS, De Gruyter Open/Sciendo).
\end{itemize}
Finally, we add a method to quickly merge bibliographies without redundancy.
This is based on the archive syntax of make(1).
This allows us to have the resulting full bibliography [[full.bib]] consist of
the subbibliographies [[sub0.bib]] and [[sub1.bib]]:
\begin{lstlisting}
full.bib: full.bib(sub0.bib sub1.bib)
\end{lstlisting}
Or, directly as a dependency for the PDF:
\begin{lstlisting}
paper.pdf: full.bib(sub0.bib sub1.bib)
\end{lstlisting}
\section{Implementation overview}
The structure of the include file is similar to a header file in C or C++.
The include file uses the old C-style technique to prevent multiple inclusions.
<<tex.mk>>=
ifndef TEX_MK
TEX_MK=true
.NOTPARALLEL:
INCLUDE_MAKEFILES?=.
include ${INCLUDE_MAKEFILES}/portability.mk
<<variables>>
<<targets for documents>>
<<targets for class and package files>>
<<targets for external classes>>
<<targets for cleaning>>
endif
@ We include [[portability.mk]] (\cref{portability.mk}) to get portable
settings for several common utilities.
It is currently not possible to run the TeX-builds in parallel, hence the need
for the [[.NOTPARALLEL]] target --- this runs any jobs that includes [[tex.mk]]
in serial.
However, this is not inherited, any recursive make invocations will run in
parallel unless [[.NOTPARALLEL]] is specified there as well.
We will start with the targets for cleaning.
We provide two phony targets, [[clean-tex]] and [[distclean-tex]], and we
add them as prerequisites to [[clean]] and [[distclean]], respectively.
<<targets for cleaning>>=
.PHONY: clean clean-tex
clean: clean-tex
clean-tex:
<<clean recipe>>
.PHONY: distclean distclean-tex
distclean: distclean-tex
distclean-tex:
<<distclean recipe>>
@ We will add to the recipes in the remainder of the chapter.
However, as latexmk(1) is set as the default in \cref{tex:Intro}, we can
already add the following line to the cleaning recipe.
<<clean recipe>>=
-latexmk -C -output-directory=${TEX_OUTDIR}
[ "${TEX_OUTDIR}" -ef "$$(pwd)" ] || \
${RM} -R ${TEX_OUTDIR}
${RM} *.pytxcode
${RM} -R pythontex-files-*
@
\section{Targets for documents}
Now we will treat how to compile documents.
<<targets for documents>>=
<<auxillary files>>
<<bibliography files>>
<<indices files>>
<<PythonTeX files>>
<<document files>>
<<target for latexmkrc>>
@ These will be discussed in the following sections.
However, since we use latexmk(1) by default (\cref{tex:Intro}), we will discuss
the relevant [[<<latexmkrc>>]] entries in parallel.
We supply a target to easily use our [[<<latexmkrc>>]] with latexmk(1).
<<target for latexmkrc>>=
latexmkrc:
[ -e $@ -o "${INCLUDE_MAKEFILES}" = "." ] || \
${LN} -s ${INCLUDE_MAKEFILES}/latexmkrc $@
@ We also add the corresponding line for cleaning.
<<distclean recipe>>=
[ ! -L latexmkrc ] || ${RM} latexmkrc
@
We will now discuss the different files we need latex(1) to generate.
Note that in many cases we want latex(1) to generate more files, \eg [[.toc]]
files, but we do not have to care about these here.
The reason we can ignore those files is that they do not require any external
tool, \eg bibtex(1), to be run, these files just requires another run of
latex(1).
\subsection{Auxillary files}
Many steps in compiling a LaTeX document needs the [[.aux]] file.
Thus we will first introduce a rule for creating the [[.aux]] file.
We will create it in the specified output directory.
<<auxillary files>>=
${TEX_OUTDIR}/%.aux: %.tex
<<create output directory and preprocess TeX>>
@ Then we simply do
<<create output directory and preprocess TeX>>=
${MKDIR} ${TEX_OUTDIR}
${PREPROCESS.tex}
@
\subsection{Bibliographies}
One file that is commonly needed is the one used to create the bibliography,
the [[.bbl]] file.
There are two ways to create this file, either using classical bibtex(1) or
using the [[biblatex]] package and biber(1).
<<bibliography files>>=
<<bbl target for bibtex>>
<<bbl target for biber>>
@
The first approach, using bibtex(1), depends on the [[.aux]] file.
This means that we can have a target creating the desired [[.bbl]] file from
the [[.aux]] file.
<<bbl target for bibtex>>=
${TEX_OUTDIR}/%.bbl: ${TEX_OUTDIR}/%.aux
${BIBLIOGRAPHY.aux}
${MV} $@ ${@:.bbl=.blg} ${TEX_OUTDIR}
@
The second approach uses the [[biblatex]] package~\cite{biblatex} and
biber(1)~\cite{biber}.
They do not rely on the [[.aux]] file, instead [[biblatex]] creates a [[.bcf]]
file.
Thus its target is exactly the same as that of the [[.aux]] file.
<<bbl target for biber>>=
${TEX_OUTDIR}/%.bcf: %.tex
<<create output directory and preprocess TeX>>
@ This [[.bcf]] file is in turn used by biber(1) to create the [[.bbl]] file.
To compile the [[.bbl]] with biber(1) and put the output files in the desired
directory, we do the following.
<<bbl target for biber>>=
${TEX_OUTDIR}/%.bbl: ${TEX_OUTDIR}/%.bcf
${BIBLIOGRAPHY.bcf}
@
As mentioned in \cref{tex:Intro}, we can automatically add the [[.bbl]] file as
a prerequisite if the variable [[TEX_BBL]] is set.
<<bibliography files>>=
ifneq (${TEX_BBL},)
%.pdf ${TEX_OUTDIR}/%.pdf: ${TEX_OUTDIR}/%.bbl
endif
@
\subsection{Indices}
There are several time we need to work with indices, \eg when working with
standard indices but also glossaries.
Here we provide some suffix rules to make it easier to build such indices.
Before we start, however, we will note that many of these rules are not needed
if the [[imakeidx]] package~\cite{imakeidx} is used.
We do recommend to use this package.
Furthermore, we provide rules for the [[nomencl]] package, however, we
recommend to use the [[glossaries]] package~\cite{glossaries} instead.
The [[glossaries]] package also has native support for xindy(1).
Although the [[glossaries]] package supports abbreviations and acronyms, we
recommend the [[acro]] package~\cite{acro} for this instead.
The standard LaTeX index uses an [[.idx]] file, which is generated similarly as
the [[.aux]] file.
Thus we can use the same type of target.
<<indices files>>=
${TEX_OUTDIR}/%.idx: %.tex
<<create output directory and preprocess TeX>>
@ The actual index, which resides in a [[.ind]] file, can then be generated as
follows.
<<indices files>>=
${TEX_OUTDIR}/%.ind: ${TEX_OUTDIR}/%.idx
${COMPILE.idx}
@ As mentioned in \cref{tex:Intro}, we can automatically add the [[.ind]] file
as
a prerequisite if the variable [[TEX_IND]] is set.
<<indices files>>=
ifneq (${TEX_IND},)
%.pdf ${TEX_OUTDIR}/%.pdf: ${TEX_OUTDIR}/%.ind
endif
@
For backwards compatibility, we provide the following code for the
[[nomenclature]] package.
<<indices files>>=
${TEX_OUTDIR}/%.nlo: %.tex
<<create output directory and preprocess TeX>>
${TEX_OUTDIR}/%.nls: ${TEX_OUTDIR}/%.nlo
${COMPILE.nlo}
@ And now we add the corresponding code for latexmk(1).
The code is fetched from the latexmk example-files on \ac{CTAN}\footnote{%
URL: \url{http://mirrors.ctan.org/support/latexmk/example_rcfiles/nomenclature_latexmkrc}
}.
<<latexmkrc>>=
add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
sub makenlo2nls {
system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
}
@
\subsection{PythonTeX}
Occasionally we use PythonTeX.
We also provide a target for the required files.
However, this construction requires that we load PythonTeX as follows.
\begin{minted}{LaTeX}
\usepackage{pythontex}
\setpythontexoutputdir{.}
\setpythontexworkingdir{..}
\end{minted}
The code is as follows.
<<PythonTeX files>>=
${TEX_OUTDIR}/%.pytxcode: ${TEX_OUTDIR}/%.aux
cd $(dir $@) && ${PYTHONTEX} ${PYTHONTEXFLAGS} $(basename $(notdir $@))
%.pytxmcr ${TEX_OUTDIR}/%.pytxmcr:: ${TEX_OUTDIR}/%.pytxcode
cd ${TEX_OUTDIR} && ${PYTHONTEX} ${PYTHONTEXFLAGS} $(basename $(notdir $@))
@
As mentioned in \cref{tex:Intro}, we can automatically add the [[.pytxmcr]]
file as a prerequisite if the variable [[TEX_PYTHONTEX]] is set.
<<bibliography files>>=
ifneq (${TEX_PYTHONTEX},)
${TEX_OUTDIR}/%.pdf: ${TEX_OUTDIR}/%.pytxmcr
endif
@
If we use latexmk(1), then we must also add instructions for this in
[[<<latexmkrc>>]].
The following code is fetched from the latexmk example-files on
\ac{CTAN}\footnote{%
URL: \url{http://mirrors.ctan.org/support/latexmk/example_rcfiles/pythontex-latexmkrc}
}.
<<latexmkrc>>=
# This version has a fudge on the latex and pdflatex commands that
# allows the pythontex custom dependency to work even when $out_dir
# is used to set the output directory. Without the fudge (done by
# trickery symbolic links) the custom dependency for using pythontex
# will not be detected.
add_cus_dep('pytxcode', 'pytxmcr', 0, 'pythontex');
sub pythontex {
# This subroutine is a fudge, because it from latexmk's point of
# view, it makes the main .tex file depend on the .pytxcode file.
# But it doesn't actually make the .tex file, but is used for its
# side effects in creating other files. The dependence is a way
# of triggering the rule to be run whenever the .pytxcode file
# changes, and to do this before running latex/pdflatex again.
return system("pythontex3 --verbose \"$_[0]\"");
}
$pdflatex = 'internal mylatex %R %Z pdflatex %O %S';
$latex = 'internal mylatex %R %Z latex %O %S';
sub mylatex {
my $root = shift;
my $dir_string = shift;
my $code = "$root.pytxcode";
my $result = "pythontex-files-$root";
if ($dir_string) {
warn "mylatex: Making symlinks to fool cus_dep creation\n";
unlink $code;
if (-l $result) {
unlink $result;
}
elsif (-d $result) {
unlink glob "$result/*";
rmdir $result;
}
symlink $dir_string.$code, $code;
if ( ! -e $dir_string.$result ) { mkdir $dir_string.$result; }
symlink $dir_string.$result, $result;
}
else {
foreach ($code, $result) { if (-l) { unlink; } }
}
return system @_;
}
@
\subsection{Document files}
Now that we have all prerequisite files, we can actually compile the document.
For simplicity we add file in both the current working directory and the
[[TEX_OUTDIR]] as targets.
The reason for this is that it makes the makefile easier to write, usually we
prefer writing just the [[.pdf]] file --- and not the path to the [[.pdf]] in
the [[TEX_OUTDIR]] directory.
And for the same reason, we create a symbolic link between them after
compilation --- this allows make(1) to track modification times correctly.
(We need a symbolic link, rather than a hard link, because upon recompilation,
the file in [[TEX_OUTDIR]] is unlinked, whereas the other is not.)
<<document files>>=
%.pdf ${TEX_OUTDIR}/%.pdf: %.tex
${COMPILE.tex}
-${LN} ${TEX_OUTDIR}/$@ $@
%.dvi ${TEX_OUTDIR}/%.dvi: %.tex
<<compile DVI>>
-${LN} ${TEX_OUTDIR}/$@ $@
@
The compilation step for DVI is the usual.
We compile once, then we recompile as long as the log file tells us.
<<compile DVI>>=
${LATEX} -output-directory=${TEX_OUTDIR} ${LATEXFLAGS} $<
while ( grep "Rerun to get cross" ${TEX_OUTDIR}/${<:.tex=.log} ); do \
${LATEX} -output-directory=${TEX_OUTDIR} ${LATEXFLAGS} $<; \
done
@
\section{Targets for merging bibliographies}
To merge bibliographies we will use [[bibtool]] and make's archive rules.
In particular, we extend the general rules we defined in [[portability.mk]].
<<variables>>=
BIBTOOL?= bibtool
BIBTOOLFLAGS?=--preserve.key.case=on --print.deleted.entries=off -s -d -r biblatex
ARCHIVE.bib?= ${CAT} $(if $(wildcard $@),$@) $% | \
${BIBTOOL} ${BIBTOOLFLAGS} -o $@
@
\section{Targets for class and package files}
There are two parts concerning class and package files.
<<targets for class and package files>>=
<<compile sty and cls files>>
<<compile class and package documentation>>
@ These are very similar to what we have done above, especially the
documentation.
Compiling a class or package from DocTeX source is easier than compiling
a document.
We can normally create the [[.sty]] and [[.cls]] files by running latex(1) on
the [[.ins]] file.
<<compile sty and cls files>>=
%.cls %.sty: %.ins
${LATEX} $<
@
We can then compile the documentation similarly to how we compile normal
documents.
<<compile class and package documentation>>=
%.pdf ${TEX_OUTDIR}/%.pdf: %.dtx
${COMPILE.dtx}
-${LN} ${TEX_OUTDIR}/$@ $@
%.dvi ${TEX_OUTDIR}/%.dvi: %.dtx
<<compile DVI>>
-${LN} ${TEX_OUTDIR}/$@ $@
@ However, we must tell make(1) how to make a [[.bbl]] etc.\ from [[.dtx]].
<<compile class and package documentation>>=
${TEX_OUTDIR}/%.aux ${TEX_OUTDIR}/%.bcf ${TEX_OUTDIR}/%.idx: %.dtx
${PREPROCESS.dtx}
@
\section{External classes and packages}
Occasionally, we are required to use document classes that are not in
\ac{CTAN}.
Here we provide targets for some such classes and packages.
<<targets for external classes>>=
<<a general downloader>>
<<Springer LNCS>>
<<biblatex LNCS style>>
<<the RFC bibliography>>
<<PoPETS>>
@
We will now construct a general downloader, then we will use this downloader to
write targets for the external classes we are interested in.
In general, what we want this function to do is to download an archive or
repository ([[TEX_EXT_SRC]]), extract the files we are interested in
([[TEX_EXT_FILES]]) to the destination directory ([[TEX_EXT_DIR]]), and
finally, create symbolic links to those files from the current working
directory.
<<a general downloader>>=
define download_archive
<<targets for symlinks>>
<<targets for desired files>>
<<targets for archive>>
<<target for cleaning>>
endef
define download_repo
<<targets for symlinks>>
<<targets for desired files>>
<<targets for repo>>
<<target for cleaning>>
endef
@
The first thing we want to do is to generate targets and recipes for how to
create the symbolic links, assuming that the target files already exists.
First we set up a dependency between the files we are interested in and where
that file is actually located.
Then we create a recipe which will create a symbolic link between them.
We use the [[notdir]] function~\cite[Sect.\ 8.3]{GNUMake} to remove any
directory-part since we want to create the symbolic link in the current working
directory.
<<targets for symlinks>>=
$(foreach file,${TEX_EXT_FILES-$(1)},\
$(eval $(notdir ${file}): ${TEX_EXT_DIR-$(1)}/${file}))
$(notdir ${TEX_EXT_FILES-$(1)}):
${LN} $$^ $$@
@ Note that we need the [[eval]] command above to evaluate the rule for each
file, otherwise we would get \emph{one line} with many colons --- which is not
valid syntax for make(1).
To make it easier to add these files as prerequisites to a target, we also
provide the following phony target.
<<targets for symlinks>>=
.PHONY: $(1)
$(1): $(notdir ${TEX_EXT_FILES-$(1)})
@
Now we need something to trigger the download of the archive or the repository.
One way to do this is to add a prerequisite for the files from the archive or
repository.
<<targets for desired files>>=
$(addprefix ${TEX_EXT_DIR-$(1)}/,${TEX_EXT_FILES-$(1)}): \
${TEX_EXT_DIR-$(1)}/${TEX_EXT_SRC-$(1)}
@ Now we turn to the recipe.
In the case of an archive, we must extract the desired files.
We let the variable [[TEX_EXT_EXTRACT]] contain the extraction command.
<<targets for archive>>=
$(addprefix ${TEX_EXT_DIR-$(1)}/,${TEX_EXT_FILES-$(1)}):
${TEX_EXT_EXTRACT-$(1)}
@ For a repository we can simply copy the file or create a link.
We prefer the latter.
<<targets for repo>>=
$(addprefix ${TEX_EXT_DIR-$(1)}/,${TEX_EXT_FILES-$(1)}):
${LN} ${TEX_EXT_SRC-$(1)}/$${@:${TEX_EXT_DIR-$(1)}/%=%} $$@
@
The file [[TEX_EXT_SRC]] can be either an archive or a repository.
We let [[TEX_EXT_URL]] be the \ac{URL} to fetch it from in both cases.
In the case of an archive we do the following.
<<targets for archive>>=
${TEX_EXT_DIR-$(1)}/${TEX_EXT_SRC-$(1)}:
${MKDIR} ${TEX_EXT_DIR-$(1)}
${CURL} -o $$@ ${TEX_EXT_URL-$(1)}
@ In the case of a repository, we simply clone it.
<<targets for repo>>=
${TEX_EXT_DIR-$(1)}/${TEX_EXT_SRC-$(1)}:
git clone ${TEX_EXT_URL-$(1)} $$@
@ We note that the directory of the repo should be an order-only
prerequisite~\cite[see][Sect.\ 4.3]{GNUMake} for the files inside.
Unfortunately this is not the case at the moment.
Finally, we must also do some cleaning.
<<target for cleaning>>=
.PHONY: distclean clean-$(1)
distclean: clean-$(1)
clean-$(1):
${RM} ${TEX_EXT_FILES-$(1)}
[ "${TEX_EXT_DIR-$(1)}" = "." ] && ${RM} ${TEX_EXT_SRC-$(1)} \
|| ${RM} -R ${TEX_EXT_DIR-$(1)}
@
\subsection{Springer LNCS}
Springer's \ac{LNCS} series is used for the proceedings of many
conferences.
The style files are available on Springer's web site, but unfortunately not
under any permissive license\footnote{%
It would be most desirable that they were made available in \ac{CTAN} under
an open license.
}.
So, we must, each and every one of us, connect to Springer's server and
download our own copy.
This is what we automate here.
We use the downloader described above.
<<Springer LNCS>>=
TEX_EXT_FILES-lncs?= llncs.cls sprmindx.sty splncs03.bst aliascnt.sty remreset.sty
TEX_EXT_DIR-lncs?= lncs
TEX_EXT_SRC-lncs?= llncs2e.zip
TEX_EXT_URL-lncs?= https://resource-cms.springernature.com/springer-cms/rest/v1/content/19238648/data/v1
TEX_EXT_EXTRACT-lncs?=${UNZIP} -u $$< -d ${TEX_EXT_DIR-lncs}
$(eval $(call download_archive,lncs))
@
We also want to add backwards compatibility for when we used [[llncs]] instead
of just [[lncs]].
<<Springer LNCS>>=
.PHONY: llncs
llncs: lncs
@
\subsection{LNCS style for [[biblatex]]}
There is also \iac{LNCS} style for the [[biblatex]] package available on
GitHub.
Since it is available on GitHub, we recommend adding it as a Git submodule.
I.e.\ run the following command.
\begin{lstlisting}
git submodule add https://github.com/neapel/biblatex-lncs.git
\end{lstlisting}
This will add a directory [[biblatex-lncs]] to the current directory.
If we do not add it as a submodule we can use the downloader above.
<<biblatex LNCS style>>=
TEX_EXT_FILES-biblatex-lncs?= lncs.bbx lncs.cbx lncs.dbx
TEX_EXT_DIR-biblatex-lncs?= lncs
TEX_EXT_SRC-biblatex-lncs?= biblatex-lncs
TEX_EXT_URL-biblatex-lncs?= https://github.com/NorwegianRockCat/biblatex-lncs.git
$(eval $(call download_repo,biblatex-lncs))
@
\subsection{The RFC bibliography}
Occasionally we want to cite \ac{IETF} \acp{RFC}.
Fortunately, Roland Bless of Karlsruher Institute of Technology provides an
up-to-date bibliography file for all \acp{RFC}, so we will use that one.
This is a single file, so we do not need to use the downloader.
<<the RFC bibliography>>=
rfc.bib:
<<download rfc.bib>>
<<change misc to techreport>>
${TEXMF}/tex/latex/rfc.bib:
mkdir -p ${TEXMF}/tex/latex/
<<download rfc.bib>>
<<change misc to techreport>>
@
We will use curl(1) to download a compressed version from Bless' site.
We let curl(1) output the contents to standard out and pipe it to the
uncompress(1) utility and, finally, redirect the result to the target file.
<<download rfc.bib>>=
${CURL} -o - http://tm.uka.de/~bless/rfc.bib.gz 2>/dev/null \
| ${UNCOMPRESS.gz} - > $@ ; \
@
According to \ac{IETF}~\cite[Sect.\ 5.2]{IETFCitingRFCs} the \acp{RFC} should
be cited as the [[techreport]] BibTeX type.
<<change misc to techreport>>=
${SED} -i "s/@misc/@techreport/" $@
@
We also provide a phony target for these two files.
<<the RFC bibliography>>=
.PHONY: rfc
rfc: rfc.bib ${TEXMF}/tex/latex/rfc.bib
@
Finally, we provide a phony cleaning for cleaning.
The target is named [[clean-rfc]] and is added as a prerequisite for
[[distclean]] --- this way its recipe will not interfere with any cleaning
recipe written by the user.
<<the RFC bibliography>>=
.PHONY: distclean clean-rfc
distclean: clean-rfc
clean-rfc:
${RM} rfc.bib
@
\subsection{Proceedings of the Privacy Enhancing Technologies Symposium}
We would also like to be able to use the PoPETS format.
<<PoPETS>>=
TEX_EXT_FILES-popets?=by-nc-nd.pdf sciendo-logo.pdf dgruyter_NEW.sty
TEX_EXT_URL-popets?=https://petsymposium.org/files/popets.zip
TEX_EXT_DIR-popets?=popets
TEX_EXT_SRC-popets?=popets.zip
TEX_EXT_EXTRACT-popets?=${UNZIP} -p $$< popets/$$(notdir $$@) > $$@
$(eval $(call download_archive,popets))
@