Debian Codegraph @

texmf-dist/source/latex/nameauth/Makefile

raw
1 # Copyright (C) 2025 by Charles P. Schaum <charles[dot][email protected]>
2 # -----------------------------------------------
3 #
4 # This file may be distributed and/or modified under the
5 # conditions of the LaTeX Project Public License, either
6 # version 1.3 of this license or (at your option) any
7 # later version. The latest version of this license is in:
8 #
9 # http://www.latex-project.org/lppl.txt
10 #
11 # and version 1.3 or later is part of all distributions
12 # of LaTeX version 2005/12/01 or later.
13 #
14 # This work includes all source and generated files
15 # described as such in README.md, included herein.
16 #
17 # -----------------------------------------------
18 #
19 # Usage:
20 #
21 # Delete all generated files, do clean build on
22 # POSIX--compliant systems, WSL, or Cygwin.
23 #
24 # make
25 #
26 # This target does the same default build as above.
27 #
28 # make release
29 #
30 # Just do a quick rebuild; keep generated files.
31 # One must edit or touch `$(NAME).dtx'.
32 #
33 # make package
34 #
35 # Install/remove supplied files into the user's texmf tree.
36 # These targets only work in a POSIX environment and do not
37 # install from WSL or Cygwin into a Windows environment
38 # They have not been tested on MikTeX for Linux.
39 #
40 # make inst
41 # make uninst
42 #
43 # Install/remove supplied files into the local texmf tree.
44 # Needs an appropriate level of permission. These targets
45 # only work in a fully POSIX environment. They have not
46 # been tested on MikTeX for Linux. Note that one should
47 # not put "sudo" before these commands because they will
48 # not find the proper path variables. Just let the make
49 # target ask for the password.
50 #
51 # make install
52 # make uninstall
53 #
54 # Add options if needed, such as
55 #
56 # make ADDOPTS="--synctex=1"
57 #
58 # Compile examples file with pdflatex.
59 #
60 # make examples
61 #
62 # Compile examples file with different engines.
63 #
64 # make examples ENGINE=xelatex
65 # make examples ENGINE=lualatex
66 # make examples ENGINE=dvilualatex
67 # make examples ENGINE=pdflatex
68 # make examples ENGINE=latex
69 #
70 # Compile test files with pdflatex.
71 #
72 # make tests
73 #
74 # Compile test files with different engines.
75 #
76 # make tests ENGINE=xelatex
77 # make tests ENGINE=lualatex
78 # make tests ENGINE=dvilualatex
79 # make tests ENGINE=pdflatex
80 # make tests ENGINE=latex
81 #
82 # Clean up auxiliary files for the package, examples, and tests.
83 #
84 # make clean
85 # make exclean
86 # make testclean
87 #
88 # Remove all generated files.
89 #
90 # make distclean
91 #
92 # Regenerate files from the dtx file if needed. This target
93 # does not build the package. It is handy when editing the
94 # dtx to work on README.md, examples.tex, and the like.
95 #
96 # make unpack
97 #
98 # Generate manual illustrations on POSIX-compliant systems
99 # and TeX distributions that support doing so. This requires
100 # the use of pdfjam, which is not available in some cases.
101 #
102 # make images
103 #
104 # Do a clean package build and create a zip archive
105 # ready for distribution.
106 #
107 # make zip
108 #
109 # -----------------------------------------------
110 #
111 # Programs necessary to make this package:
112 #
113 # POSIX Build Utilities
114 # bash
115 # make
116 # sed
117 # zip
118 #
119 # TeX Distro Programs
120 # pdflatex
121 # pdftex
122 # kpsewhich
123 # makeindex
124 #
125 # -----------------------------------------------
126 #
127 # Recommended prerequisites, primary tier:
128 #
129 # TeX Distro Programs
130 # xelatex
131 # lualatex
132 # dvilualatex
133 # latex
134 # ltxfileinfo
135 # dvipdfmx
136 #
137 # -----------------------------------------------
138 #
139 # Recommended prerequisites, secondary tier:
140 #
141 # POSIX Build Utilities
142 # dvipdf
143 #
144 # TeX Distro Programs
145 # pdfjam
146 #
147 # -----------------------------------------------
148 #
149
150 #
151 # Assign most variables in this section. Here we determine what
152 # programs exist and choices related to that.
153 #
154
155 # Name of package
156
157 NAME = nameauth
158
159 # Shell to use; default is bash
160
161 SHELL = bash
162
163 # Value of current working directory
164
165 PWD = $(shell pwd)
166
167 # LaTeX engines to use for building the package and for typesetting
168 # the examples file and testing files; below is the default.
169
170 # We ttest if we are on Windows by adding a .exe extension.
171
172 EXT = .exe
173
174 ENGINE ?= pdflatex
175 BUILDENGINE := $(shell command -v pdflatex$(EXT) 2> /dev/null)
176 TESTENGINE := $(shell command -v $(ENGINE)$(EXT) 2> /dev/null)
177
178 # If we cannot find the engine, try the version without an extension.
179
180 ifeq ($(strip $(BUILDENGINE)),)
181 EXT =
182 BUILDENGINE := $(shell command -v pdflatex$(EXT) 2> /dev/null)
183 endif
184
185 ifeq ($(strip $(TESTENGINE)),)
186 EXT =
187 TESTENGINE := $(shell command -v $(ENGINE)$(EXT) 2> /dev/null)
188 endif
189
190 # Get package version info; check if not available in some environments.
191 # Create a zip file name that will not cause problems, e.g., in Windows.
192
193 DOVERSION := $(shell command -v ltxfileinfo 2> /dev/null)
194
195 ifeq ($(strip $(DOVERSION)),)
196 ZIPNAME = $(NAME)
197 else
198 ZIPNAME = $(NAME)-$(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//')
199 endif
200
201 # Determine which dvi to pdf converter to use. If Ghostscript is installed
202 # use dvipdf, otherwise dvipdfmx. Do not use Ghostscript on Windows.
203
204 DVIPDF := $(shell command -v dvipdf 2> /dev/null)
205
206 ifeq ($(strip $(DVIPDF)),)
207 DVIPDF = dvipdfmx
208 else
209 ifneq ($(strip $(EXT)),)
210 DVIPDF = dvipdfmx
211 else
212 DVIPDF = dvipdf
213 endif
214 endif
215
216 # Test if pdfjam is available.
217
218 PDFJAM := $(shell command -v pdfjam 2> /dev/null)
219
220 # Build options are in this variable.
221
222 BUILDOPTS = --recorder --interaction=nonstopmode
223
224 # Test and example options are in this variable.
225
226 TESTOPTS = --interaction=nonstopmode
227
228 # Add options with this variable, e.g.: make ADDOPTS="--synctex=1"
229
230 ADDOPTS ?=
231
232 # Core options for generating the sty file and included files
233 # the normal way. Alternate is via make unpack.
234
235 COREOPTS = --shell-escape --recorder --interaction=batchmode
236
237 # Local, system-wide tex tree
238
239 LOCAL = $(shell kpsewhich$(EXT) --var-value TEXMFLOCAL)
240
241 # Tex tree in user's home directory
242
243 UTREE = $(shell kpsewhich$(EXT) --var-value TEXMFHOME)
244
245 #
246 # Package Building Section
247 #
248
249 # Default make target is the package release and its dependencies.
250 # When building, erase all generated files to make a fresh build.
251
252 release : distclean package clean
253
254 # Use this recipe to make the package without removing all prior files.
255
256 package : $(NAME).pdf
257 @echo "Package has been made successfully."
258
259 # This is the recipe for the package and the docs.
260
261 $(NAME).pdf : $(NAME).sty
262 ifeq ($(strip $(BUILDENGINE)),)
263 $(error Cannot find engine for building.\
264 Please check your installation)
265 endif
266 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
267 makeindex$(EXT) -q -s gglo.ist -o $(NAME).gls $(NAME).glo
268 makeindex$(EXT) -q -s gind.ist -o $(NAME).ind $(NAME).idx
269 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
270 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
271
272 # This is the core dependency. When run we get all extracted files:
273 # README.md, nameauth.ins, nameauth.sty, examples.tex, and the test
274 # files as well.
275
276 $(NAME).sty : $(NAME).dtx
277 $(BUILDENGINE) $(COREOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
278
279 #
280 # Examples and Testing Section
281 #
282
283 # Compile the test files into their output documents.
284
285 tests :
286 $(TESTFILES)
287 $(MAKE) testout
288 @echo "Test files have been made successfully."
289
290 testout : test01_01.pdf \
291 test05_01.pdf \
292 test07_01.pdf test07_02.pdf \
293 test09_01.pdf \
294 test11_01.pdf test11_02.pdf test11_03.pdf test11_04.pdf \
295 test11_05.pdf test11_06.pdf test11_07.pdf test11_08.pdf \
296 test11_09.pdf test11_10.pdf \
297 test13_01.pdf test13_02.pdf
298
299 # Regardless of what engine is used for tests, one must use the
300 # build engine (pdflatex) to extract the tests.
301
302 TESTFILES = $(BUILDENGINE) \
303 "\def\NameauthDoTestFiles{}\input{nameauth.dtx}" \
304 > /dev/null
305
306 # Make the example pdf using the TeX to pdf pattern rule.
307 # Ensure that at least the style file exists when doing so.
308
309 examples : $(NAME).sty examples.pdf
310 @echo "Examples file has been made successfully."
311
312 # Pattern for pdf files; works on tests or examples with or without
313 # indexes, those with multiple indexes, and with or without TOC.
314
315 %.pdf : %.tex
316 ifeq ($(strip $(TESTENGINE)),)
317 $(error Cannot find engine $(ENGINE) for building.\
318 Please check your installation)
319 endif
320 $(TESTENGINE) $(TESTOPTS) $< > /dev/null
321 $(TESTENGINE) $(TESTOPTS) $< > /dev/null
322 if [ -f $*.idx ]; \
323 then makeindex$(EXT) -q -o $*.ind $*.idx > /dev/null; fi
324 if [ -f $*.rdx ]; \
325 then makeindex$(EXT) -q -o $*.rnd $*.rdx > /dev/null; fi
326 $(TESTENGINE) $(TESTOPTS) $< > /dev/null
327 $(TESTENGINE) $(TESTOPTS) $< > /dev/null
328 if [ -f $*.dvi ]; then $(DVIPDF)$(EXT) $*; fi
329 if [ -f $*.out.ps ]; then rm $*.out.ps; fi
330
331 #
332 # Generate Manual Images from Examples
333 #
334
335 # Create example images instead of using the supplied pdf files.
336 # For this recipe one needs the pdfjam script to be somewhere in
337 # the command search path. Otherwise, this recipe will fail.
338 # In case of failure, use another application to split the pdf
339 # files and rename the appropriate pages, or use the pdfpages
340 # package. Normally, users should not need to make this recipe.
341 # This target may fail if using MikTeX.
342
343 images :
344 $(TESTFILES)
345 $(MAKE) imageout ENGINE=pdflatex
346 ifeq ($(strip $(PDFJAM)),)
347 @echo "Image files have been typeset, but you need to split \
348 and rename the pages manually; pdfjam is not available. Sorry."
349 @echo "Page 3 of test07_02.pdf -> cat01.pdf"
350 @echo "Pages 1,2,3 of testo9_01.pdf -> beamer01.pdf, \
351 beamer02.pdf, beamer03.pdf"
352 else
353 pdfjam --paper a6paper --landscape --quiet \
354 test07_02.pdf 3 --outfile cat01.pdf
355 pdfjam --paper a5paper --landscape --quiet \
356 test09_01.pdf 1 --outfile beamer01.pdf
357 pdfjam --paper a5paper --landscape --quiet \
358 test09_01.pdf 2 --outfile beamer02.pdf
359 pdfjam --paper a5paper --landscape --quiet \
360 test09_01.pdf 3 --outfile beamer03.pdf
361 @echo "Image files have been made successfully."
362 endif
363
364 imageout : test07_02.pdf test09_01.pdf
365
366 #
367 # Utility Section
368 #
369
370 # Set up phony targets that do not depend on any specific files.
371
372 .PHONY: tests images unpack clean exclean testclean distclean uninst ununstall
373
374 # Simply unpack the other supplied files from the dtx file.
375 # Not usually needed to build the package, but can be used,
376 # for example, in case one accidentally deletes a file.
377
378 unpack :
379 pdftex$(EXT) $(NAME).dtx
380
381 # Delete all auxiliary and log files for the package; prep for
382 # re-running building and packaging targets. The file
383 # "nameauth.dtx.aux" has appeared in some systems. Just in case
384 # someone tries to create a "nameauth.dvi" file, we delete it.
385
386 clean :
387 rm -f $(NAME).{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
388 rm -f $(NAME).{dvi,fls,hd,log,out,tmp}
389 rm -f manhook.tmp nullhook.tmp
390 rm -f $(NAME).synctex.gz
391 rm -f $(NAME).'synctex(busy)'
392 rm -f $(NAME).dtx.aux
393
394 # Delete all auxiliary and log files for the examples files; leave
395 # just the TeX file for re-running the examples target.
396
397 exclean :
398 rm -f examples.{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
399 rm -f examples.{dvi,fls,hd,log,out,pdf,tmp}
400 rm -f examples.synctex.gz
401 rm -f examples.'synctex(busy)'
402
403 # Delete all test-related files to prep for re-running tests.
404
405 testclean :
406 rm -f test*
407
408 # Delete all generated files related to package building except zip.
409
410 distclean : clean exclean testclean
411 rm -f $(NAME).{pdf,ins,sty,zip}
412 rm -f README.md
413 rm -f compat.tex
414 rm -f examples.tex
415
416 # Install the package release into the user's tree.
417 # Note that this target depends on the "package" target,
418 # so we do not do a clean build. This may aid testing.
419
420 inst : package
421 ifeq ($(strip $(UTREE)),)
422 $(error "Unable to install; no path to user tree." )
423 else
424 mkdir -p $(UTREE)/{tex,source,doc}/latex/$(NAME)
425 cp Makefile $(UTREE)/source/latex/$(NAME)
426 cp $(NAME).dtx $(UTREE)/source/latex/$(NAME)
427 cp $(NAME).sty $(UTREE)/tex/latex/$(NAME)
428 cp $(NAME).pdf $(UTREE)/doc/latex/$(NAME)
429 cp *.tex $(UTREE)/doc/latex/$(NAME)
430 cp README.md $(UTREE)/doc/latex/$(NAME)
431 endif
432
433 # Install the package release into the system tree.
434 # Note that this target depends on the "package" target,
435 # so we do not do a clean build. This may aid testing.
436
437 install : package
438 ifeq ($(strip $(LOCAL)),)
439 $(error "Unable to install; no path to local tree." )
440 else
441 sudo mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(NAME)
442 sudo cp $(NAME).dtx $(LOCAL)/source/latex/$(NAME)
443 sudo cp Makefile $(LOCAL)/source/latex/$(NAME)
444 sudo cp $(NAME).sty $(LOCAL)/tex/latex/$(NAME)
445 sudo cp $(NAME).pdf $(LOCAL)/doc/latex/$(NAME)
446 sudo cp *.tex $(LOCAL)/doc/latex/$(NAME)
447 sudo cp README.md $(LOCAL)/doc/latex/$(NAME)
448 endif
449
450 # Uninstall the package release from the user's tree.
451 # Show the state of the texmf tree thereafter.
452
453 uninst :
454 ifeq ($(strip $(LOCAL)),)
455 $(error "Unable to uninstall; no path to user tree." )
456 else
457 rm -f $(UTREE)/source/latex/$(NAME)/$(NAME).dtx
458 rm -f $(UTREE)/source/latex/$(NAME)/Makefile
459 rm -f $(UTREE)/tex/latex/$(NAME)/$(NAME).sty
460 rm -f $(UTREE)/doc/latex/$(NAME)/$(NAME).pdf
461 rm -f $(UTREE)/doc/latex/$(NAME)/*.tex
462 rm -f $(UTREE)/doc/latex/$(NAME)/README.md
463 rmdir $(UTREE)/{tex,source,doc}/latex/$(NAME)
464 @echo "The texmf tree now looks like:"
465 ls $(UTREE)/source/latex/
466 ls $(UTREE)/tex/latex/
467 ls $(UTREE)/doc/latex/
468 endif
469
470 # Uninstall the package release from the system tree.
471
472 uninstall :
473 ifeq ($(strip $(LOCAL)),)
474 $(error "Unable to uninstall; no path to local tree." )
475 else
476 sudo rm -f $(LOCAL)/source/latex/$(NAME)/$(NAME).dtx
477 sudo rm -f $(LOCAL)/source/latex/$(NAME)/Makefile
478 sudo rm -f $(LOCAL)/tex/latex/$(NAME)/$(NAME).sty
479 sudo rm -f $(LOCAL)/doc/latex/$(NAME)/$(NAME).pdf
480 sudo rm -f $(LOCAL)/doc/latex/$(NAME)/*.tex
481 sudo rm -f $(LOCAL)/doc/latex/$(NAME)/README.md
482 sudo rmdir $(LOCAL)/{tex,source,doc}/latex/$(NAME)
483 @echo "The texmf tree now looks like:"
484 ls $(LOCAL)/source/latex/
485 ls $(LOCAL)/tex/latex/
486 ls $(LOCAL)/doc/latex/
487 endif
488
489 # Create a zip file for upload to CTAN. On systems where ltxfileinfo
490 # cannot be found, we create a zip file without a version in its name
491 # instead of a zip file with a dash at the end, which can cause some
492 # problems on Windows in certain cases.
493
494 zip : release
495 rm -f $(NAME)*.zip
496 ln -sf . $(NAME)
497 zip -Drq $(PWD)/$(ZIPNAME).zip \
498 $(NAME)/{Makefile,README.md,\
499 cat01.pdf,beamer01.pdf,beamer02.pdf,beamer03.pdf,\
500 compat.tex,examples.tex,\
501 $(NAME).{dtx,pdf}}
502 rm $(NAME)
503 @echo "Zip file has been made successfully."
504