Debian Codegraph @

texmf-dist/source/generic/schemata/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 test file with pdflatex.
59 #
60 # make test
61 #
62 # Compile test file with different engines.
63 #
64 # make test ENGINE=xelatex
65 # make test ENGINE=lualatex
66 # make test ENGINE=pdflatex
67 # make test ENGINE=latex
68 #
69 # make test ENGINE=xetex
70 # make test ENGINE=luatex
71 # make test ENGINE=dviluatex
72 # make test ENGINE=pdftex
73 # make test ENGINE=tex
74 # make test ENGINE=eplain
75 # make test ENGINE=lollipop
76 #
77 # The dvilualatex engine is not available due to manual font setup prerequisites.
78 #
79 # Clean up auxiliary files for the package, examples, and tests.
80 #
81 # make clean
82 # make testclean
83 #
84 # Remove all generated files.
85 #
86 # make distclean
87 #
88 # Regenerate files from the dtx file if needed. This target
89 # does not build the package. It is handy when editing the
90 # dtx to work on README.md, examples.tex, and the like.
91 #
92 # make unpack
93 #
94 # Do a clean package build and create a zip archive
95 # ready for distribution.
96 #
97 # make zip
98 #
99 # -----------------------------------------------
100 #
101 # Programs necessary to make this package:
102 #
103 # POSIX Build Utilities
104 # bash
105 # make
106 # sed
107 # zip
108 #
109 # TeX Distro Programs
110 # pdflatex
111 # pdftex
112 # kpsewhich
113 # makeindex
114 #
115 # -----------------------------------------------
116 #
117 # Recommended prerequisites, primary tier:
118 #
119 # TeX Distro Programs
120 # xelatex
121 # lualatex
122 # latex
123 # xetex
124 # luatex
125 # pdftex
126 # tex
127 # ltxfileinfo
128 # dvipdfmx
129 #
130 # -----------------------------------------------
131 #
132 # Recommended prerequisites, secondary tier:
133 #
134 # POSIX Build Utilities
135 # dvipdf
136 #
137 # TeX Distro Programs
138 # dviluatex
139 # eplain
140 # lollipop
141 #
142 # -----------------------------------------------
143 #
144
145 #
146 # Assign most variables in this section. Here we determine what
147 # programs exist and choices related to that.
148 #
149
150 # Name of package
151
152 NAME = schemata
153
154 # Shell to use; default is bash
155
156 SHELL = bash
157
158 # Value of current working directory
159
160 PWD = $(shell pwd)
161
162 # LaTeX engines to use for building the package and for typesetting
163 # the examples file and testing files; below is the default.
164
165 # We ttest if we are on Windows by adding a .exe extension.
166
167 EXT = .exe
168
169 ENGINE ?= pdflatex
170 BUILDENGINE := $(shell command -v pdflatex$(EXT) 2> /dev/null)
171 TESTENGINE := $(shell command -v $(ENGINE)$(EXT) 2> /dev/null)
172
173 # If we cannot find the engine, try the version without an extension.
174
175 ifeq ($(strip $(BUILDENGINE)),)
176 EXT =
177 BUILDENGINE := $(shell command -v pdflatex$(EXT) 2> /dev/null)
178 endif
179
180 ifeq ($(strip $(TESTENGINE)),)
181 EXT =
182 TESTENGINE := $(shell command -v $(ENGINE)$(EXT) 2> /dev/null)
183 endif
184
185 # Get package version info; check if not available in some environments.
186 # Create a zip file name that will not cause problems, e.g., in Windows.
187
188 DOVERSION := $(shell command -v ltxfileinfo 2> /dev/null)
189
190 ifeq ($(strip $(DOVERSION)),)
191 ZIPNAME = $(NAME)
192 else
193 ZIPNAME = $(NAME)-$(shell ltxfileinfo -v $(NAME).dtx|sed -e 's/^v//')
194 endif
195
196 # Determine which dvi to pdf converter to use. If Ghostscript is installed
197 # use dvipdf, otherwise dvipdfmx. Do not use Ghostscript on Windows.
198
199 DVIPDF := $(shell command -v dvipdf 2> /dev/null)
200
201 ifeq ($(strip $(DVIPDF)),)
202 DVIPDF = dvipdfmx
203 else
204 ifneq ($(strip $(EXT)),)
205 DVIPDF = dvipdfmx
206 else
207 DVIPDF = dvipdf
208 endif
209 endif
210
211 # Build options are in this variable.
212
213 BUILDOPTS = --recorder --interaction=nonstopmode
214
215 # Test and example options are in this variable.
216
217 TESTOPTS = --interaction=nonstopmode
218
219 # Add options with this variable, e.g.: make ADDOPTS="--synctex=1"
220
221 ADDOPTS ?=
222
223 # Core options for generating the sty file and included files
224 # the normal way. Alternate is via make unpack.
225
226 COREOPTS = --shell-escape --recorder --interaction=batchmode
227
228 # Local, system-wide tex tree
229
230 LOCAL = $(shell kpsewhich$(EXT) --var-value TEXMFLOCAL)
231
232 # Tex tree in user's home directory
233
234 UTREE = $(shell kpsewhich$(EXT) --var-value TEXMFHOME)
235
236 # Used when testing for formats that are hard to deal with.
237
238 DVILUALATEX = dvilualatex
239 EPLAIN = eplain
240
241 #
242 # Package Building Section
243 #
244
245 # Default make target is the package release and its dependencies.
246 # When building, erase all generated files to make a fresh build.
247
248 release : distclean package clean
249
250 # Use this recipe to make the package without removing all prior files.
251
252 package : $(NAME).pdf
253 @echo "Package has been made successfully."
254
255 # This is the recipe for the package and the docs.
256
257 $(NAME).pdf : $(NAME).sty
258 ifeq ($(strip $(BUILDENGINE)),)
259 $(error Cannot find engine for building.\
260 Please check your installation)
261 endif
262 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
263 makeindex$(EXT) -q -s gglo.ist -o $(NAME).gls $(NAME).glo
264 makeindex$(EXT) -q -s gind.ist -o $(NAME).ind $(NAME).idx
265 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
266 $(BUILDENGINE) $(BUILDOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
267
268 # This is the core dependency. When run we get all extracted files:
269 # README.md, nameauth.ins, nameauth.sty, examples.tex, and the test
270 # files as well.
271
272 $(NAME).sty : $(NAME).dtx
273 $(BUILDENGINE) $(COREOPTS) $(ADDOPTS) $(NAME).dtx > /dev/null
274
275 #
276 # Testing Section
277 #
278
279 # Make schematest pdf using the TeX to pdf pattern rule.
280 # Ensure that at least the style file exists when doing so.
281 # Show success messages for only allowed engines.
282
283 test : $(NAME).sty schematest.pdf
284 @echo "Test file has been made successfully."
285
286 # Pattern for pdf files.
287
288 %.pdf : %.tex
289 ifeq ($(strip $(TESTENGINE)),)
290 ifeq ($(ENGINE), $(EPLAIN))
291 pdftex$(EXT) --jobname=$* "\input eplain \input $*"
292 else
293 $(error $(ENGINE) may not be available in some cases.\
294 Check documentation. Cannot find engine for testing;\
295 please check your installation)
296 endif
297 else
298 ifeq ($(ENGINE), $(DVILUALATEX))
299 $(error $(ENGINE) requires manual font installation.\
300 This make file does not process it)
301 else
302 $(TESTENGINE) $(TESTOPTS) $< > /dev/null
303 if [ -f $*.dvi ]; then $(DVIPDF)$(EXT) $*; fi
304 if [ -f $*.out.ps ]; then rm $*.out.ps; fi
305 endif
306 endif
307
308 #
309 # Utility Section
310 #
311
312 # Set up phony targets that do not depend on any specific files.
313
314 .PHONY: test unpack clean testclean distclean uninst ununstall
315
316 # Simply unpack the other supplied files from the dtx file.
317 # Not usually needed to build the package, but can be used,
318 # for example, in case one accidentally deletes a file.
319
320 unpack :
321 pdftex$(EXT) $(NAME).dtx
322
323 # Delete all auxiliary and log files for the package; prep for
324 # re-running building and packaging targets. The file
325 # "nameauth.dtx.aux" has appeared in some systems. Just in case
326 # someone tries to create a "nameauth.dvi" file, we delete it.
327
328 clean :
329 rm -f $(NAME).{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
330 rm -f $(NAME).{dvi,fls,hd,log,out,tmp}
331 rm -f $(NAME).synctex.gz
332 rm -f $(NAME).'synctex(busy)'
333 rm -f $(NAME).dtx.aux
334
335 # Delete all auxiliary and log files for the test file; leave
336 # just the TeX file for re-running the test target.
337
338 testclean :
339 rm -f schematest.{aux,glo,gls,idx,rdx,ilg,ind,rnd,toc}
340 rm -f schematest.{dvi,fls,hd,log,out,pdf,tmp}
341 rm -f schematest.synctex.gz
342 rm -f schematest.'synctex(busy)'
343
344 # Delete all generated files related to package building except zip.
345
346 distclean : clean testclean
347 rm -f $(NAME).{pdf,ins,sty,zip}
348 rm -f README.md
349 rm -f schemata-eps-converted-to.pdf
350 rm -f schematest.tex
351
352 # Install the package release into the user's tree.
353 # Note that this target depends on the "package" target,
354 # so we do not do a clean build. This may aid testing.
355
356 inst : package
357 ifeq ($(strip $(UTREE)),)
358 $(error "Unable to install; no path to user tree." )
359 else
360 mkdir -p $(UTREE)/{tex,source,doc}/generic/$(NAME)
361 cp $(NAME).dtx $(UTREE)/source/generic/$(NAME)
362 cp $(NAME).eps $(UTREE)/source/generic/$(NAME)
363 cp Makefile $(UTREE)/source/generic/$(NAME)
364 cp $(NAME).sty $(UTREE)/tex/generic/$(NAME)
365 cp $(NAME).pdf $(UTREE)/doc/generic/$(NAME)
366 cp schematest.tex $(UTREE)/doc/generic/$(NAME)
367 cp README.md $(UTREE)/doc/generic/$(NAME)
368 endif
369
370 # Install the package release into the system tree.
371 # Note that this target depends on the "package" target,
372 # so we do not do a clean build. This may aid testing.
373
374 install : package
375 ifeq ($(strip $(LOCAL)),)
376 $(error "Unable to install; no path to local tree." )
377 else
378 sudo mkdir -p $(LOCAL)/{tex,source,doc}/generic/$(NAME)
379 sudo cp $(NAME).dtx $(LOCAL)/source/generic/$(NAME)
380 sudo cp $(NAME).eps $(LOCAL)/source/generic/$(NAME)
381 sudo cp Makefile $(LOCAL)/source/generic/$(NAME)
382 sudo cp $(NAME).sty $(LOCAL)/tex/generic/$(NAME)
383 sudo cp $(NAME).pdf $(LOCAL)/doc/generic/$(NAME)
384 sudo cp schematest.tex $(LOCAL)/doc/generic/$(NAME)
385 sudo cp README.md $(LOCAL)/doc/generic/$(NAME)
386 endif
387
388 # Uninstall the package release from the user's tree.
389 # Show the state of the texmf tree thereafter.
390
391 uninst :
392 ifeq ($(strip $(LOCAL)),)
393 $(error "Unable to uninstall; no path to user tree." )
394 else
395 rm -f $(UTREE)/source/generic/$(NAME)/$(NAME).dtx
396 rm -f $(UTREE)/source/generic/$(NAME)/Makefile
397 rm -f $(UTREE)/tex/source/$(NAME)/$(NAME).sty
398 rm -f $(UTREE)/doc/generic/$(NAME)/$(NAME).pdf
399 rm -f $(UTREE)/doc/generic/$(NAME)/*.tex
400 rm -f $(UTREE)/doc/generic/$(NAME)/README.md
401 rmdir $(UTREE)/{tex,source,doc}/generic/$(NAME)
402 @echo "The texmf tree now looks like:"
403 ls $(UTREE)/source/generic/
404 ls $(UTREE)/tex/generic/
405 ls $(UTREE)/doc/generic/
406 endif
407
408 # Uninstall the package release from the system tree.
409
410 uninstall :
411 ifeq ($(strip $(LOCAL)),)
412 $(error "Unable to uninstall; no path to local tree." )
413 else
414 sudo rm -f $(LOCAL)/source/generic/$(NAME)/$(NAME).dtx
415 sudo rm -f $(LOCAL)/source/generic/$(NAME)/Makefile
416 sudo rm -f $(LOCAL)/tex/generic/$(NAME)/$(NAME).sty
417 sudo rm -f $(LOCAL)/doc/generic/$(NAME)/$(NAME).pdf
418 sudo rm -f $(LOCAL)/doc/generic/$(NAME)/*.tex
419 sudo rm -f $(LOCAL)/doc/generic/$(NAME)/README.md
420 sudo rmdir $(LOCAL)/{tex,source,doc}/generic/$(NAME)
421 @echo "The texmf tree now looks like:"
422 ls $(LOCAL)/source/generic/
423 ls $(LOCAL)/tex/generic/
424 ls $(LOCAL)/doc/generic/
425 endif
426
427 # Create a zip file for upload to CTAN. On systems where ltxfileinfo
428 # cannot be found, we create a zip file without a version in its name
429 # instead of a zip file with a dash at the end, which can cause some
430 # problems on Windows in certain cases.
431
432 zip : release
433 rm -f $(NAME)*.zip
434 ln -sf . $(NAME)
435 zip -Drq $(PWD)/$(ZIPNAME).zip \
436 $(NAME)/{Makefile,README.md,\
437 schematest.tex,\
438 $(NAME).{dtx,pdf,eps,sty}}
439 rm $(NAME)
440 @echo "Zip file has been made successfully."
441