summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nameauth/Makefile
blob: 44d46cbfeb371fef65b8024174b2f45dc1482cff (plain)
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
# Copyright (C) 2023 by Charles P. Schaum <charles[dot]schaum@comcast.net>
# -------------------------------------------------------------------
#
# This file may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.3
# of this license or (at your option) any later version.
# The latest version of this license is in:
#
#   http://www.latex-project.org/lppl.txt
#
# and version 1.3 or later is part of all distributions of LaTeX
# version 2005/12/01 or later.
#
# -------------------------------------------------------------------
#
# Usage:
#
# 	Delete all generated files, do clean build on
# 	POSIX-compliant systems, WSL, or Cygwin.
#
# 		make
#
#	This target does the same default build as above.
#
# 		make release
#
# 	Just do a quick rebuild; keep generated files.
# 	One must edit or touch `$(NAME).dtx'.
#
#		make package
#
#	Install/remove supplied files into the user's texmf tree.
#	These targets only work in a POSIX environment and do not
#	install from WSL or Cygwin into a Windows wnvironment
#	They have not been tested on MikTeX for Linux.
#
#		make inst
#		make uninst
#
#	Install/remove supplied files into the local texmf tree.
#	Needs an appropriate level of permission. These targets
#	only work in a fully POSIX environment. They have not
#	been tested on MikTeX for Linux. Note that one should
#	not put "sudo" before these commands because they will
#	not find the proper path variables. Just let the make
#	target ask for the password.
#
#		make install
#		make uninstall
#
#	Compile examples file with pdflatex.
#
#		make examples
#
#	Compile examples file with all different engines.
#
#		make examples ENGINE=xelatex
#		make examples ENGINE=lualatex
#		make examples ENGINE=dvilualatex
#		make examples ENGINE=pdflatex
#		make examples ENGINE=latex
#
#	Compile test files with pdflatex.
#
#		make tests
#
#	Compile test files with all different engines.
#
#		make tests ENGINE=xelatex
#		make tests ENGINE=lualatex
#		make tests ENGINE=dvilualatex
#		make tests ENGINE=pdflatex
#		make tests ENGINE=latex
#
#	Clean up auxiliary files for the package, examples, and tests.
#
#		make clean
#		make exclean
#		make testclean
#
#	Remove all generated files.
#
#		make distclean
#
#	Regenerate files from the dtx file if needed.
#
#		make unpack
#
#	Generate manual illustrations on POSIX-compliant systems
#	and TeX distributions that support doing so. This requires
#	the use of pdfjam, which is not available in some cases.
#
#		make images
#
#	Do a clean package build and create a zip archive
#	ready for distribution.
#
#		make zip
#
# -------------------------------------------------------------------
#
# Programs minimally necessary to execute this make file:
#
#	make		bash		pdflatex	kpsewhich
#	makeindex	zip		pdftex
#
# -------------------------------------------------------------------

#
# Assign most variables in this section. Here we determine what
# programs exist and choices related to that.
#

# Name of package

NAME  = nameauth

# Shell to use; default is bash

SHELL = bash

# Value of current working directory

PWD = $(shell pwd)

# LaTeX engines to use for building th package and for typesetting
# the examples file and testing files; below is the default.
# One can choose from latex, pdflatex, xelatex, lualatex, dvilualatex.

ENGINE ?= pdflatex
BUILDENGINE := $(shell command -v pdflatex 2> /dev/null)
TESTENGINE := $(shell command -v $(ENGINE) 2> /dev/null)

# If we cannot find the engine, add a .exe extension and try that instead.
# This usually occurs only when using WSL and a Windows-native TeX distro.

ifeq ($(strip $(BUILDENGINE)),)
	BUILDENGINE = pdflatex
	EXT = .exe
else
	BUILDENGINE = pdflatex
	EXT =
endif

ifeq ($(strip $(TESTENGINE)),)
	TESTENGINE = $(ENGINE)
	EXT = .exe
else
	TESTENGINE = $(ENGINE)
	EXT =
endif

# Now if we still can't find things, something is very wrong.

ifeq ($(strip $(BUILDENGINE)$(EXT)),)
	$(error Cannot find $(BUILDENGINE). Please check your installation.")
endif

ifeq ($(strip $(TESTENGINE)$(EXT)),)
	$(error Cannot find $(TESTENGINE). Please check your installation.")
endif

# Get Package pversion info; check if not available in some environments.
# Create a zip file name that will not cause problems, e.g., in Windows.

DOVERSION := $(shell command -v ltxfileinfo 2> /dev/null)

ifeq ($(strip $(DOVERSION)),)
	ZIPNAME = $(NAME)
else
	ZIPNAME = $(NAME)-$(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//')
endif

# Determine which dvi to pdf converter to use. If Ghostscript is installed
# use dvipdf, otherwise dvipdfmx.

DVIPDF := $(shell command -v dvipdf 2> /dev/null)

ifeq ($(strip $(DVIPDF)),)
	DVIPDF = dvipdfmx
else
	DVIPDF = dvipdf
endif

# Test if pdfjam is available.

PDFJAM := $(shell command -v pdfjam 2> /dev/null)

# Build options are in this variable.

BUILDOPTS = -recorder -interaction=nonstopmode

# Test and example options are in this variable.

TESTOPTS = -interaction=nonstopmode

# Add options with this variable, e.g.: make ADDOPTS="--synctex=1"

ADDOPTS ?= 

# Core options for generating the sty file and included files
# the normal way. Alternate is via make unpack.

COREOPTS = -shell-escape -recorder -interaction=batchmode

# Local, system-wide tex tree

LOCAL = $(shell kpsewhich$(EXT) --var-value TEXMFLOCAL)

# Tex tree in user's home directory

UTREE = $(shell kpsewhich$(EXT) --var-value TEXMFHOME)

#
# Package Building Section
#

# Default make target is the package release and its dependencies.
# When building, erase all generated files to make a fresh build.

release : distclean package

# Use this recipe to make the package without removing all prior files.

package : $(NAME).pdf
	@echo "Package has been made successfully."

# This is the recipe for the package and the docs.

$(NAME).pdf : $(NAME).sty
	$(BUILDENGINE)$(EXT) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
	makeindex$(EXT) -q -s gglo.ist -o $(NAME).gls $(NAME).glo
	makeindex$(EXT) -q -s gind.ist -o $(NAME).ind $(NAME).idx
	$(BUILDENGINE)$(EXT) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
	$(BUILDENGINE)$(EXT) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null

# This is the core dependency. When run we get all extracted files:
# README.md, nameauth.ins, nameauth.sty, examples.tex, and the test
# files as well.

$(NAME).sty : $(NAME).dtx
	$(BUILDENGINE)$(EXT) $(COREOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null

#
# Examples and Testing Section
#

# Compile the test files into their output documents.

tests :
	$(TESTFILES)
	$(MAKE) testout
	@echo "Test files have been made successfully."

testout : test01_01.pdf \
	test07_01.pdf test07_02.pdf \
	test09_01.pdf \
	test11_01.pdf test11_02.pdf test11_03.pdf test11_04.pdf \
	test11_05.pdf test11_06.pdf test11_07.pdf test11_08.pdf \
	test11_09.pdf test11_10.pdf \
	test13_01.pdf test13_02.pdf test13_03.pdf test13_04.pdf

# Regardless of what engine is used for tests, one must use the
# build engine (pdflatex) to extract the tests.

TESTFILES = $(BUILDENGINE)$(EXT) \
		"\def\NameauthDoTestFiles{}\input{nameauth.dtx}" \
		> /dev/null

# Make the example pdf using the TeX to pdf pattern rule.
# Ensure that at least the style file exists when doing so.

examples : $(NAME).sty examples.pdf
	@echo "Examples file has been made successfully."

# Pattern for pdf files; works on tests or examples with or without
# indexes, those with multiple indexes, and with or without TOC.

%.pdf : %.tex
	$(TESTENGINE)$(EXT) $(TESTOPTS) $< > /dev/null
	$(TESTENGINE)$(EXT) $(TESTOPTS) $< > /dev/null
	if [ -f $*.idx ]; \
		then makeindex$(EXT) -q -o $*.ind $*.idx > /dev/null; fi
	if [ -f $*.rdx ]; \
		then makeindex$(EXT) -q -o $*.rnd $*.rdx > /dev/null; fi
	$(TESTENGINE)$(EXT) $(TESTOPTS) $< > /dev/null
	$(TESTENGINE)$(EXT) $(TESTOPTS) $< > /dev/null
	if [ -f $*.dvi ]; then $(DVIPDF)$(EXT) $*; fi
	if [ -f $*.out.ps ]; then rm $*.out.ps; fi

#
# Generate Manual Images from Examples
#

# Create example images instead of using the supplied pdf files.
# For this recipe one needs the pdfjam script to be somewhere in
# the command search path. Otherwise, this recipe will fail.
# In case of failure, use another application to split the pdf
# files and rename the appropriate pages, or use the pdfpages
# package. Normally, users should not need to make this recipe.
# This target may fail if using MikTeX.

images :
	$(TESTFILES)
	$(MAKE) imageout ENGINE=pdflatex
ifeq ($(strip $(PDFJAM)),)
	@echo "Image files have been typeset, but you need to split \
	       and rename the pages manually; pdfjam is not available. Sorry."
	@echo "Page 3 of test07_02.pdf -> cat01.pdf"
	@echo "Pages 1,2,3 of testo9_01.pdf -> beamer01.pdf, \
	       beamer02.pdf, beamer03.pdf"
else
	pdfjam --paper a6paper --landscape --quiet \
	       test07_02.pdf 3 --outfile cat01.pdf
	pdfjam --paper a5paper --landscape --quiet \
	       test09_01.pdf 1 --outfile beamer01.pdf
	pdfjam --paper a5paper --landscape --quiet \
	       test09_01.pdf 2 --outfile beamer02.pdf
	pdfjam --paper a5paper --landscape --quiet \
	       test09_01.pdf 3 --outfile beamer03.pdf
	@echo "Image files have been made successfully."
endif

imageout : test07_02.pdf test09_01.pdf

#
# Utility Section
#

# Set up phony targets that do not depend on any specific files.

.PHONY: tests images unpack clean exclean testclean distclean uninst ununstall

# Simply unpack the other supplied files from the dtx file.
# Not usually needed to build the package, but can be used,
# for example, in case one accidentally deletes a file.

unpack :
	pdftex$(EXT) $(NAME).dtx

# Delete all auxiliary and log files for the package; prep for
# re-running building and packaging targets. The file
# "nameauth.dtx.aux" has appeared in some systems. Just in case
# someone tries to create a "nameauth.dvi" file, we delete it.

clean :
	rm -f $(NAME).{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
	rm -f $(NAME).{dvi,fls,hd,log,out,tmp}
	rm -f $(NAME).synctex.gz
	rm -f $(NAME).'synctex(busy)'
	rm -f $(NAME).dtx.aux

# Delete all auxiliary and log files for the examples files; leave
# just the TeX file for re-running the examples target.

exclean :
	rm -f examples.{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
	rm -f examples.{dvi,fls,hd,log,out,pdf,tmp}
	rm -f examples.synctex.gz
	rm -f examples.'synctex(busy)'

# Delete all test-related files to prep for re-running tests.

testclean :
	rm -f test*

# Delete all generated files related to package building except zip.

distclean : clean exclean testclean
	rm -f $(NAME).{pdf,ins,sty,zip}
	rm -f README.md
	rm -f compat.tex
	rm -f examples.tex

# Install the package release into the user's tree.
# Note that this target depends on the "package" target,
# so we do not do a clean build. This may aid testing.

inst : package
ifeq ($(strip $(UTREE)),)
	$(error "Unable to install; no path to user tree." )
else
	mkdir -p $(UTREE)/{tex,source,doc}/latex/$(NAME)
	cp $(NAME).dtx $(UTREE)/source/latex/$(NAME)
	cp Makefile $(UTREE)/source/latex/$(NAME)
	cp $(NAME).sty $(UTREE)/tex/latex/$(NAME)
	cp $(NAME).pdf $(UTREE)/doc/latex/$(NAME)
	cp *.tex $(UTREE)/doc/latex/$(NAME)
	cp README.md $(UTREE)/doc/latex/$(NAME)
endif

# Install the package release into the system tree.
# Note that this target depends on the "package" target,
# so we do not do a clean build. This may aid testing.

install : package
ifeq ($(strip $(LOCAL)),)
	$(error "Unable to install; no path to local tree." )
else
	sudo mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(NAME)
	sudo cp $(NAME).dtx $(LOCAL)/source/latex/$(NAME)
	sudo cp Makefile $(LOCAL)/source/latex/$(NAME)
	sudo cp $(NAME).sty $(LOCAL)/tex/latex/$(NAME)
	sudo cp $(NAME).pdf $(LOCAL)/doc/latex/$(NAME)
	sudo cp *.tex $(LOCAL)/doc/latex/$(NAME)
	sudo cp README.md $(LOCAL)/doc/latex/$(NAME)
endif

# Uninstall the package release from the user's tree.
# Show the state of the texmf tree thereafter.

uninst : 
ifeq ($(strip $(LOCAL)),)
	$(error "Unable to uninstall; no path to user tree." )
else
	rm -f $(UTREE)/source/latex/$(NAME)/$(NAME).dtx 
	rm -f $(UTREE)/source/latex/$(NAME)/Makefile
	rm -f $(UTREE)/tex/latex/$(NAME)/$(NAME).sty
	rm -f $(UTREE)/doc/latex/$(NAME)/$(NAME).pdf 
	rm -f $(UTREE)/doc/latex/$(NAME)/*.tex
	rm -f $(UTREE)/doc/latex/$(NAME)/README.md 
	rmdir $(UTREE)/{tex,source,doc}/latex/$(NAME)
	@echo "The texmf tree now looks like:"
	ls $(UTREE)/source/latex/
	ls $(UTREE)/tex/latex/
	ls $(UTREE)/doc/latex/
endif

# Uninstall the package release from the system tree.

uninstall : 
ifeq ($(strip $(LOCAL)),)
	$(error "Unable to uninstall; no path to local tree." )
else
	sudo rm -f $(LOCAL)/source/latex/$(NAME)/$(NAME).dtx 
	sudo rm -f $(LOCAL)/source/latex/$(NAME)/Makefile
	sudo rm -f $(LOCAL)/tex/latex/$(NAME)/$(NAME).sty
	sudo rm -f $(LOCAL)/doc/latex/$(NAME)/$(NAME).pdf
	sudo rm -f $(LOCAL)/doc/latex/$(NAME)/*.tex
	sudo rm -f $(LOCAL)/doc/latex/$(NAME)/README.md
	sudo rmdir $(LOCAL)/{tex,source,doc}/latex/$(NAME)
	@echo "The texmf tree now looks like:"
	ls $(LOCAL)/source/latex/
	ls $(LOCAL)/tex/latex/
	ls $(LOCAL)/doc/latex/
endif

# Create a zip file for upload to CTAN. On systems where ltxfileinfo
# cannot be found, we create a zip file without a version in its name
# instead of a zip file with a dash at the end, which can cause some
# problems on Windows in certain cases.

zip : release
	rm -f $(NAME)*.zip
	ln -sf . $(NAME)
	zip -Drq $(PWD)/$(ZIPNAME).zip \
	$(NAME)/{Makefile,\
	cat01.pdf,beamer01.pdf,beamer02.pdf,beamer03.pdf,\
	$(NAME).dtx,\
	compat.tex,examples.tex,$(NAME).pdf,README.md}
	rm $(NAME)
	@echo "Zip file has been made successfully."