Debian Codegraph @

doc/tlbuild.texi

raw
1 \input texinfo
2 @setfilename tlbuild.info
3
4 @set version 2026
5 @set month-year January 2026
6
7 @set mytitle Building @TeX{} Live (@value{version})
8 @settitle @value{mytitle}
9
10 @macro TL
11 @TeX{}@tie{}Live
12 @end macro
13
14 @copying
15 This file documents the @TL{} build system and more.
16
17 @noindent
18 Copyright @copyright{} 2016--2026 Karl Berry.@*
19 Copyright @copyright{} 2013--2015 Karl Berry & Peter Breitenlohner.
20
21 Permission is granted to make and distribute verbatim copies of this
22 manual provided the copyright notice and this permission notice are
23 preserved on all copies.
24
25 @ignore
26 Permission is granted to process this file through TeX and print the
27 results, provided the printed document carries a copying permission
28 notice identical to this one except for the removal of this paragraph
29 (this paragraph not being relevant to the printed manual).
30 @end ignore
31
32 Permission is granted to copy and distribute modified versions of this
33 manual under the conditions for verbatim copying, provided that the
34 entire resulting derived work is distributed under the terms of a
35 permission notice identical to this one.
36
37 Permission is granted to copy and distribute translations of this manual
38 into another language, under the above conditions for modified versions,
39 except that this permission notice may be stated in a translation
40 approved by the @TeX{} Users Group.
41 @end copying
42
43 @c Put everything in one index (arbitrarily chosen to be the concept index).
44 @syncodeindex fn cp
45 @syncodeindex ky cp
46 @syncodeindex pg cp
47 @syncodeindex tp cp
48 @syncodeindex vr cp
49
50 @dircategory TeX
51 @direntry
52 * TLbuild: (tlbuild). TeX Live configuration and development.
53 @end direntry
54
55 @dircategory Individual utilities
56 @direntry
57 * install-tl:: Installing TeX Live.
58 * tlmgr:: Managing TeX Live.
59 @end direntry
60
61 @titlepage
62 @title @value{mytitle}
63 @subtitle @value{version} release
64 @subtitle @value{month-year}
65 @author Peter Breitenlohner
66 @author Karl Berry
67 @author @url{https://tug.org/texlive}
68
69 @page
70 @vskip 0pt plus 1filll
71 @insertcopying
72 @end titlepage
73
74 @shortcontents
75 @contents
76
77 @ifnottex
78 @node Top
79 @top @value{mytitle}
80
81 For an overview of this manual, @pxref{Introduction}.
82
83 @menu
84 * Introduction:: About this manual.
85 * Overview of build system:: The @TL{} build system.
86 * Prerequisites:: Requirements for building @TL{}.
87 * Building:: The overall build process.
88 * Installing:: How and where installation happens (or not).
89 * Layout and infrastructure:: Autoconf macros, etc., in detail.
90 * Configure options:: List of all configure options.
91 * Coding conventions:: Conventions to follow.
92 * Continuous integration:: Automated build testing.
93 * install-tl:: The @TL{} installer.
94 * tlmgr:: The native @TL{} package manager.
95 * Index:: General index.
96 @end menu
97 @end ifnottex
98
99 @node Introduction
100 @chapter Introduction
101
102 @cindex introduction
103
104 This manual (dated @value{month-year}) corresponds to the @TL{}
105 @value{version} release.
106
107 This manual is aimed at system installers and programmers, and focuses
108 on how to configure, build, and develop the @TL{} (TL) sources. It is
109 also available as plain text files in the source tree:
110 @file{source/README.*}.
111
112 The main @file{source/README} file in the TL source tree provides
113 maximally-terse information for doing a build, and portability
114 information for different systems, along with
115 @file{source/doc/README.solaris}.
116
117 For information on acquiring the TL sources, see
118 @url{https://tug.org/texlive/svn}. The canonical source repository
119 uses Subversion, and we have no plans to change this.
120
121 This manual does not duplicate the information found in other TL
122 documentation resources, such as:
123
124 @itemize
125 @item The @TL{} web pages: @url{https://tug.org/texlive}.
126
127 @item The web page describing how to build the binaries which
128 are distributed with @TL{}: @url{https://tug.org/texlive/build.html}.
129
130 @item The @TL{} user manual: @url{https://tug.org/texlive/doc.html}, or
131 run @code{texdoc texlive}.
132
133 @item Other @TeX{}-related Texinfo manuals (@pxref{,,,web2c, Web2c},
134 @ref{,,,kpathsea, Kpathsea}, etc.):
135 @url{https://tug.org/texinfohtml/}, or check the @samp{TeX} category in
136 the GNU Info system.
137
138 @item Package documentation:
139 @url{https://tug.org/texlive/Contents/live/doc.html}, or the
140 @file{doc.html} file at the top level of the installed TL.
141
142 @end itemize
143
144 As an exception, the full documentation for @code{install-tl} and
145 @code{tlmgr} is included here as appendices, simply because it is easy
146 to do so. The same text is available online (linked from
147 @url{https://tug.org/texlive/doc.html}, or by invoking the program
148 with @samp{--help} (or look at the end of the source).
149
150 @c The first word of the chapter/section title here is used to
151 @c construct the README.* filenames, so choose well. (Or hack the script.)
152
153 @node Overview of build system
154 @chapter Overview of build system
155
156 @cindex build system, design of
157
158 @cindex Autoconf
159 @cindex Automake
160 @cindex Libtool
161 @cindex tests, running
162 The @TL{} build system was redesigned in 2009 to consistently use
163 Autoconf, Automake, and Libtool. Thus, running@*@ @ @ @code{configure
164 && make && make check && make install}@*or the essentially-equivalent
165 top-level @code{Build} script suffices to build and install the TL
166 programs. The @code{make check} clause performs various tests of the
167 generated programs---not strictly required but strongly recommended.
168 Running @code{configure --help} will display a comprehensive list of
169 all @code{configure} options.
170
171 The main components of the TL build system are:
172
173 @table @file
174 @item libs/@var{lib}
175 Generic libraries.
176
177 @item texk/@var{lib}
178 @TeX{}-specific libraries in subdirectories, notably
179 @var{lib}=@code{kpathsea}. (The other one is @file{texk/ptexenc}.)
180
181 @item texk/@var{prog}
182 @TeX{}-specific programs (that use Kpathsea).
183
184 @item utils/@var{prog}
185 Other programs (that don't use Kpathsea).
186
187 @end table
188
189 @pindex kpse-pkgs.m4
190 The primary design goal of the build system is modularity. Each
191 program and library module (or package) specifies its own requirements
192 and properties, such as required libraries, whether an installed
193 (system) version of a library can be used, @code{configure} options to
194 be seen at the top level, and more. An explicit list of all available
195 modules is kept in a single central place: @file{m4/kpse-pkgs.m4}.
196
197 A second, related goal is to configure and build each library before
198 configuring any other (program or library) module which uses that
199 library. This allows checking for properties and features of a
200 library built as part of the TL tree in much the same way as for a
201 system version of that library.
202
203 All generic libraries and several programs are maintained
204 independently. The corresponding modules use (most of) the
205 distributed source tree and document any modifications of that source.
206
207 All this is for the sake of simplifying both upgrading of modules and
208 integrating new modules into the TL build system. (Despite all
209 efforts, neither task is easy.)
210
211 @node Prerequisites
212 @chapter Prerequisites
213
214 @cindex prerequisites for building
215 @cindex requirements for building
216
217 @cindex compilers, C and C++11
218 Overall, building the @TL{} programs, when using all libraries from
219 the TL source tree, requires C and C++11 compilers, GNU @code{make},
220 and Python.
221
222 @itemize
223 @item
224 If @code{make} from your @code{PATH} is not GNU @code{make}, you can
225 set the @code{MAKE} environment variable to whatever is necessary.
226
227 @cindex GNU @code{make}, required
228 @cindex @code{gmake}, required
229 @cindex FreeType, requires @code{gmake}
230 @cindex @code{$@@} target in normal @code{make} rules
231 GNU @code{make} is required only because of third-party libraries,
232 notably FreeType. Automake/Autoconf output in general, and the
233 TL-maintained directories, work with any reasonable
234 @code{make}.@footnote{There is one exception in TL: the
235 @code{tangle-sh} and related rules use @code{$@@} to mean the target
236 name, a feature not present in all @code{make}s. This could be
237 alleviated by laborious editing, but since there's no way to avoid GNU
238 @code{make} for builds of the entire tree, it does not seem worth the
239 trouble.}
240
241 @item
242 @cindex C++11, required
243 @cindex @code{dvisvgm}, requires C++11
244 @cindex HarfBuzz, requires C++11
245 @cindex ICU, requires C++11
246 A C++11 compiler is similarly required because of the third-party
247 libraries ICU and HarfBuzz (at least); the program @code{dvisvgm} also
248 requires C++11. It is possible to build what remains with older
249 compilers, but you have to remove the C++11-dependent sources.
250 @xref{Build one package}.
251
252 @item
253 @cindex Python, required by ICU
254 Python is required by ICU tests. (If you know how to disable these
255 tests and thus eliminate the requirement, please write.)
256
257 @end itemize
258
259 A few programs in the tree have additional requirements:
260
261 @table @file
262 @item web2c
263 @cindex @code{perl}, required by @code{web2c}, etc.
264 requires @code{perl} for some tests run by @code{make check}.
265 Incidentally, the @TeX{} Live installer (@code{install-tl}) and
266 manager (@code{tlmgr}) are also written in Perl, but this does not
267 matter for compiling the sources.
268
269 @item xdvik
270 @itemx xpdfopen
271 @cindex X11 development, required by X clients
272 require X11 headers and libraries, typically in devel(opment) packages
273 that are not installed by default.
274
275 @item xetex
276 @cindex @code{fontconfig} library, required by @code{xetex}
277 @cindex @code{ApplicationServices} Mac framework, required by @code{xetex}
278 @cindex @code{Cocoa} Mac framework, required by @code{xetex}
279 requires @file{fontconfig} (again both headers and library), or, for
280 MacOS only, the @code{ApplicationServices} and @code{Cocoa}
281 frameworks.
282
283 @item xindy
284 @cindex @code{clisp}, required by @code{xindy}
285 @cindex @code{libsigsegv}, required by @code{xindy}
286 requires GNU @code{clisp}, @code{libsigsegv}, and @code{libiconv};
287 additionally, to build the rules and/or documentation: @code{perl},
288 @code{latex}, @code{pdflatex}.
289
290 @end table
291
292 @noindent Lacking the required tools, building these
293 programs must avoided, e.g.,@*
294 @code{configure --without-x --disable-xetex --disable-xindy}
295
296 Modifying source files induces more requirements, as one might expect:
297
298 @itemize
299 @item
300 Modification of any @code{.y} or @code{.l} source files requires
301 @file{bison} or @file{flex} to update the corresponding C sources.
302
303 @item
304 Modification of the sources for @code{.info} files requires
305 @code{makeinfo}.
306
307 @item
308 Modification of any part of the build system (M4 macros,
309 @file{configure.ac}, @file{Makefile.am}, or their fragments) requires
310 GNU M4, GNU Autoconf, GNU Automake, and GNU Libtool to update the
311 generated files. Furthermore, to reliably reproduce the build files,
312 the latest original GNU releases of these tools must be used, not any
313 distro packaging of them. @xref{Build system tools}, for more
314 discussion.
315
316 @end itemize
317
318 If you haven't modified any source files, and infrastructure tools
319 such as @code{autoconf} or @code{makeinfo} are still being run, check
320 your timestamps---notably, @code{use-commit-times} must be set to
321 @code{yes} in your Subversion configuration (@pxref{Build system
322 tools}). No infrastructure tools are needed to do a normal build
323 (barring bugs).
324
325 @node Building
326 @chapter Building
327
328 @cindex building
329 @cindex overall build process
330
331 @pindex Build @r{script}
332 The top-level @file{Build} script is intended to simplify building the
333 binaries distributed with @TL{} itself---we call this the ``native''
334 TL build. It runs @code{configure && make world}, which builds
335 everything in a subdirectory of the main source tree (default
336 @file{Work/}), installs everything in another subdirectory (default
337 @file{inst/}), and finally runs @code{make check}. The exact
338 directory and command names can be specified via environment variables
339 and a few leading options. All remaining arguments (assignments or
340 options) are passed to the @file{configure} script. Please take a
341 look at the @file{./Build} source file for more information; it is a
342 straightforward shell script.
343
344 @cindex source directory building, not supported
345 @cindex build directory, required
346 An alternative, and the one we will mainly discuss here, is to run
347 @code{configure} and @code{make} in a suitable empty subdirectory.
348 Building in the source directory itself is not supported (sorry).
349
350 @menu
351 * Build iteration:: What @code{configure} and @code{make} do in TL.
352 * Build in parallel:: Simultaneous @code{make} processes.
353 * Build distribution:: (Not) making a distribution tarball.
354 * Build one package:: Example of working on just one program.
355 * Build one engine:: Example of building just one @TeX{} engine.
356 * Cross compilation:: Building on host X for target Y.
357 @end menu
358
359 @node Build iteration
360 @section Build iteration
361
362 @cindex build iteration
363 @cindex iteration through sources, by @code{configure} and @code{make}
364
365 Running the top-level @file{configure} script configures the top level
366 and the subdirectories @file{libs}, @file{utils}, and @file{texk}.
367 Running @code{make} at the top level first iterates over the
368 @TeX{}-specific libraries, and then runs @code{make} in @file{libs},
369 @file{utils}, and @file{texk} to iterate over the generic libraries,
370 utility programs, and @TeX{}-specific programs, respectively. These
371 iterations consist of two steps:
372
373 @enumerate
374 @item
375 For each library or program module not yet configured, run
376 @code{configure}, adding the configure option @code{--disable-build}
377 if the module need not be built, otherwise running @code{make all}.
378
379 @item
380 For each library or program module that must be built, run
381 @code{make} for the selected target(s): @code{default} or
382 @code{all} to (re-)build, @code{check} to run tests, @code{install},
383 etc.
384
385 @end enumerate
386
387 Running the top-level @code{make} a second time iterates again over
388 all the library and program modules, and finds (should find) nothing
389 to be done.
390
391 @node Build in parallel
392 @section Build in parallel
393
394 @cindex building in parallel
395 @cindex parallel build
396 @cindex cache for @code{configure}
397
398 @cindex dependencies, with several output files
399 @vindex -j make @r{option}
400 The TL build system carefully formulates dependencies as well as
401 @code{make} rules when a tool (such as @code{tangle}, @code{ctangle},
402 and @code{convert}) creates several output files. This allows for
403 parallel builds (@code{make -j @var{n}} with @math{@var{n}>1} or even
404 @code{make -j}) that can considerably speed up the TL build.
405
406 @vindex TL_MAKE_FLAGS
407 If you're using TL's @code{Build} script, you can enable @code{-j}
408 with the environment variable @code{TL_MAKE_FLAGS}, as in:
409 @samp{env TL_MAKE_FLAGS=-j`nproc` ./Build}.
410
411 @cindex cache file, for @code{configure}
412 @vindex -C configure @r{option}
413 Independently, a noticeable speed-up can also be gained by using a
414 configure cache file, i.e., specifying the @code{configure} option
415 @code{-C} (recommended).
416
417 @node Build distribution
418 @section Build distribution
419
420 @cindex building a distribution
421 @cindex distribution tarball, making
422
423 @cindex @code{dist} and @code{distcheck} targets for @code{make}
424 Running @code{make dist} or related targets at the top level outputs an
425 error message and fails. We no longer try to keep @code{make dist}
426 working, although it could be restored if there is some use for it.
427
428 The @code{dist} target used to create a tarball
429 @file{tex-live-@var{yyyy}-@var{mm}-@var{dd}.tar.xz} from the TL source
430 tree, and @code{distcheck} also verifies that this tarball suffices to
431 build and install all of TL.
432
433 However, the result was not a complete or even usable @TeX{} system,
434 since all the support files are lacking. We do not actually
435 distribute any such tarball, and have no plans to do so.
436
437 @xref{Installing}, for more information on what to do with the results
438 of a build.
439
440 @node Build one package
441 @section Build one package
442
443 @cindex build one package
444 @cindex one package, building
445
446 @vindex --disable-all-packages
447 @cindex build on demand
448 To build one package, the basic idea is to use the @code{configure}
449 option @code{--disable-all-pkgs} (@pxref{@code{--disable-all-pkgs}}).
450 Then all program and library modules are configured but none are made.
451 However, the @file{Makefile}s still contain all build rules and
452 dependencies and can be invoked to build an individual program or
453 library, first building any required libraries.
454
455 Here is an example from start to finish for working on
456 @code{dvipdfm-x}. Unfortunately, this does not suffice for building
457 the @TeX{} engines; see the next section.
458
459 @example
460 mkdir mydir && cd mydir # new working directory
461
462 # Get sources (@url{https://tug.org/texlive/svn}), e.g.:
463 rsync -a --delete --exclude=.svn --exclude=Work \
464 tug.org::tldevsrc/Build/source/ .
465
466 # Create build directory:
467 mkdir Work && cd Work
468
469 # Do the configure:
470 ../configure --disable-all-pkgs --enable-dvipdfm-x \
471 -C CFLAGS=-g CXXFLAGS=-g >&outc || echo fail
472
473 # Do the make:
474 make >&outm || echo fail
475
476 # Run the tests:
477 cd texk/dvipdfm-x
478 make check
479
480 # Run the new binary in the build tree, finding support files
481 # in a separate tree for a TeX Live release YYYY
482 # (Bourne shell syntax):
483 TEXMFROOT=/usr/local/texlive/YYYY \
484 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c \
485 ./xdvipdfmx ...
486 @end example
487
488 @vindex TEXMFROOT @r{for running standalone}
489 @vindex TEXMFCNF @r{for running standalone}
490
491 Then you can modify source files in @file{mydir/texk/dvipdfm-x} and
492 rerun @code{make} in @file{mydir/Work/texk/dvipdfm-x} to rebuild; that
493 build directory is where the binary ends up and where you can run a
494 debugger, etc.
495
496 The second line of the @code{configure} invocation shows examples of
497 extra things you likely want to specify if you intend to hack the
498 sources (and not just build binaries): the @code{-C} speeds
499 @code{configure} by enabling a cache file, and the @code{CFLAGS} and
500 @code{CXXFLAGS} settings eliminate compiler optimization for debugging
501 purposes.
502
503 Of course, you need to actually look at the output and check that
504 things are working. There are many @code{configure} options you can
505 tweak as desired; check the output from @code{configure --help}. It
506 is also a good idea to run @code{make check} after making any changes,
507 to ensure that whatever tests have been written still pass.
508
509 @subsubheading Reducing source download size
510
511 @cindex size of source tree
512 The above retrieves the entire TL source tree (several
513 hundred megabytes). It is natural to ask if this is really necessary.
514 Strictly speaking, the answer is no, but it is vastly more convenient
515 to do so. If you cut down the source tree, you must also give
516 additional @code{configure} flags to individually disable using system
517 versions of libraries, or the intricacies of the dependencies (such as
518 @code{teckit} requiring @code{zlib}) will have undesired side effects.
519 For an example of this approach, see the @code{build-pdftex.sh} script
520 in the @code{pdftex} development source (details at
521 @url{http://pdftex.org}), which is indeed such a cut-down TL source
522 tree.
523
524 @subsubheading GCC used by default
525
526 @vindex CC=@var{c-compiler}
527 @vindex CXX=@var{c++-compiler}
528 @vindex OBJCXX=@var{objc-compiler}
529 @pindex gcc@r{, default compilers}
530 By default, the @code{gcc} compilers will be used if present;
531 otherwise, individual packages may use something different. You can
532 explicitly specify the compilers to be used with the environment
533 variables @code{CC}, @code{CXX}, and @code{OBJCXX}.
534
535 @subsubheading Removing C+11 dependency
536
537 @cindex C++11, removing dependent sources
538 Some libraries and programs require C++11; one such is XeTeX. If you
539 want to build with an older compiler lacking such support, you need to
540 (re)move those source directories; unfortunately, specifying
541 @code{--disable} for them does not suffice. It's also necessary to
542 specify @code{--disable-xetex} explicitly. Specifically, before
543 running @code{configure --disable-xetex ...}:
544
545 @example
546 rm -rf libs/icu libs/graphite2 texk/dvisvgm texk/web2c/xetexdir
547 @end example
548
549 @vindex --enable-missing @r{to ignore dependencies}
550 Also, even with @code{--disable-all-pkgs}, dependencies are (currently)
551 checked. One notable case: if a (non-MacOS) system does not have
552 @code{fontconfig}, Xe@TeX{} cannot be built (@pxref{Prerequisites}),
553 and @code{configure} will terminate even with @code{--disable-xetex}.
554 To proceed without such dependencies, specify @code{--enable-missing}
555 also.
556
557 As of 2022, HarfBuzz also requires C++11. Therefore even more would
558 have to be disabled and removed, notably including @code{luahbtex},
559 the standard engine used for Lua@LaTeX{}. Removing that would not
560 be acceptable for builds intended for distribution; but perhaps for
561 testing the above information could still be useful.
562
563 @cindex removing build directories
564 @cindex @code{configure} problems, work around by removing
565 In general, the TL @code{configure} will run in all directories.
566 Therefore a general workaround for build problems is to remove failing
567 directories from the tree, and also specify the relevant
568 @code{--disable-...} option(s).
569
570 Patches to improve all this would be most welcome.
571
572 @node Build one engine
573 @section Build one engine
574
575 @cindex build one engine
576 @cindex one engine, building
577 @cindex engine, building one
578
579 Unfortunately, there is one common case where the steps in the
580 preceding section to build one package (@pxref{Build one package}) do
581 not suffice: wanting to build one, or a subset, of the @TeX{} engines
582 (or other Web2c programs).
583
584 The simplest way to do this is to disable everything and then
585 explicitly specify what to make. For example, to build only the
586 original @TeX{}:
587
588 @example
589 cd Work # top build directory
590 ../configure --without-x --disable-shared --disable-all-pkgs \
591 --enable-tex --disable-synctex --disable-xetex \
592 --enable-missing -C CFLAGS=-g CXXFLAGS=-g
593 make
594 cd texk/web2c # cd engine build directory
595 make tex # must specify target
596 @end example
597
598 The first @code{make} run will configure everything, and even build
599 the libraries, even though the packages are disabled.
600
601 The source tree can be cut down to just what is needed for the given
602 engine (the separate pdf@TeX{} and Lua@TeX{} source repositories do
603 this, for example), but see caveats in previous section. When the
604 @code{--disable-xetex} and @code{--enable-missing} options are needed
605 is also explained in the previous section.
606
607 If you want to debug an X-related program or shared library setup, or
608 other variants, change the @code{configure} options
609 accordingly. Either @code{../Build} or @code{../configure} can be run.
610
611 Then it is necessary to again specify the target engine (@code{tex},
612 in the above) in the @code{make}.
613
614 All these complications are rather unfortunate. Patches are welcome.
615
616 @subsubheading Testing one engine
617
618 To run only the tests for a given engine, say @code{hitex}:
619
620 @example
621 make -C $ww check SUBDIRS=. TESTS='$(hitex_tests)'
622 @end example
623
624 @noindent where @code{$ww} is the web2c build directory, that is,
625 @file{ww=/.../Build/source/Work/texk/web2c}.
626
627 It's also possible to run individual tests the same way, using the test
628 name exactly as specified in the @file{.am} file:
629
630 @example
631 make -C $ww check SUBDIRS=. TESTS=hitexdir/tests/hello.test
632 @end example
633
634 Without the @code{SUBDIRS=.}, errors like this will show up, since
635 @code{make} will descend into every directory.
636
637 @example
638 fatal: making test-suite.log: failed to create hitexdir/tests/hello.test
639 @end example
640
641 @vindex --no-print-directory @r{GNU make option}
642 If you get tired of looking at the @samp{Entering}/@samp{Leaving
643 directory} lines, you can add the (GNU) make option
644 @code{--no-print-dir}.
645
646 You may find it useful to put lengthy incantations like this into a
647 trivial shell script with a short name (say, @code{hitch}). Then you
648 just run @code{hitch} and edit the file when necessary to change
649 the options.
650
651 @node Cross compilation
652 @section Cross compilation
653
654 @cindex cross compilation
655 In a cross compilation a @dfn{build} system is used to create
656 binaries to be executed on a @dfn{host} system with different
657 hardware and/or operating system.
658
659 @cindex native cross compilation
660 In simple cases, the build system can execute binaries for the host
661 system. This typically occurs for bi-arch systems where, e.g.,
662 @code{i386-linux} binaries can run on @code{x86_64-linux} systems and
663 @code{win32} binaries can run on @code{win64} systems. Although
664 sometimes called ``native cross'', technically this is not cross
665 compilation at all. In most such cases it suffices to specify
666 suitable compiler flags. It might be useful to add the configure
667 option @code{--build=@var{host}} to get the correct canonical host
668 name, but note that this should @emph{not} be @code{--host=@var{host}}
669 (@pxref{Hosts and Cross-Compilation,,, autoconf, GNU Autoconf}).
670
671 In order to build, e.g., 32-bit binaries with @command{clang} on a 64-bit
672 MacOS system one could use:
673
674 @example
675 TL_BUILD_ENV="CC='clang -arch i386' \
676 CXX='clang++ -arch i386' \
677 OBJCXX='clang++ -arch i386'" \
678 ./Build --build=i386-apple-darwin
679 @end example
680
681 @menu
682 * Cross configuring:: Configuring for cross compilation.
683 * Cross problems:: Cross compilation problems.
684 @end menu
685
686 @node Cross configuring
687 @subsection Cross configuring
688
689 @cindex cross compilation configuring
690 @cindex configuring, for cross compilation
691
692 @vindex --host=@var{host}
693 @vindex --build=@var{host}
694 In a standard cross compilation, binaries for the host system cannot
695 execute on the build system and it is necessary to specify the
696 configure options @code{--host=@var{host}} and
697 @code{--build=@var{build}} with two different values.
698
699 Building binaries requires suitable ``cross'' tools, e.g., compiler,
700 linker, and archiver, and perhaps a ``cross'' version of
701 @code{pkg-config} and similar to locate host system libraries.
702 Autoconf expects that these cross tools are given by their usual
703 variables or found under their usual name prefixed with
704 @code{@var{host}-}. Here a list of such tools and corresponding
705 variables:
706
707 @example
708 @code{ar} AR
709 @code{freetype-config} FT2_CONFIG
710 @code{g++} CXX
711 @code{gcc} CC
712 @code{icu-config} ICU_CONFIG
713 @code{objdump} OBJDUMP
714 @code{pkg-config} PKG_CONFIG
715 @code{ranlib} RANLIB
716 @code{strip} STRIP
717 @end example
718
719 @cindex @code{mingw32}
720 @noindent In order to, e.g., build @code{mingw32} binaries on
721 @code{x86_64-linux} with a cross compiler found as
722 @file{i386-pc-mingw32-gcc} one would specify
723
724 @example
725 --host=i386-pc-mingw32 --build=x86_64-linux-gnu
726 @end example
727
728 @noindent or perhaps
729
730 @example
731 --host=mingw32 --build=x86_64-linux CC=i386-pc-mingw32-gcc
732 @end example
733
734 @noindent but this latter, especially, might require adding @code{CXX} and others.
735
736 Configure arguments such as @code{CFLAGS=@dots{}} refer to the cross
737 compiler. If necessary, you can specify compilers and flags for the
738 few auxiliary C and C++ programs required for the build process as
739 configure arguments
740
741 @vindex BUILDCC@r{,} BUILDCFLAGS@r{, @dots{}}
742 @example
743 BUILDCC=@dots{}
744 BUILDCPPFLAGS=@dots{}
745 BUILDCFLAGS=@dots{}
746 BUILDCXX=@dots{}
747 BUILDCXXFLAGS=@dots{}
748 BUILDLDFLAGS=@dots{}
749 @end example
750
751 @node Cross problems
752 @subsection Cross problems
753
754 @cindex cross compilation problems
755
756 The fact that binaries for the host system cannot be executed on the
757 build system causes some problems.
758
759 One problem is that configure tests using @code{AC_RUN_IFELSE} can
760 compile and link the test program but cannot execute it. Such tests
761 should be avoided if possible and otherwise must supply a pessimistic
762 test result.
763
764 @pindex squeeze
765 @pindex web2c @r{program}
766 @cindex @code{freetype} cross compiling
767 @vindex CC_BUILD
768 Another problem arises if the build process must execute some
769 (auxiliary or installable) programs. Auxiliary programs can be placed
770 into a subdirectory that is configured natively as is done for
771 @file{texk/web2c/web2c}, @file{texk/dvipsk/squeeze}, and
772 @file{texk/xdvik/squeeze}. The module @file{libs/freetype2} uses the
773 value of @code{CC_BUILD}, @file{@var{build}-gcc}, @file{gcc}, or
774 @file{cc} as the compiler for the auxiliary program.
775
776 @cindex ICU cross compiling
777 The situation for installable programs needed by the build process is
778 somewhat different. A rather expensive possibility, chosen for the ICU
779 libraries in module @file{libs/icu}, is to first compile natively for
780 the build system and in a second step to use these (uninstalled)
781 programs during the cross compilation.
782
783 @pindex tangle
784 @pindex ctangle
785 @pindex otangle
786 @pindex tie
787 This approach would also be possible for the tools such as
788 @file{tangle} used in the module @file{texk/web2c} to build the WEB
789 programs, but that would require first building a native
790 @code{kpathsea} library. To avoid this complication, cross
791 compilation of programs written in (C)WEB requires sufficiently recent
792 installed versions of @file{tangle}, @file{ctangle}, @file{otangle},
793 and @file{tie}.
794
795 @cindex @code{xindy} cross compiling requires @code{clisp}
796 Building @code{xindy} requires running the host system @code{clisp}
797 binary, thus cross compilation is painful, but possible.
798
799 @node Installing
800 @chapter Installing
801
802 @cindex installing
803 This section discusses the results of @code{make install} in the
804 source tree.
805
806 @cindex support files, separate from build
807 @pindex texlive.tlpdb@r{, @TL{} database}
808 @pindex install-tl@r{, @TL{} installer}
809 @pindex plain.tex@r{, not in source tree}
810 The main consideration is that @code{make install} is nothing like
811 enough to make a usable @TeX{} installation. It creates the compiled
812 binaries, but (thousands of) support files are also needed; just as a
813 first example, @file{plain.tex} is not installed. All the support
814 files are maintained completely independently and are not present in
815 the TL @file{Build/source} tree of sources to be compiled.
816
817 Thus, perhaps the simplest way to get a running @TeX{} system after
818 building new binaries from these sources is to do a normal
819 installation of @TeX{} Live, and then use the new binaries as a
820 so-called ``custom'' platform
821 (@url{https://tug.org/texlive/custom-bin.html}).
822
823 Alternatively, the best general basis for dealing with them, for
824 example if you're trying to figure out how to support @TeX{} in a
825 general distro, is the @TL{} (plain text) database in
826 @file{Master/tlpkg/texlive.tlpdb}, and/or the @TL{} installer,
827 @code{install-tl}.
828
829 More information is under @file{Master/tlpkg} and at
830 @url{https://tug.org/texlive/distro.html} and
831 @url{https://tug.org/texlive/build.html#deploy}.
832
833 @menu
834 * Installation directories:: The prefix, @code{bindir}, etc., directories.
835 * Linked scripts:: Scripts not maintained in the sources.
836 * Distro builds:: Configuring and building for OS distributions.
837 @end menu
838
839 @node Installation directories
840 @section Installation directories
841
842 @cindex installation directories
843 @cindex directories, for installation
844 @cindex paths, for installation
845
846 Running @code{make install} (or @code{make install-strip}) installs
847 executables in @code{@var{bindir}}, libraries in @code{@var{libdir}},
848 headers in @code{@var{includedir}}, general data (including ``linked
849 scripts'', @pxref{Linked scripts}) in
850 @code{@var{datarootdir}/texmf-dist}, man pages in @code{@var{mandir}},
851 and Info files in @code{@var{infodir}}.
852
853 The values of these directories are determined by @code{configure}
854 and can be specified explicitly as options such as
855 @code{--prefix=@var{prefix}} or @code{--bindir=@var{bindir}};
856 otherwise, they are given by their usual Autoconf defaults:
857
858 @example
859 @var{prefix} /usr/local
860 @var{exec_prefix} @var{prefix}
861 @var{bindir} @var{exec_prefix}/bin
862 @var{libdir} @var{exec_prefix}/lib
863 @var{includedir} @var{prefix}/include
864 @var{datarootdir} @var{prefix}/share
865 @var{mandir} @var{datarootdir}/man
866 @var{infodir} @var{datarootdir}/info
867 @end example
868
869 @noindent except possibly modified as follows:
870
871 @itemize @bullet
872 @item
873 If the option @code{--enable-multiplatform} is given,
874 @code{/@var{platform}} (i.e., the canonical platform name) is appended
875 to @code{@var{bindir}} and @code{@var{libdir}}. This is implied for a
876 native TL build.
877
878 @item
879 @raggedright
880 In a native TL build, @code{@var{datarootdir}} is set to
881 @code{@var{prefix}}, @code{@var{infodir}} is set to
882 @code{@var{prefix}/texmf-dist/doc/info}, and @code{@var{mandir}} to
883 @code{@var{prefix}/texmf-dist/doc/man}, corresponding to the
884 directories used in the TL distribution.
885 @end raggedright
886
887 @end itemize
888
889 @noindent The top-level @file{configure} script displays all these
890 installation paths.
891
892 For the native TL build, the @code{Build} script leaves the binaries
893 in @file{./inst/bin/@var{std-system-triplet}}. The new binaries are
894 not directly usable from that location; they need to be copied to
895 @file{Master/bin/@var{tl-platform}}. The other files and directories
896 that end up in @file{./inst/} are ignored.
897
898 @node Linked scripts
899 @section Linked scripts
900
901 @cindex linked scripts
902 @cindex scripts, linked and not maintained
903 @cindex symbolic links, used for scripts
904
905 @cindex symlinks, used for scripts
906 @cindex wrapper binary for scripts on Windows
907 @cindex Windows, invoking scripts on
908 Quite a few of the executables in @TL{} are architecture-independent
909 shell, Perl, or other interpreted scripts, rather than compiled
910 binaries. A few are maintained as part of the TL source tree, but
911 most are maintained independently in their own packages, with copies
912 under @file{texk/texlive/linked_scripts}.
913
914 These so-called @dfn{linked scripts} are installed under
915 @code{@var{datarootdir}/texmf-dist/scripts}; for Unix-like systems a
916 symbolic link is made in @code{@var{bindir}}. For example, a symlink
917 points from @code{@var{bindir}/fmtutil} to
918 @code{@var{datarootdir}/texmf-dist/scripts/texlive/fmtutil.pl}. The
919 symlink is relative, so the installation root can be anywhere.
920
921 @cindex wrapper for scripts, on Windows
922 For Windows, we cannot portably use symlinks, so a standard wrapper
923 binary (copied to, e.g., @code{@var{bindir}/fmtutil.exe}) serves the
924 same purpose (the source for the wrapper is in
925 @file{texk/texlive/windows_wrapper}).
926
927 One reason for all this is to avoid having many copies of the same
928 script; a more important reason is that it guarantees the scripts will
929 stay in sync across the different supported operating systems.
930
931 @pindex asymptote
932 @pindex biber
933 @pindex xindy
934 @pindex xz
935 @pindex wget
936 Most important of all, we want the @code{@var{bindir}} resulting from
937 @code{make install} in the TL source tree to be as close as possible
938 to what's in thej TL distribution. At present, there are a few
939 exceptions---Asymptote, Biber, Xindy---and each one creates
940 considerable extra work. We don't want to add more. (See
941 @url{https://tug.org/texlive/build.html} for information about
942 building those exceptions, as well as the @code{xz} and @code{wget}
943 programs that are used in the TL infrastructure.)
944
945 @pindex scripts-targets.lst
946 As part of the @code{make install} in the @file{linked_scripts}
947 directory, a file @file{scripts-targets.lst} is created to record all
948 the links that are created this way, so that distros and others can
949 reproduce them. The file has one line per link. The first word is the
950 target of the link (e.g.,
951 @samp{texmf-dist/scripts/texlive/fmtutil.pl}), and the second word
952 is the name of the link to be placed in the bindir (e.g.,
953 @samp{fmtutil}). Determining the relative link target (how many
954 @samp{../}s) is left to the users of this file, since it varies among
955 distributions. It can be assumed there is no whitespace in these filenames.
956
957 A few links are within bindir; in that case, the first word of the
958 line is just a base name, e.g., the file @samp{fmtutil mktexfmt} means
959 that doing the equivalent of @code{ln -s fmtutil mktexfmt} in the bindir.
960
961 Be aware that although extensions are usually stripped (as with
962 @code{fmtutil}), there are exceptions, such as
963 @code{memoize-extract.pl} and @code{listings-ext.sh}.
964
965 The @file{scripts-targets.lst} file started being created as of the
966 @TL{} 2025 release. Historically, another file @file{scripts.lst} has
967 been (and still is) created, containing only the link targets, and
968 using a Bourne shell syntax.
969
970 @node Distro builds
971 @section Distro builds
972
973 @cindex distro, building for
974 @cindex operating system distribution, building for
975 @cindex system distribution, building for
976
977 @cindex GNU/Linux distro
978 @cindex BSD distro
979 Although they use the same code base, building for the native TL
980 distribution as shipped by the @TeX{} user groups is typically quite
981 different from a ``distro'' build needed by, e.g., a full GNU/Linux or
982 BSD operating system distribution.
983
984 @cindex shared libraries, using vs.@: avoiding
985 The native TL distribution uses shared libraries only when absolutely
986 necessary (@file{libc}, @file{libm}, X11 libraries, and
987 @file{libfontconfig}). In contrast, a distro typically wants to use
988 as many shared libraries as possible from elsewhere on the system,
989 including @TeX{}-specific libraries such as @file{libkpathsea} (even
990 though Kpathsea has never officially been released as a shared
991 library). In addition, the installation paths will, in general, be
992 completely different.
993
994 Here are the @code{configure} options that distro builds are likely to
995 find most relevant:
996
997 @table @code
998 @item --disable-native-texlive-build
999 This must be specified to avoid interference from the many tweaks we
1000 do for the native TL build.
1001
1002 @item --with-banner-add=/@var{SomeDistro}
1003 This isn't technically required, but is strongly recommended, so your
1004 build and your distro can be distinguished from others.
1005
1006 @item --enable-shared
1007 Build shared versions of the @TeX{}-specific libraries (uses
1008 @code{libtool}).
1009
1010 @item --disable-static
1011 Do not build the static versions of the @TeX{}-specific libraries.
1012
1013 @item --with-system-@var{lib}
1014 Look for and use a system version of the library @var{lib}.
1015 @code{configure --help} will give you the list of possibilities.
1016
1017 @item --with-@var{lib}-includes=@var{dir}
1018 @itemx --with-@var{lib}-libdir=@var{dir}
1019 If needed, allows you to specify where the headers/code are for the
1020 given library @var{lib}.
1021
1022 @item --prefix=/usr
1023 @itemx --prefix=/opt/TeXLive
1024 Or whatever your convention is. The default is @file{/usr/local} and
1025 you shouldn't install there for a distro.
1026
1027 @item --libdir=\$@{exec_prefix@}/lib64
1028 May be needed for 64-bit bi-architecture (GNU/Linux) systems.
1029
1030 @end table
1031
1032 @cindex Preining, Norbert
1033 @cindex adapting @TL{} for distros
1034 You will need to take care of the support files mentioned above
1035 (@pxref{Installing}), and many other issues, such as font maps,
1036 languages, and formats, independently of the build. Norbert Preining
1037 has written a detailed article on adapting TL for distros:
1038 @url{https://tug.org/TUGboat/tb34-3/tb108preining-distro.pdf}. (If the
1039 article needs updating in the future, perhaps we will merge it into
1040 this document.)
1041
1042 @node Layout and infrastructure
1043 @chapter Layout and infrastructure
1044
1045 @cindex layout of sources
1046 @cindex source tree
1047
1048 The @TL{} source tree is the subtree rooted at @file{Build/source} of
1049 the complete TL distribution and contains the sources for all executables
1050 distributed by TL, as well as @code{configure} scripts and @code{make}
1051 rules to build and install them together with some of their support
1052 files.
1053
1054 @menu
1055 * Build system tools:: Modifying infrastructure files.
1056 * Top-level directories:: libs texk utils; am auxdir build-aux m4; doc extra.
1057 * Autoconf macros:: TL-specific Autoconf macros.
1058 * Library modules:: Handling libraries, with examples.
1059 * Program modules:: Handling programs, with examples.
1060 * Extending @TL{}:: Adding a new module.
1061 @end menu
1062
1063 @node Build system tools
1064 @section Build system tools
1065
1066 @cindex tools, for building
1067 @cindex GNU tools, needed for building
1068 @cindex infrastructure, tools needed for
1069
1070 As mentioned above (@pxref{Prerequisites}), a normal build has few
1071 requirements. On the other hand, if you want to modify the @TL{}
1072 infrastructure sources, such as @file{configure.ac} or
1073 @file{Makefile.am} files, you will need to have several additional
1074 tools installed.
1075
1076 In general, the TL build system uses the latest released versions of
1077 the GNU build tools, installed directly from the original GNU releases
1078 (e.g., by building them with @code{configure --prefix=/usr/local/gnu}
1079 and having @env{PATH} start with @file{/usr/local/gnu/bin}). We have
1080 found that trying to use the versions of these tools packaged for
1081 distros causes many extra hassles, so don't do that, tempting as it
1082 may be.
1083
1084 Currently the versions we use are:
1085
1086 @display
1087 @include build-tools.txt
1088 @end display
1089
1090 @pindex reautoconf
1091 @vindex --enable-maintainer-mode
1092 These versions should be used to update the generated files (e.g.,
1093 @file{configure} or @file{Makefile.in}) in all or parts of the TL tree
1094 after their dependencies have been changed. This can be done
1095 explicitly with the top-level @code{reautoconf} script or implicitly
1096 by using the configure option @code{--enable-maintainer-mode}.
1097
1098 It has often turned out that the bison and flex versions are not
1099 critical; however, the autotools versions are. If you don't have the
1100 given versions, get them before modifying the build infrastructure.
1101
1102 @cindex Subversion repository
1103 @cindex timestamps, in repository
1104 @vindex use-commit-times@r{, Subversion}
1105 The files in the Subversion repository (see
1106 @url{https://tug.org/texlive/svn}) are all up to date (barring
1107 bugs). For this to be reflected by their timestamps in your checkout,
1108 be sure to set @file{use-commit-times=yes} in
1109 @file{~/.subversion/config} or the equivalent.
1110
1111 @cindex touching files to avoid rerunning
1112 @pindex make -t
1113 If timestamps are wrong, you may also be able to avoid unnecessary
1114 runs of @code{bison}, @code{flex}, or @code{makeinfo} with
1115 @code{touch} of the generated (@file{.c}, @file{.h}, or @file{.info})
1116 files. With @code{--enable-maintainer-mode} it may also be necessary
1117 to @code{touch} first @file{aclocal.m4}, then @file{configure} and
1118 @file{config.h.in} (or @file{c-auto.in}), and finally all
1119 @file{Makefile.in} files.
1120
1121 @node Top-level directories
1122 @section Top-level directories
1123
1124 @cindex directories, top-level
1125 @cindex top-level directories
1126
1127 Here is a brief description of the top-level directories in the @TL{}
1128 source tree.
1129
1130 As mentioned at the beginning of @pxref{Overview of build
1131 system}, the main source directories are @file{texk/}
1132 (@TeX{}-specific programs and libraries), @file{utils/} (additional
1133 programs), and @file{libs/} (generic libraries).
1134
1135 @cindex @file{am/} top-level directory
1136 @cindex @file{m4/} top-level directory
1137 In addition, the top-level directories @file{am/} and @file{m4/}
1138 contain @file{Makefile.am} fragments and Autoconf macros,
1139 respectively, used in many places. Specifically, the file
1140 @file{m4/kpse-pkgs.m4} contains lists of all program and library
1141 modules; missing modules are silently ignored. (This helps in
1142 creating cut-down source trees.)
1143
1144 Each module contributes fragments (in separate files) defining its
1145 capabilities and requirements to the @file{configure.ac} scripts at
1146 the top-level and in the subdirectories @file{libs}, @file{utils}, and
1147 @file{texk}. The fragments from program modules supply
1148 @code{configure} options to disable or enable building them; those
1149 from library modules specify if an installed (system) version of that
1150 library can be used. This ultimately determines which modules need to
1151 be built---although all modules must be configured for the benefit of
1152 @file{make} targets such as @code{dist} or @code{distcheck}.
1153
1154 @cindex @file{build-aux/} top-level directory
1155 @pindex config.guess@r{,} config.sub, @dots{}
1156 @cindex Gnulib, used for common files
1157 The top-level @file{build-aux/} directory contains the common files
1158 @file{compile}, @file{config.guess}, @file{config.sub},
1159 @file{depcomp}, etc.@ used by most packages. These are taken from the
1160 GNU Gnulib sources (@url{https://www.gnu.org/software/gnulib}), which
1161 in turn synchronizes with any ultimate upstream repository. There are
1162 independent copies of some of these in a few other places, e.g.,
1163 @file{libs/freetype2/freetype-*/builds/unix/}. The @code{reautoconf}
1164 script does not touch those, but a TL cron job keeps them in sync
1165 (nightly).
1166
1167 @cindex @file{Work/} top-level directory
1168 @cindex @file{inst/} top-level directory
1169 When the top-level @file{./Build} script is used to build TL, two more
1170 two more top-level directories appear: @file{Work/} for the build tree,
1171 and @file{inst/} for the install tree (from @code{make install}).
1172 These names (and everything else about @file{Build}'s operation) can
1173 be changed by setting environment variables before running it; see the
1174 script source.
1175
1176 @node Autoconf macros
1177 @section Autoconf macros
1178
1179 @cindex autoconf macros
1180
1181 @c Texinfo macro: @ovar(ARG)
1182 @c ARG is the name of an optional argument; this is used for
1183 @c documentation of macro arguments (@defmac lines). Plain
1184 @c brackets are treated specially and appear more distinct.
1185 @macro ovar{varname}
1186 [@var{\varname\}]
1187 @end macro
1188
1189 @c @dvar(ARG, DEFAULT)
1190 @c -------------------
1191 @c The ARG is an optional argument, defaulting to DEFAULT. To be used
1192 @c for macro arguments in their documentation (@defmac).
1193 @c @macro xxdvar{varname, default}
1194 @c @r{[}@var{\varname\} = @samp{\default\}@r{]}
1195 @c @end macro
1196
1197 Here we describe a few of the Autoconf macros used in several
1198 modules---many more are defined in the sources; see the top-level
1199 @code{m4/} directory. These general macros are supplemented by
1200 module-specific macros in directories such as @file{texk/dvipng/m4/};
1201 some of those are described in following sections (@pxref{Library
1202 modules} and @ref{Program modules}).
1203
1204 @menu
1205 * Setup: General setup macros.
1206 * Programs: Macros for programs.
1207 * Compilers: Macros for compilers.
1208 * Libraries: Macros for libraries.
1209 * Flags: Macros for library and header flags.
1210 * Windows: Macros for Windows.
1211 @end menu
1212
1213 @node General setup macros
1214 @subsection General setup macros
1215
1216 @cindex general setup macros
1217 @cindex setup macros, general
1218 @cindex macros, general setup
1219 The TL sources use two general setup macros:
1220
1221 @defmac KPSE_BASIC (@var{name}, @ovar{more-options})
1222 Initialize the basic TL infrastructure for module @var{name}:@*@ @ @
1223 @code{AM_INIT_AUTOMAKE([foreign @var{more-options}])}@*@ @ @
1224 @code{AM_MAINTAINER_MODE}@*@ @ @ @code{KPSE_COMPILER_WARNINGS}@*
1225 and make sure the C compiler understands function prototypes. This is
1226 used for all generic library and program modules.
1227 @end defmac
1228
1229 @defmac KPSE_COMMON (@var{name}, @ovar{more-options})
1230 Like @code{KPSE_BASIC} but add:@*@ @ @ @code{LT_PREREQ([2.2.6])}@*@ @
1231 @ @code{LT_INIT([win32-dll])}@*@ @ @ @code{AC_SYS_LARGEFILE}@*@ @ @
1232 @code{AC_FUNC_FSEEKO}@*along with checks for frequently used functions,
1233 headers, types, and structures. This is used for @TeX{}-specific
1234 modules.
1235 @end defmac
1236
1237 @node Macros for programs
1238 @subsection Macros for programs
1239
1240 @cindex macros, for programs
1241 Macros for program checks:
1242
1243 @defmac KPSE_CHECK_LATEX
1244 Set @code{LATEX} to the first of @code{latex}, @code{elatex}, or
1245 @code{lambda} which exists in @code{PATH}, or to @code{no} if none of
1246 them exists. Call @code{AC_SUBST} for @code{LATEX}. The result of
1247 this test can be overridden by setting the @code{LATEX} environment
1248 variable or the cache variable @code{ac_cv_prog_LATEX}.
1249 @end defmac
1250
1251 @defmac KPSE_CHECK_PDFLATEX
1252 Check for @code{pdflatex} in @code{PATH} and set @code{PDFLATEX}.
1253 @end defmac
1254
1255 @defmac KPSE_CHECK_PERL
1256 Check for @code{perl} or @code{perl5} in @code{PATH} and set
1257 @code{PERL}.
1258 @end defmac
1259
1260 @defmac KPSE_PROG_LEX
1261 Call @code{AC_PROG_LEX} and add the flag @code{-l} for @code{flex}.
1262 @end defmac
1263
1264 @node Macros for compilers
1265 @subsection Macros for compilers
1266
1267 @cindex macros, for compilers
1268
1269 Macros for compiler-related checks:
1270
1271 @defmac KPSE_COMPILER_WARNINGS
1272 @vindex WARNING_C[XX]FLAGS
1273 When using the (Objective) C/C++ compiler, set
1274 @code{WARNING_[OBJ]C[XX]FLAGS} to suitable warning flags (depending on
1275 the value given to or implied for @code{--enable-compiler-warnings}).
1276 Call @code{AC_SUBST} for them. At present this assumes GNU compiler
1277 warning options, but could be extended to others if necessary.
1278
1279 @vindex kpse_cv_warning_cflags
1280 This macro caches its results in the @code{kpse_cv_warning_cflags},
1281 @dots{} variables.
1282 @end defmac
1283
1284 @defmac KPSE_COMPILER_VISIBILITY
1285 @vindex -fvisibility=hidden
1286 @vindex -fvisibility-inlines-hidden
1287 When using the C or C++ compiler, try to set
1288 @code{VISIBILITY_C[XX]FLAGS} to flags to hide external symbols. Call
1289 @code{AC_SUBST} for this variable. This tests for the compiler option
1290 @code{-fvisibility=hidden} and, except for C,
1291 @code{-fvisibility-inlines-hidden}. Reports or patches for additional
1292 tests are welcome.
1293
1294 @vindex kpse_cv_visibility_c[xx]flags
1295 This macro caches its results in the @code{kpse_cv_visibility_cflags}
1296 or @code{kpse_cv_visibility_cxxflags} variable.
1297 @end defmac
1298
1299 @defmac KPSE_CXX_HACK
1300 @cindex static linking for C++
1301 @cindex linking C++ libraries statically
1302 @vindex --enable-cxx-runtime-hack
1303 @pindex libstc++@r{, statically linking}
1304 Provide the configure option @code{--enable-cxx-runtime-hack}. If
1305 enabled and when using @code{g++}, try to statically link with
1306 @file{libstdc++}, notably improving portability of the resulting
1307 binary.
1308
1309 @vindex kpse_cv_cxx_hack
1310 This macro caches its result in the @code{kpse_cv_cxx_hack} variable.
1311 @end defmac
1312
1313 @node Macros for libraries
1314 @subsection Macros for libraries
1315
1316 @cindex macros, for libraries
1317 One macro for a library check:
1318
1319 @defmac KPSE_LARGEFILE (@var{variable}, @ovar{extra-define})
1320 Call @code{AC_SYS_LARGEFILE} and @code{AC_FUNC_FSEEKO} and append
1321 suitable @code{-D} flags (optionally including
1322 @code{-D@var{extra-define}}) to @var{variable}.
1323 @end defmac
1324
1325 @node Macros for library and header flags
1326 @subsection Macros for library and header flags
1327
1328 @cindex macros, for library and header flags
1329 @cindex flags, macros for library and header
1330 @vindex KPSE_@var{LIB}_FLAGS
1331 Each library module @file{libs/@var{lib}} or @file{texk/@var{lib}} is
1332 supplemented by a macro @code{KPSE_@var{LIB}_FLAGS} (all uppercase)
1333 that provides make variables for that library. E.g., for
1334 @file{libs/libpng}:
1335
1336 @defmac KPSE_LIBPNG_FLAGS
1337 Provide the configure option @code{--with-system-libpng}. Set and
1338 @code{AC_SUBST} @code{make} variables for modules using this library (either
1339 an installed version or from the @TL{} tree):
1340
1341 @multitable {@code{LIBPNG_INCLUDES}} {for the @code{make} rules to rebuild the library.}
1342 @item @code{LIBPNG_INCLUDES}
1343 @tab for use in @code{CPPFLAGS},
1344 @item @code{LIBPNG_LIBS}
1345 @tab for use in @code{LDADD},
1346 @item @code{LIBPNG_DEPEND}
1347 @tab for use as a Makefile dependency,
1348 @item @code{LIBPNG_RULE}
1349 @tab for the @code{make} rules to rebuild the library.
1350 @end multitable
1351 @end defmac
1352
1353 @defmac KPSE_ADD_FLAGS (@var{name})
1354 Temporarily extend @code{CPPFLAGS} and @code{LIBS} with the values required
1355 for the library module @code{@var{name}}.
1356 @end defmac
1357
1358 @defmac KPSE_RESTORE_FLAGS
1359 Restore @code{CPPFLAGS} and @code{LIBS} to their original values.
1360 @end defmac
1361
1362 As an example, the @file{configure.ac} file for a hypothetical program
1363 @file{utils/foo} using @file{libpng}, and hence @file{zlib}, would
1364 contain
1365 @example
1366 KPSE_ZLIB_FLAGS
1367 KPSE_LIBPNG_FLAGS
1368 @end example
1369
1370 @noindent and its @file{Makefile.am} would be along these lines:
1371 @example
1372 bin_PROGRAMS = foo
1373 AM_CPPFLAGS = $@{LIBPNG_INCLUDES@} $@{ZLIB_INCLUDES@}
1374 foo_LDADD = $@{LIBPNG_LIBS@} $@{ZLIB_LIBS@}
1375 foo_DEPENDENCIES = $@{ZLIB_DEPEND@} $@{LIBPNG_DEPEND@}
1376 ## Rebuild libz
1377 @@ZLIB_RULE@@
1378 ## Rebuild libpng
1379 @@LIBPNG_RULE@@
1380 @end example
1381
1382 If it were necessary to examine whether certain @file{zlib} or
1383 @file{libpng} features were available, @file{configure.ac} should be
1384 continued this way:
1385 @example
1386 KPSE_ADD_FLAGS([zlib])
1387 @dots{} # @r{tests for @file{zlib} features, if any}
1388 KPSE_ADD_FLAGS([libpng])
1389 @dots{} # @r{tests for @file{libpng} features}
1390 KPSE_RESTORE_FLAGS # @r{restore @code{CPPFLAGS} and @code{LIBS}}
1391 @end example
1392
1393 @node Macros for Windows
1394 @subsection Macros for Windows
1395
1396 @cindex macros, for Windows
1397 @cindex Windows, macros for
1398 Windows differs in several aspects from Unix-like systems, many of
1399 them due to the lack of symbolic links.
1400
1401 @defmac KPSE_CHECK_WIN32
1402 @vindex kpse_cv_have_win32
1403 Check if compiling for a Windows system. The result is either
1404 @code{no} for Unix-like systems (including Cygwin), @code{mingw32} for
1405 Windows with GCC, or @code{native} for Windows with MSVC. The result
1406 is cached in the @code{kpse_cv_have_win32} variable.
1407 @end defmac
1408
1409 @defmac KPSE_COND_WIN32
1410 @vindex WIN32@r{, Automake conditional}
1411 Call @code{KPSE_CHECK_WIN32} and define the Automake conditional
1412 @code{WIN32} (@code{true} if the value of @code{kpse_cv_have_win32} is
1413 not @code{no}).
1414 @end defmac
1415
1416 @defmac KPSE_COND_MINGW32
1417 @vindex MINGW32@r{, Automake conditional}
1418 Call @code{KPSE_COND_WIN32} and define the Automake conditional
1419 @code{MINGW32} (@code{true} if the value of @code{kpse_cv_have_win32} is
1420 @code{mingw32}).
1421 @end defmac
1422
1423 @defmac KPSE_COND_WIN32_WRAP
1424 @vindex WIN32_WRAP@r{, Automake conditional}
1425 @pindex runscript.exe
1426 Call @code{KPSE_COND_WIN32} and define the Automake conditional
1427 @code{WIN32_WRAP} (@code{true} if the standard Windows wrapper
1428 (@file{texk/texlive/windows_wrapper/runscript.exe}) exists. This wrapper
1429 is used on Windows instead of symlinks for the ``linked scripts''
1430 (@pxref{Linked scripts}).
1431 @end defmac
1432
1433 @defmac KPSE_WIN32_CALL
1434 @pindex callexe.c
1435 Call @code{KPSE_COND_WIN32} and check whether the file
1436 @file{texk/texlive/windows_wrapper/callexe.c} exists; if it does, create a
1437 symlink in the build tree. Compiling @file{callexe.c} with
1438 @code{-DEXEPROG='"@var{foo}.exe"'} and installing @file{callexe.exe}
1439 as @code{@var{bar}.exe} is used on Windows instead of a symlink
1440 @code{@var{bar}->@var{foo}} for Unix-like systems.
1441 @end defmac
1442
1443 @node Library modules
1444 @section Library modules
1445
1446 @cindex library modules
1447 @cindex modules, for libraries
1448 Here we discuss some specifics for a few of the libraries in TL, both
1449 for the details themselves, and as a way of illuminating the general
1450 structure and variation.
1451
1452 @menu
1453 * @code{png} library:: @file{libs/libpng}
1454 * @code{zlib} library:: @file{libs/zlib}
1455 * @code{freetype} library:: @file{libs/freetype2}
1456 * @code{kpathsea} library:: @file{texk/kpathsea}
1457 @end menu
1458
1459 @node @code{png} library
1460 @subsection The @code{png} library in @file{libs/libpng}
1461
1462 @pindex png @r{library}
1463 @pindex libpng @r{library}
1464 The ``generic'' @code{png} library uses the source tree in the
1465 subdirectory @file{libpng-src/}, with all modifications for TL
1466 recorded in @file{TLpatches/*}. The @file{configure.ac} fragment
1467 @file{ac/withenable.ac} contains
1468
1469 @example
1470 KPSE_WITH_LIB([libpng], [zlib])
1471 @end example
1472
1473 @noindent to specify the module name and indicate the dependency on
1474 @code{zlib}. A third literal argument `@code{tree}' would specify that
1475 the library from the @TL{} tree cannot be replaced by a system
1476 version. That not being the case here, a second fragment
1477 @file{ac/libpng.ac} contains
1478
1479 @findex KPSE_TRY_LIB
1480 @example
1481 KPSE_TRY_LIB([libpng],
1482 [#include <png.h>],
1483 [png_structp png; png_voidp io; png_rw_ptr fn;
1484 png_set_read_fn(png, io, fn);])
1485 @end example
1486
1487 @noindent thus providing the simple C code
1488
1489 @example
1490 #include <png.h>
1491 int main ()
1492 @{ png_structp png; png_voidp io; png_rw_ptr fn;
1493 png_set_read_fn(png, io, fn);
1494 return 0; @}
1495 @end example
1496
1497 @findex KPSE_TRY_LIBXX
1498 @noindent which Autoconf uses to verify the usability of a system
1499 version with C code. The analogous macro @code{KPSE_TRY_LIBXX} would
1500 check using C++. These fragments are included by the
1501 @file{configure.ac} at the top level of TL
1502 (@code{Build/source/configure.ac}).
1503
1504 @cindex proxy build system
1505 For this library, like many other modules, a proxy build system for TL
1506 is used, consisting of our own @file{configure.ac},
1507 @file{Makefile.am}, @file{include/Makefile.am}; the distributed build
1508 system is not used. (Consequently, a few generated files and
1509 auxiliary scripts are removed from the distributed source tree.)
1510
1511 The public headers @file{png.h}, @file{pngconf.h}, and
1512 @file{pnglibconf.h} are ``installed'' (as symlinks) under
1513 @file{include/} in the build tree exactly as they are for a system
1514 version under, e.g., @file{/usr/include/}.
1515
1516 @pindex kpse-libpng-flags.m4
1517 @vindex KPSE_LIBPNG_FLAGS
1518 The module is supplemented by the file @file{m4/kpse-libpng-flags.m4}
1519 that defines the M4 macro @code{KPSE_LIBPNG_FLAGS} used by all modules
1520 depending on this library in their @file{configure.ac} to generate the
1521 @code{make} variables @code{LIBPNG_INCLUDES} for use in
1522 @code{CPPFLAGS}, @code{LIBPNG_LIBS} for use in @code{LDADD},
1523 @code{LIBPNG_DEPEND} for use as dependencies, and @code{LIBPNG_RULE}
1524 for the @code{make} rules to rebuild the library.
1525
1526 @file{m4/kpse-libpng-flags.m4} also supplies the configure option
1527 @code{--with-system-libpng}, which then uses @code{pkg-config} to
1528 determine the flags required for the system library.
1529
1530 @node @code{zlib} library
1531 @subsection The @code{zlib} library in @file{libs/zlib}
1532
1533 @pindex zlib @r{library}
1534
1535 @pindex kpse-zlib-flags.m4
1536 This generic library is very much analogous to @code{libpng}, but
1537 without the dependency on any other library. The file
1538 @file{m4/kpse-zlib-flags.m4} supplies the configure option
1539 @code{--with-system-zlib}, as well as @code{--with-zlib-includes} and
1540 @code{--with-zlib-libdir} to specify non-standard locations of the
1541 @code{zlib} headers and/or library.
1542
1543 @node @code{freetype} library
1544 @subsection The @code{freetype} library in @file{libs/freetype2}
1545
1546 @pindex freetype @r{library}
1547 @cindex wrapper build system
1548
1549 This module uses a wrapper build system. In contrast to the proxy
1550 build described earlier, the wrapper build has an almost trivial
1551 @file{configure.ac} and a @file{Makefile.am} which invokes the
1552 @code{configure} and @code{make} in the distributed source, followed
1553 by @code{make install} with the TL build tree as destination. In
1554 other words, this actually uses the build system provided by upstream
1555 (possibly patched).
1556
1557 @pindex freetype-config
1558 The flags required for the system library are obtained through
1559 @code{freetype-config}.
1560
1561 @node @code{kpathsea} library
1562 @subsection The @code{kpathsea} library in @file{texk/kpathsea}
1563
1564 @pindex kpathsea @r{library}
1565
1566 This is one of the @TeX{}-specific libraries that are maintained as
1567 part of @TL{} (@pxref{,,, kpathsea, Kpathsea
1568 @r{(@url{tug.org/kpathsea})}}); the other is @code{ptexenc}. These
1569 @TeX{} libraries are Libtool libraries (static and/or shared) and are
1570 installed by @code{make install} together with the programs. They
1571 are, however, not part of the TL DVD as distributed by @TeX{} user
1572 groups, and have never been officially released for standalone use.
1573
1574 @pindex --with-system-kpathsea
1575 It is possible, and probably useful for distro builds (@pxref{Distro
1576 builds}), to specify the configure option
1577 @code{--with-system-kpathsea} in order to use a system version of the
1578 library. Programs outside the TL tree should use @code{pkg-config}
1579 for the required flags.
1580
1581 @pindex kpathsea.ac
1582 @pindex mktex.ac
1583 @vindex --enable-mktextfm-default
1584 @pindex mktextfm
1585 In addition to @file{kpathsea/ac/withenable.ac} and
1586 @file{kpathsea/ac/kpathsea.ac} here there is a third fragment
1587 @file{kpathsea.ac/mktex.ac}, included by both @file{withenable.ac} and
1588 @file{configure.ac}, which supplies configure options such as
1589 @code{--enable-mktextfm-default}. These determine the compile time
1590 default of whether or not to run @code{mktextfm} (and similar) to
1591 generate a missing @file{.tfm} (or whatever) file. In any case,
1592 however, the command line options @code{-mktex=tfm} or
1593 @code{-no-mktex=tfm} for the @TeX{}-like engines override this
1594 default.
1595
1596 @node Program modules
1597 @section Program modules
1598
1599 @cindex program modules
1600 @cindex modules, for programs
1601 As with libraries (@pxref{Library modules}), here we discuss the
1602 details for a few of the programs in TL.
1603
1604 @menu
1605 * @code{t1utils} package:: @file{utils/t1utils}
1606 * @code{xindy} package:: @file{utils/xindy}
1607 * @code{xdvik} package:: @file{texk/xdvik}
1608 * @code{asymptote}:: @file{utils/asymptote}
1609 @end menu
1610
1611 @node @code{t1utils} package
1612 @subsection The @code{t1utils} package in @file{utils/t1utils}
1613
1614 @pindex t1utils @r{package}
1615
1616 Here we use the distributed source tree @file{t1utils-src} with
1617 modifications documented in @file{TLpatches/*} and a proxy build
1618 system consisting of @file{configure.ac} and @file{Makefile.am}. The
1619 fragment @file{ac/withenable.ac} contains
1620
1621 @example
1622 KPSE_ENABLE_PROG([t1utils])
1623 @end example
1624
1625 @noindent specifying the module name without any dependencies, and
1626 supplies the configure option @code{--disable-t1utils}.
1627
1628 @node @code{xindy} package
1629 @subsection The @code{xindy} package in @file{utils/xindy}
1630
1631 @pindex xindy
1632
1633 This module uses the distributed source tree @file{xindy-src/} with
1634 modifications documented in @file{TLpatches/*}, and a wrapper
1635 @file{configure.ac} and @file{Makefile.am} that descends into
1636 @file{xindy-src}.
1637
1638 The @code{xindy} build requires a @file{make} that supports a
1639 @code{VPATH} build, can handle all needed targets, and does not refer
1640 to @code{$@{top_srcdir@}} or @code{$@{top_builddir@}}. The fragment
1641 @code{xindy/ac/withenable.ac} contains
1642
1643 @example
1644 KPSE_ENABLE_PROG([xindy], , [disable])
1645 m4_include(kpse_TL[utils/xindy/ac/xindy.ac])
1646 m4_include(kpse_TL[utils/xindy/ac/clisp.ac])
1647 @end example
1648
1649 @noindent where @code{disable} in the third argument indicates that
1650 @code{xindy} is only built if explicitly enabled by the user with
1651 @code{configure --enable-xindy} (the need for @code{clisp} makes it
1652 too painful to enable by default).
1653
1654 The additional fragments @file{ac/xindy.ac} and @file{ac/clisp.ac}
1655 specify more @code{configure} options to be seen at the top level,
1656 with @file{ac/xindy.ac} also included by @file{configure.ac}.
1657
1658 @node @code{xdvik} package
1659 @subsection The @code{xdvik} package in @file{texk/xdvik}
1660
1661 @pindex xdvik
1662
1663 This package is maintained as part of the @TL{} tree with sources in
1664 its own directory (@file{texk/xdvik/}). The fragment
1665 @code{xdvik/ac/withenable.ac} contains
1666
1667 @example
1668 dnl extra_dirs = texk/xdvik/squeeze
1669 KPSE_ENABLE_PROG([xdvik], [kpathsea freetype2], [x])
1670 m4_include(kpse_TL[texk/xdvik/ac/xdvik.ac])
1671 @end example
1672
1673 @pindex squeeze/configure.ac
1674 @cindex cross compilation, with host binary
1675 @noindent thus specifying dependencies on the @code{kpathsea},
1676 @code{freetype}, and X11 libraries. The M4 comment (following
1677 @code{dnl}) signals the subsidiary @file{squeeze/configure.ac}. This
1678 is needed because the main executable @file{xdvi-bin} (to be installed
1679 as, e.g., @file{xdvi-xaw}) is for the @code{host} system whereas the
1680 auxiliary program @file{squeeze/squeeze} has to run on the
1681 @code{build} system; in a cross compilation, these differ.
1682
1683 @vindex --with-xdvi-x-toolkit
1684 The additional fragment @code{ac/xdvik.ac} is also included by
1685 @file{configure.ac} and supplies the configure option
1686 @code{--with-xdvi-x-toolkit} also seen at the top level.
1687
1688 @node @code{asymptote}
1689 @subsection The subdirectory @file{utils/asymptote}
1690
1691 @pindex asymptote
1692 @pindex xasy
1693
1694 @cindex OpenGL, required for Asymptote
1695 This subdirectory contains the sources for @file{asy} and @file{xasy}
1696 but due to its complexity and prerequisites (e.g., OpenGL) it is
1697 not part of the TL build system. These programs must be built and
1698 installed independently, but are included on the TL DVD together with
1699 their support files. See @url{https://tug.org/texlive/build.html#asymptote}.
1700
1701 @node Extending @TL{}
1702 @section Extending @TL{}
1703
1704 @cindex extending @TL{}
1705 @cindex adding to @TL{}
1706
1707 This section outlines the basic process for adding new packages to the
1708 TL build system.
1709
1710 A new package directory @file{foo} should be placed under
1711 @file{Build/source/texk/} if it uses Kpathsea (or another
1712 @TeX{}-specific library), or under @file{Build/source/utils} if it
1713 does not.
1714
1715 The new directory should normally have the original sources, modified
1716 only with changes necessary for TL, in a subdirectory
1717 @file{foo/foo-src}. The changes should be documented in
1718 @file{foo/TLpatches/*}, and also be submitted upstream whenever
1719 reasonable. In addition, @file{foo/} will need the usual Automake
1720 build-related files (@file{configure.ac}, @file{Makefile.am}, etc.
1721 Please maintain @file{foo/ChangeLog} for all TL changes.
1722
1723 @cindex new package using Autoconf only
1724 @cindex Autoconf, new package using only
1725 It is also possible to add a package which is configured with Autoconf
1726 (or another @code{make}-based system) and not Automake. The package
1727 must still support the standard @code{make} variables and targets, and
1728 @code{VPATH} builds (@pxref{VPATH Builds,,, automake, GNU Automake}).
1729 For Autoconf-only packages, it is probably not sensible to use a
1730 @code{foo-src} subdirectory.
1731
1732 @menu
1733 * Adding a new program module::
1734 * Adding a new engine::
1735 * Adding a new generic library module::
1736 * Adding a new @TeX{}-specific library module::
1737 @end menu
1738
1739 @node Adding a new program module
1740 @subsection Adding a new program module
1741
1742 @cindex adding a new program
1743 @cindex program module, adding
1744
1745 @vindex kpse_texk_pkgs
1746 A @TeX{}-specific program module in a subdirectory
1747 @file{texk/@var{prog}} may use the @TeX{}-specific libraries and is
1748 included by adding its name @file{@var{prog}} to the M4 list
1749 @code{kpse_texk_pkgs} defined in @file{m4/kpse-pkgs.m4}.
1750
1751 @vindex kpse_utils_pkgs
1752 A generic program module in a subdirectory @file{utils/@var{prog}}
1753 must not use the @TeX{}-specific libraries, notably Kpathsea, and is
1754 included by adding its name @file{@var{prog}} to the M4 list
1755 @code{kpse_utils_pkgs} in @file{m4/kpse-pkgs.m4}.
1756
1757 @pindex withenable.ac@r{, for new modules}
1758 @findex KPSE_ENABLE_PROG
1759 In either case, the subdirectory @file{texk/@var{prog}} or
1760 @file{utils/@var{prog}} must include a file
1761 @file{ac/withenable.ac} which contains a call to the M4 macro
1762 @code{KPSE_ENABLE_PROG} defined in @file{m4/kpse-setup.m4} with
1763 @code{@var{prog}} as the mandatory first argument and three optional
1764 arguments:
1765
1766 @enumerate
1767 @item a list of required libraries from the TL tree;
1768
1769 @item a list of options: @code{disable} if this module is not to be
1770 built without the configure option @code{--enable-@var{prog}},
1771 @code{native} if cross compilation is not possible, @code{x} if the
1772 program requires X11 libraries;
1773
1774 @item a comment added to the help text for the @code{configure}
1775 option @code{--enable-@var{prog}} or @code{--disable-@var{prog}}.
1776 @end enumerate
1777
1778 If the module requires specific @code{configure} options to be seen at
1779 the top level, they should be defined in an additional fragment
1780 @file{ac/@var{prog}.ac} included from @file{ac/withenable.ac} and
1781 @file{configure.ac}.
1782
1783 @cindex @var{newprog-src}, original source subdirectory
1784 Usually, the new program is maintained somewhere outside of @TL{}. In
1785 that case, as above, we put the upstream sources into a subdirectory
1786 @file{@var{prog}-src} (e.g., @file{utils/newprog/newprog-src}). We do
1787 not typically run @code{configure} in this original @code{...-src}
1788 directory, but only in our own directory; but we do compile using the
1789 source files in @code{...-src}.
1790
1791 So, to summarize the files that must (usually) be created inside a new
1792 TL source directory (@file{texk/newprog} or @file{utils/newprog}):
1793
1794 @ftable @file
1795 @item ac/withenable.ac
1796 The @code{KPSE_ENABLE_PROG} call just explained.
1797
1798 @item configure.ac
1799 @itemx Makefile.am
1800 By merging the contents of the original @file{configure.ac} (if
1801 provided) and a comparable program already in TL. In the above
1802 example, one line that will be needed in @file{configure.ac} (can be
1803 added before the @code{AC_CONFIG_FILES} at the end) is:
1804
1805 @example
1806 AC_SUBST([NEWPROG_TREE], [newprog-src])
1807 @end example
1808
1809 @noindent and then use @code{@@NEWPROG_TREE@@} in
1810 @code{Makefile.am} where needed.
1811
1812 In general, there is no magic recipe for this part of the job. It's
1813 necessary to think about what needs to be done in the original vs.@:
1814 in @TL{}. It's useful to look at the setup for the most comparable
1815 programs already in TL that you can find. It's also useful to grep the
1816 entire @file{Build/source} tree for whatever you can think of to
1817 investigate how something is done. Most of the TL-specific macros are
1818 defined in @file{Build/source/m4/*}.
1819
1820 @item TLpatches/TL-Changes
1821 First actions taken after getting the original source tree; typically
1822 removal of derived or unused common files.
1823
1824 @item TLpatches/patch-...
1825 If any changes are needed to the original sources, record the patches
1826 here so they can be applied next time. Also, send them upstream so
1827 that we don't have to maintain them forever.
1828
1829 @item ChangeLog
1830 Record all TL-specific changes, now and in the future.
1831
1832 @end ftable
1833
1834 @pindex autoreconf@r{, for new program}
1835 After populating the new TL source directory (@file{.../newprog/}, in
1836 the above), run GNU @code{autoreconf} there (@pxref{Build system
1837 tools}). Once that works, if you are the one who's eventually going
1838 to commit the new package, @code{svn add} the necessary files,
1839 including the generated @file{Makefile.in aclocal.m4 configure}, and
1840 @code{svn:ignore} the Automake cache @file{autom4te.cache}. (This is
1841 so people checking out the TL source tree do not have to run any
1842 autotools, but can simply run @code{configure}.)
1843
1844 To reiterate: do not fail to commit the generated @file{configure} and
1845 other files. The m4 code in @file{kpse-pkgs.m4} uses the existence of
1846 @file{configure} to determine whether to descend into (and configure)
1847 a given subdirectory.
1848
1849 @pindex reautoconf@r{, for new program}
1850 Then, run the TL tool @code{reautoconf} in the top-level TL
1851 @code{Build/source/} directory, to incorporate the new program into
1852 the build tree. It is good to then rebuild the whole tree (e.g., using
1853 TL's @file{Build/Build} script) to get all the necessary files generated.
1854
1855 It will probably fail. So then you need to keep at it until the
1856 program compiles and tests successfully. The most efficient way is to
1857 rerun @code{autoreconf} as needed in the new source directory
1858 (@code{Build/source/.../newprog}), then @code{make} in the
1859 corresponding build directory (@code{Build/work/.../newprog}), then
1860 @code{make check}, etc. In the end, also make sure that the whole tree
1861 builds from scratch.
1862
1863 After final success, don't forget to commit. (Or email the TL
1864 maintainers with the patch.)
1865
1866 @node Adding a new engine
1867 @subsection Adding a new engine
1868
1869 @cindex adding a new engine
1870 @cindex engine, adding new
1871
1872 Adding a new @TeX{} engine is not completely different from adding a
1873 program, but it's not all that similar, either. In this case, the main
1874 work is done by creating a new subdirectory of @file{texk/web2c/} for
1875 the engine. The subdirectory is conventionally named ending in
1876 @file{dir}, like @file{pdftexdir} and @file{xetexdir}, to avoid
1877 clashes with executable names.
1878
1879 The source files for the new engine should be put in this
1880 @file{@var{newengine}dir} subdirectory. Also, a file
1881 @file{@var{newengine}dir/am/@var{newengine}.am} (e.g.,
1882 @file{pdftexdir/am/pdftex.am} is needed with the Makefile fragment
1883 needed to build it.
1884
1885 The overall @file{web2c/Makefile.am} needs to have an @file{include}
1886 statement added to insert that @file{@var{newengine}.am} file.
1887
1888 In @file{web2c/ac/web2c.ac}, a line needs to be added in the
1889 definition of the @code{kpse_tex_progs} variable to include it in the
1890 build. That line specifies whether the new engine is built by default,
1891 and the additional libraries requires.
1892
1893 For examples of building engines in CWEB, you can check the existing
1894 @file{hitexdir} and @file{mplibdir} directories; these are somewhat
1895 simpler than Lua@TeX{}. Of course, every engine will have its own
1896 unique features and requirements, so existing examples will only take
1897 you so far.
1898
1899 Web2c is built as one ``package'', with each subdirectory's @file{.am}
1900 fragment inserted with an Automake @code{include}. This means that,
1901 for instance, @code{$(srcdir)} is @file{.../web2c}, not
1902 @file{.../webdir/enginedir}. It is a difficult setup to come to terms
1903 with, but the alternative is to recurse into each engine subdirectory,
1904 and that would be far worse (@pxref{Directories,,, automake, GNU
1905 Automake}).
1906
1907 @node Adding a new generic library module
1908 @subsection Adding a new generic library module
1909
1910 @cindex adding a new generic library
1911 @cindex generic library module, adding
1912 @cindex library module, generic, adding
1913
1914 @vindex kpse_libs_pkgs
1915 A generic library module in a subdirectory @file{libs/@var{lib}} must
1916 not depend on @TeX{}-specific libraries, by definition. It is
1917 included by adding its name @file{@var{lib}} to the M4 macro
1918 @code{kpse_libs_pkgs} in @file{m4/kpse-pkgs.m4}---before any other
1919 libraries from the @TL{} tree on which it depends.
1920
1921 @findex KPSE_WITH_LIB
1922 As with program modules, the subdirectory @file{libs/@var{lib}} must
1923 contain the sources and build system for the library (and any
1924 installable support programs) and a fragment @file{ac/withenable.ac}
1925 that contains the M4 macro @code{KPSE_WITH_LIB} defined in
1926 @file{m4/kpse-setup.m4} with @code{@var{lib}} as the mandatory first
1927 argument and two optional arguments: a list of required libraries from
1928 the TL tree, and a list of options: for libraries, currently there is
1929 only one---specify @code{tree} if this library cannot be replaced by a
1930 system version.
1931
1932 @findex KPSE_TRY_LIB
1933 @findex KPSE_TRY_LIBXX
1934 If a system version can be used, a second fragment
1935 @file{ac/@var{lib}.ac} is needed, containing the M4 macro
1936 @code{KPSE_TRY_LIB} (or @code{KPSE_TRY_LIBXX}) with @code{@var{lib}}
1937 as the mandatory first argument and two additional arguments for the
1938 Autoconf macro @code{AC_LANG_PROGRAM} used to compile and link a small
1939 C (or C++) program as sanity check for using the system library.
1940
1941 @vindex KPSE_@var{LIB}_FLAGS
1942 In addition a file @file{m4/kpse-@var{lib}-flags} (at the top level)
1943 must define the M4 macro @code{KPSE_@var{LIB}_FLAGS} (all uppercase)
1944 setting up the @code{make} variables @code{@var{LIB}_INCLUDES},
1945 @code{@var{LIB}_LIBS}, @code{@var{LIB}_DEPEND}, and
1946 @code{@var{LIB}_RULE} with the values required for @code{CPPFLAGS},
1947 @code{LDADD}, dependencies, and a (multi-line) @code{make} rule to
1948 rebuild the library when necessary. All of that is needed for the
1949 library from the TL tree and, if supported, for a system version.
1950
1951 @vindex --with-system-@var{lib}
1952 @vindex KPSE_@var{LIB}_SYSTEM_FLAGS
1953 @vindex KPSE_ALL_SYSTEM_FLAGS
1954 If a system library is allowed, @code{KPSE_@var{LIB}_FLAGS} also
1955 provides the configure option @code{--with-system-@var{lib}} and uses
1956 the additional M4 macro @code{KPSE_@var{LIB}_SYSTEM_FLAGS} to generate
1957 the @code{make} variables for a system library. In addition, the
1958 definition of the M4 macro @code{KPSE_ALL_SYSTEM_FLAGS} in
1959 @file{m4/kpse-pkgs.m4} must be extended by the line:@*@ @ @
1960 @code{AC_REQUIRE([KPSE_@var{LIB}_SYSTEM_FLAGS])}
1961
1962 @node Adding a new @TeX{}-specific library module
1963 @subsection Adding a new @TeX{}-specific library module
1964
1965 @cindex adding a new @TeX{}-specific library
1966 @cindex @TeX{}-specific library module, adding
1967 @cindex library module, @TeX{}-specific, adding
1968
1969 A @TeX{}-specific library module in a subdirectory
1970 @file{texk/@var{lib}} may depend on other @TeX{}-specific libraries
1971 but must not depend on any generic library from the TL tree. It is
1972 included in the same general ways as a generic library (see the
1973 previous section), with these modifications:
1974
1975 @itemize @bullet
1976 @item
1977 @vindex kpse_texlibs_pkgs
1978 The library name @code{@var{lib}} is added to the M4 macro
1979 @code{kpse_texlibs_pkgs}, which is also in @file{m4/kpse-pkgs.m4}.
1980
1981 @item
1982 @findex KPSE_WITH_TEXLIB
1983 The fragment @code{ac/withenable.ac} must use @code{KPSE_WITH_TEXLIB}.
1984 @end itemize
1985
1986 @node Configure options
1987 @chapter Configure options
1988
1989 @cindex @code{configure} options
1990
1991 Corresponding to the large number of program and library modules there
1992 are a large number @code{configure} options, most of which are
1993 described here. The command@*@ @ @ @code{configure --help}@*at the
1994 top level gives an exhaustive list of all global options and a few
1995 important module-specific ones, whereas, e.g.,@*@ @ @
1996 @code{texk/lcdf-typetools/configure --help}@* also displays the
1997 @code{lcdf-typetools} specific options, which are not shown at the
1998 top level.
1999
2000 @cindex environment variables, for @code{configure}
2001 The help text also mentions several influential environment variables,
2002 but for @TL{} it is better to specify them as assignments on the
2003 command line.
2004
2005 The @file{./Build} script used to make the binaries shipped with @TL{}
2006 invokes the top-level @code{configure} with a few additional options
2007 (@pxref{Building}). The defaults discussed below are those for the
2008 actual @code{configure} script; invoking @code{configure} via
2009 @file{./Build} yields different results.
2010
2011 Defaults for most options are set at the top level and propagated
2012 explicitly to all subdirectories. Options specified on the command
2013 line are checked for consistency but never modified.
2014
2015 @menu
2016 * Global configure options::
2017 * Program-specific configure options::
2018 * Library-specific configure options::
2019 * Variables for configure::
2020 @end menu
2021
2022 @node Global configure options
2023 @section Global configure options
2024
2025 @cindex global @code{configure} options
2026 @cindex @code{configure} options, global
2027 Here are the global configure options.
2028
2029 @menu
2030 * @code{--disable-native-texlive-build}::
2031 * @code{--prefix} @code{--bindir} @dots{}::
2032 * @code{--disable-largefile}::
2033 * @code{--disable-missing}::
2034 * @code{--enable-compiler-warnings=}@var{level}::
2035 * @code{--enable-cxx-runtime-hack}::
2036 * @code{--enable-maintainer-mode}::
2037 * @code{--enable-multiplatform}::
2038 * @code{--enable-shared}::
2039 * @code{--enable-silent-rules}::
2040 * @code{--without-ln-s}::
2041 * @code{--without-x}::
2042 @end menu
2043
2044 @node @code{--disable-native-texlive-build}
2045 @subsection @code{--disable-native-texlive-build}
2046
2047 @vindex --disable-native-texlive-build
2048 If enabled (the default), build for a TL binary distribution as
2049 shipped by the @TeX{} user groups. This requires GNU @code{make} and
2050 implies @code{--enable-multiplatform} and
2051 @code{--enable-cxx-runtime-hack} (unless they are explicitly disabled),
2052 and enforces @code{--disable-shared}.
2053
2054 If building TL for a GNU/Linux or other distribution, this should be
2055 disabled and system versions of most libraries should be used
2056 (@pxref{Distro builds}).
2057
2058 @vindex --enable-texlive-build
2059 A related option, @code{--enable-texlive-build}, is automatically
2060 passed to all subdirectories (and cannot be disabled). Subdirectories
2061 that can also be built independently from the TL tree (such as
2062 @file{utils/xindy} and @file{texk/dvipng}) but cooperate with TL can
2063 use this option to enable TL-specific adaptations, such as
2064 installation paths.
2065
2066 @node @code{--prefix} @code{--bindir} @dots{}
2067 @subsection @code{--prefix}, @code{--bindir}, @dots{}
2068
2069 @vindex --prefix configure @r{option}
2070 @vindex --bindir configure @r{option}
2071 These standard Autoconf options specify various installation
2072 directories as usual. For the complete list, @pxref{Installation
2073 directories}.
2074
2075 @vindex DESTDIR
2076 Also as usual, all values are prefixed by the value of @code{DESTDIR},
2077 if set, on the @code{make} command line (@pxref{Staged Installs, ,
2078 Installation in a temporary location, automake, GNU Automake}).
2079
2080 @node @code{--disable-largefile}
2081 @subsection @code{--disable-largefile}
2082
2083 @vindex --disable-largefile
2084 @cindex large file support
2085 @cindex LFS (large file support)
2086 Omit large file support (LFS), which is needed on most 32-bit Unix
2087 systems for files with 2GB or more. Regardless of this option, the
2088 size of @code{DVI} and @code{GF} files must always be @math{<2}GB, due
2089 to the file format specifications.
2090
2091 @cindex size of PDF and PS files
2092 @cindex PDF files, size of
2093 @cindex PostScript files, size of
2094 With LFS, there is no fixed limit on the size of PDF files created by
2095 @file{pdftex} or PostScript files created by @file{dvips}.
2096
2097 @node @code{--disable-missing}
2098 @subsection @code{--disable-missing}
2099
2100 @vindex --disable-missing
2101 Immediately terminate the build process if a requested program or feature
2102 must be disabled, e.g., due to missing libraries. This can help when
2103 figuring out a specific (sub)set of modules to enable.
2104
2105 @node @code{--enable-compiler-warnings=}@var{level}
2106 @subsection @code{--enable-compiler-warnings=}@var{level}
2107
2108 @vindex --enable-compiler-warnings=@var{level}
2109 Enable various levels of compiler warnings for C, C++, and/or
2110 Objective@tie{}C: the @var{level} value can be one of: @code{no min
2111 yes max all}. The default is @code{yes} in @code{maintainer-mode}
2112 (see below) and @code{min} otherwise. This option defines the
2113 variables @code{WARNING_[OBJ]C[XX]FLAGS}, but these variables are not
2114 consistently used in all library and program modules. At present,
2115 these warning flags assume options from the GNU compilers.
2116
2117 @node @code{--enable-cxx-runtime-hack}
2118 @subsection @code{--enable-cxx-runtime-hack}
2119
2120 If enabled (as it is for the native TL build), when using @code{g++},
2121 try to statically link with @code{libstdc++}, thus improving
2122 portability of the resulting binary. @xref{Macros for compilers}.
2123
2124 @node @code{--enable-maintainer-mode}
2125 @subsection @code{--enable-maintainer-mode}
2126
2127 @vindex --enable-maintainer-mode
2128 Enable @file{make} rules and dependencies not useful (and sometimes
2129 confusing) to the casual user. This requires current versions of the
2130 GNU build tools (@pxref{Build system tools}), as it automatically
2131 rebuilds infrastructure files as needed. @xref{maintainer-mode,,
2132 @code{missing} and @code{AM_MAINTAINER_MODE}, automake, GNU Automake}.
2133
2134 @node @code{--enable-multiplatform}
2135 @subsection @code{--enable-multiplatform}
2136
2137 @vindex --enable-multiplatform
2138 @vindex exec_prefix
2139 @vindex --bindir configure @r{option}
2140 @vindex --libdir configure @r{option}
2141 If enabled (as it is for the native TL build) and
2142 @code{--bindir=@var{dir}} or @code{--libdir=@var{dir}} are not
2143 specified, install executables and libraries in per-platform
2144 subdirectories of @file{@var{eprefix}/bin} and
2145 @file{@var{eprefix}/lib} where @var{eprefix} is the value given or
2146 implied for @code{exec_prefix}. In any case, the values for
2147 @code{bindir} and @code{libdir} are automatically propagated to all
2148 subdirectories.
2149
2150 @node @code{--enable-shared}
2151 @subsection @code{--enable-shared}
2152
2153 @vindex --enable-shared
2154 Build shared versions of the @TeX{}-specific libraries such as
2155 @file{libkpathsea}. This is not allowed for a native TL build (i.e.,
2156 @code{--disable-native-texlive-build} must also be specified).
2157
2158 @node @code{--enable-silent-rules}
2159 @subsection @code{--enable-silent-rules}
2160
2161 @vindex --enable-silent-rules
2162 @cindex @code{make} rules, verbose vs.@: silent
2163 Enable the use of less verbose build rules. When using GNU
2164 @code{make} (or any @code{make} implementation supporting nested
2165 variable expansions), you can specify @code{V=1} on the @code{make}
2166 command line to get more verbosity, or @code{V=0} to get less,
2167 regardless of this option.
2168
2169 @node @code{--without-ln-s}
2170 @subsection @code{--without-ln-s}
2171
2172 @vindex --without-ln-s
2173 Required when using a system without a working @code{ln -s} to build
2174 binaries for a Unix-like system. However, @code{make install} will
2175 not create anything useful, and might fail.
2176
2177 @node @code{--without-x}
2178 @subsection @code{--without-x}
2179
2180 @vindex --without-x
2181 Disable all programs using the X Window System.
2182
2183 @node Program-specific configure options
2184 @section Program-specific configure options
2185
2186 @cindex program-specific @code{configure} options
2187 @cindex @code{configure} options, program-specific
2188 Here are (some of) the program-specific @code{configure} options.
2189
2190 @menu
2191 * @code{--enable-@var{prog}} @code{--disable-@var{prog}}::
2192 * @code{--disable-all-pkgs}::
2193 * Configure options for @file{texk/web2c}::
2194 * Configure options for @file{texk/bibtex-x}::
2195 * Configure options for @file{texk/dvipdfm-x}::
2196 * Configure options for @file{texk/dvisvgm}::
2197 * Configure options for @file{texk/texlive}::
2198 * Configure options for @file{texk/xdvik}::
2199 * Configure options for @file{utils/xindy}::
2200 @end menu
2201
2202 @node @code{--enable-@var{prog}} @code{--disable-@var{prog}}
2203 @subsection @code{--enable-@var{prog}}, @code{--disable-@var{prog}}
2204
2205 @vindex --enable-@var{prog}
2206 @vindex --disable-@var{prog}
2207 Do or do not build and install the program(s) of module @code{@var{prog}}.
2208
2209 @node @code{--disable-all-pkgs}
2210 @subsection @code{--disable-all-pkgs}
2211
2212 @vindex --disable-all-pkgs
2213 Do not build any program modules by default---only those explicitly
2214 enabled. This is useful when one wants to work on only a single
2215 program, which is specified with an additional @code{--enable} option,
2216 e.g., @code{--enable-dvipdfm-x}. It's still simplest to check out and
2217 configure the whole source tree, but at least only the program you are
2218 interested in, and its dependencies, are built. @xref{Build one package}.
2219
2220 Without this option, all modules are built except those that are
2221 explicitly disabled or specify @code{disable} in their
2222 @file{ac/withenable.ac} fragment.
2223
2224 @node Configure options for @file{texk/web2c}
2225 @subsection Configure options for @file{texk/web2c}
2226
2227 @cindex @code{configure} options, for @code{web2c}
2228
2229 @vindex --with-banner-add=@var{str}
2230 @noindent @code{--with-banner-add=@var{str}}@*Add @code{@var{str}} to the
2231 default version string (which is `@code{TeX Live @var{year}}' or
2232 `@code{Web2C @var{year}}') appended to banner lines. This is ignored
2233 for a native TL build, but distro builds should specify, e.g.,
2234 @code{/@var{SomeDistro}}.
2235
2236 @vindex --with-editor=@var{cmd}
2237 @noindent @code{--with-editor=@var{cmd}}@*Specify the command
2238 @code{@var{cmd}} to invoke from the @code{e} option of @TeX{} and friends,
2239 replacing the default @code{vi +%d '%s'} for Unix or @code{texworks
2240 --position=%d "%s"} for Windows.
2241
2242 @vindex --with-fontconfig-includes=@var{dir}
2243 @vindex --with-fontconfig-libdir=@var{dir}
2244 @noindent @code{--with-fontconfig-includes=@var{dir}},
2245 @code{--with-fontconfig-libdir=@var{dir}}@*Building Xe@TeX{} on
2246 non-Mac systems requires the @code{fontconfig} library headers and
2247 code. If one or both of these options are given, the required flags
2248 are derived from them; otherwise, they are determined via
2249 @file{pkg-config} (if present).
2250
2251 @cindex X toolkit
2252 @pindex libXt
2253 @pindex Xlib
2254 @noindent @code{--with-mf-x-toolkit}@*Use the X toolkit (@file{libXt}) for
2255 Metafont (the default is to use the lowest-level @file{Xlib} support;
2256 it seems this has the best chance of working across X installations
2257 nowadays).
2258
2259 @vindex --disable-dump-share
2260 @cindex LittleEndian architectures
2261 @noindent @code{--disable-dump-share}@*Make the @code{fmt}/@code{base}
2262 dump files architecture dependent (somewhat faster on LittleEndian
2263 architectures).
2264
2265 @vindex --disable-ipc
2266 @cindex interprocess communication
2267 @noindent @code{--disable-ipc}@*Disable @TeX{}'s @code{--ipc} option.
2268
2269 @vindex --disable-mf-nowin
2270 @pindex mf-nowin
2271 @noindent @code{--disable-mf-nowin}@*Do not build a separate
2272 non-graphically-capable Metafont (@file{mf-nowin}).
2273
2274 @vindex --disable-tex
2275 @vindex --enable-etex
2276 @pindex web2c.ac
2277 @noindent @code{--disable-tex}, @code{--enable-etex}, @dots{}@*Do not or
2278 do build the various @TeX{}, Metafont, and MetaPost engines (defaults are
2279 defined in the fragment @file{texk/web2c/ac/web2c.ac}).
2280
2281 @vindex --disable-web-progs
2282 @noindent @code{--disable-web-progs}@*Do not build the original WEB programs
2283 @file{bibtex}, @dots{}, @file{weave}. Useful if, e.g., you only want
2284 to (re)build some engines.
2285
2286 @vindex --enable-auto-core
2287 @cindex preloaded binaries
2288 @noindent @code{--enable-auto-core}@*This option causes @TeX{} and Metafont
2289 to produce a core dump when a particular hacky filename is
2290 encountered, for use in creating preloaded binaries. This is rarely
2291 done nowadays.
2292
2293 @vindex --enable-libtool-hack
2294 @pindex libtool@r{, hack for avoiding excessive linking}
2295 @pindex libfontconfig@r{, hack for avoiding linking dependencies}
2296 @pindex libexpat@r{, dependency of @code{libfontconfig}}
2297 @noindent @code{--enable-libtool-hack}@*
2298 If enabled (which is the default for all platforms), prevents
2299 @code{libtool} from linking explicitly with dependencies of
2300 @file{libfontconfig} such as @file{libexpat}.
2301
2302 @vindex --enable-*win @r{for Metafont window support}
2303 @noindent @code{--enable-*win}@*Include various types of non-X window
2304 support for Metafont (EPSF output, @code{mftalk}, old graphics
2305 terminals, @dots{}).
2306
2307 @vindex --enable-tex-synctex
2308 @vindex --disable-etex-synctex
2309 @cindex synctex
2310 @noindent @code{--enable-tex-synctex}, @code{--disable-etex-synctex},
2311 @dots{}@*Build the @TeX{} engines with or without @code{SyncTeX}
2312 support; ignored for a native @TL{} build. Defaults are defined in
2313 @file{texk/web2c/ac/web2c.ac} (@pxref{Autoconf macros}).
2314
2315 @vindex --disable-synctex
2316 @cindex synctex
2317 @noindent @code{--disable-synctex}
2318 @*Do not build the @code{SyncTeX} library and tool.
2319
2320 @node Configure options for @file{texk/bibtex-x}
2321 @subsection Configure options for @file{texk/bibtex-x}
2322
2323 @cindex @code{configure} options, for @code{bibtex-x}
2324 @pindex bibtex8
2325 @pindex bibtexu
2326 @pindex bibtex-x
2327 The programs @code{bibtex8} and @code{bibtexu} have been merged into the
2328 module @code{bibtex-x} (extended Bib@TeX{}).
2329
2330 @vindex --disable-bibtex8
2331 @noindent @code{--disable-bibtex8}@*Do not build the @file{bibtex8} program.
2332
2333 @vindex --disable-bibtexu
2334 @noindent @code{--disable-bibtexu}@*Do not build the @file{bibtexu} program
2335 (building @file{bibtexu} requires @code{ICU} libraries).
2336
2337 @node Configure options for @file{texk/dvipdfm-x}
2338 @subsection Configure options for @file{texk/dvipdfm-x}
2339
2340 @cindex @code{configure} options, for @code{dvipdfm-x}
2341 @pindex dvipdfm-x
2342 @pindex dvipdfmx
2343 @pindex xdvipdfmx
2344
2345 The former modules @code{dvipdfmx} (extended DVI to PDF converter) and
2346 @code{xdvipdfmx} (the same, as used by Xe@TeX{}) have been merged into
2347 @code{dvipdfm-x} at the source level. Two separate binaries are still
2348 created by default. In addition, @file{dvipdfm} is created as a
2349 symlink to @file{dvipdfmx}, with backward-compatible (very slightly
2350 different) behavior.
2351
2352 @vindex --disable-dvipdfmx
2353 @noindent @code{--disable-dvipdfmx}@*Do not build the @file{dvipdfmx}
2354 program or make the @file{dvipdfm} symlink.
2355
2356 @vindex --disable-xdvipdfmx
2357 @noindent @code{--disable-xdvipdfmx}@*Do not build the @file{xdvipdfmx}
2358 program.
2359
2360 @node Configure options for @file{texk/dvisvgm}
2361 @subsection Configure options for @file{texk/dvisvgm}
2362
2363 @cindex @code{configure} options, for @file{dvisvgm}
2364 @pindex dvisvgm
2365
2366 @vindex --with-system-libgs
2367 @noindent @code{--with-system-libgs}@*Build @file{dvisvgm} using installed
2368 Ghostscript (@code{gs}) headers and library (not allowed for a native
2369 TL build). The default is to load the @code{gs} library at runtime if
2370 possible, else to disable support for PostScript specials.
2371
2372 @vindex --without-libgs
2373 @noindent @code{--without-libgs}@*Build @file{dvisvgm} without PostScript
2374 support at all. Because the dynamic loading just mentioned defeats all
2375 attempts at static linking, the result can crash due to library
2376 incompatibilities, e.g., on CentOS 5.
2377
2378 @vindex --with-libgs-includes@r{,} -libdir
2379 @noindent @code{--with-libgs-includes=@var{dir}},
2380 @code{--with-libgs-libdir=@var{dir}}@*Specify non-standard locations
2381 of the Ghostscript headers and library.
2382
2383 @node Configure options for @file{texk/texlive}
2384 @subsection Configure options for @file{texk/texlive}
2385
2386 @cindex @code{configure} options, for @file{texk/texlive}
2387 @vindex --disable-linked-scripts
2388 @noindent @code{--disable-linked-scripts}@*Do not install the ``linked
2389 scripts'' (@pxref{Linked scripts}), except for the TL scripts required
2390 to run @code{texlinks}.
2391
2392 @node Configure options for @file{texk/xdvik}
2393 @subsection Configure options for @file{texk/xdvik}
2394
2395 @cindex @code{configure} options, for @file{xdvik}
2396 @pindex xdvik
2397
2398 @vindex --with-gs=@var{filename}
2399 @cindex Ghostscript location for Xdvik
2400 @noindent @code{--with-gs=@var{filename}}@*Hardwire the location of Ghostscript
2401 (@file{gs}) as called by Xdvik.
2402
2403 @vindex --with-xdvi-x-toolkit=@var{kit}
2404 @pindex motif
2405 @pindex xaw
2406 @noindent @code{--with-xdvi-x-toolkit=@var{kit}}@*Use toolkit
2407 @code{@var{kit}} for @file{xdvik}, one of: @code{motif xaw xaw3d
2408 neXtaw}. The default is @code{motif} if available, else @code{xaw}.
2409
2410 @vindex --enable-xi2-scrolling
2411 @pindex XInput
2412 @pindex scrolling, smooth
2413 @noindent @code{--enable-xi2-scrolling}@*Use XInput 2.1 ``smooth scrolling''
2414 if available (default: yes, except for a native TL build).
2415
2416 @node Configure options for @file{utils/xindy}
2417 @subsection Configure options for @file{utils/xindy}
2418
2419 @cindex @code{configure} options, for @file{xindy}
2420 @pindex xindy
2421
2422 @vindex --enable-xindy-rules
2423 @noindent @code{--enable-xindy-rules}@*Build and install @code{xindy} rules
2424 (default: yes, except for a native TL build).
2425
2426 @vindex --enable-xindy-docs
2427 @noindent @code{--enable-xindy-docs}@*Build and install @code{xindy}
2428 documentation (default: yes, except for a native TL build).
2429
2430 @vindex --with-clisp-runtime=@var{filename}
2431 @pindex lisp.run@r{,} lisp.exe
2432 @cindex CLISP
2433 @noindent @code{--with-clisp-runtime=@var{filename}}@*Specifies the
2434 full path for the Clisp runtime file (@file{lisp.run} or
2435 @file{lisp.exe}) to be installed. When specified as @code{default}
2436 (the default for a native TL build) the path is determined by the
2437 Clisp executable; the value @code{system} (not allowed for a native TL
2438 build, but the default otherwise) indicates that @file{xindy} will use
2439 the installed version of @file{clisp} (which must be identical to the
2440 one used to build @file{xindy}).
2441
2442 @node Library-specific configure options
2443 @section Library-specific configure options
2444
2445 @cindex library-specific @code{configure} options
2446 @cindex @code{configure} options, library-specific
2447 Here are (some of) the library-specific @code{configure} options,
2448 starting with this generic one:
2449
2450 @vindex --with-system-@var{lib}
2451 @noindent @code{--with-system-@var{lib}}
2452
2453 Use an installed (system) version of the library @code{@var{lib}};
2454 this option exists for most libraries, but is not allowed for a native
2455 TL build. Using a system version implies also using the system
2456 versions of all libraries that @var{lib} depends on.
2457
2458 @vindex --with-@var{lib}-includes=@var{dir}@r{,} -libdir
2459 For many libraries @code{--with-@var{lib}-includes=@var{dir}} and
2460 @code{--with-@var{lib}-libdir=@var{dir}} can specify non-standard
2461 search locations; others use @file{pkg-config} or similar to determine
2462 the required flags.
2463
2464 The top-level @file{configure} script performs a consistency check for all
2465 required system libraries and bails out if tests fail.
2466
2467 @menu
2468 * Configure options for @code{kpathsea}::
2469 @end menu
2470
2471 @node Configure options for @code{kpathsea}
2472 @subsection Configure options for @code{kpathsea}
2473
2474 @cindex @code{configure} options, for @code{kpathsea}
2475
2476 @noindent @code{--enable-@var{cmd}-default},
2477 @code{--disable-@var{cmd}-default}@*Determine the compile time default
2478 for whether or not to run @var{cmd}, which is one of:
2479 @table @code
2480 @item mkocp
2481 (Omega compiled translation process file)
2482 @item mkofm
2483 (Omega font metrics file)
2484 @item mktexfmt
2485 (format/base dump file)
2486 @item mktexmf
2487 (Metafont source)
2488 @item mktexpk
2489 (PK bitmap font)
2490 @item mktextex
2491 (@TeX{} source)
2492 @item mktextfm
2493 (TFM file)
2494 @end table
2495
2496 @noindent to generate the specified type of file dynamically.
2497 The default can be overridden by the user in any case
2498 (@pxref{@code{kpathsea} library}).
2499
2500 @node Variables for configure
2501 @section Variables for configure
2502
2503 @cindex variables for @code{configure}
2504 @cindex @code{configure} variables
2505
2506 The values for these variables can be specified as @code{configure}
2507 arguments of the form @code{@var{VAR}=@var{value}}. They can also be
2508 defined in the environment, but that might not work for cross
2509 compilations.
2510
2511 @vtable @code
2512 @item CC
2513 @itemx CXX
2514 @itemx CPPFLAGS
2515 And plenty more. As usual with Autoconf, these variables specify the
2516 name (or full path) of compilers, preprocessor flags, and similar.
2517 @xref{Preset Output Variables,,, autoconf, GNU Autoconf}.
2518
2519 @item CLISP
2520 @pindex clisp
2521 Name (or full path) of the @file{clisp} executable, used to build
2522 @code{xindy}.
2523
2524 @item FT2_CONFIG
2525 @itemx ICU_CONFIG
2526 @itemx PKG_CONFIG
2527 @pindex freetype-config
2528 @pindex icu-config
2529 @pindex libfreetype
2530 @cindex ICU libraries
2531 These specify the name (or path) for the @file{freetype-config},
2532 @file{icu-config}, and @file{pkg-config} commands used to determine the
2533 flags required for system versions of @file{libfreetype}, the ICU
2534 libraries, and other libraries, respectively.
2535
2536 @item KPSEWHICH
2537 @pindex kpsewhich
2538 Name (or path) of an installed @file{kpsewhich} binary, used by
2539 @code{make check} to determine the location of, e.g.,
2540 @file{cmbx10.tfm}.
2541
2542 @item MAKE
2543 @itemx SED
2544 And more. Name (or path) of the @code{make}, @code{sed}, and similar
2545 programs; used at the top level and propagated to all subdirectories.
2546
2547 @item PERL
2548 @itemx LATEX
2549 @itemx PDFLATEX
2550 Name (or full path) for the @file{perl}, @file{latex}, and @file{pdflatex}
2551 commands used, e.g., to build the @code{xindy} documentation.
2552
2553 @end vtable
2554
2555 @node Coding conventions
2556 @chapter Coding conventions
2557
2558 @cindex coding conventions
2559 @cindex conventions, coding
2560
2561 Ideally, building all of @TL{} with
2562 @code{--enable-compiler-warnings=max} should produce no (GCC) compiler
2563 warnings at all. In spite of considerable efforts into that direction
2564 we are still far from that goal and there are reasons that we may
2565 never fully reach it. Below are some rules about declarations of
2566 functions or variables and the use of @code{const}. These rules
2567 should be applied to the code maintained in the @TL{} tree and for
2568 other packages whose maintainers are willing to accept patches.
2569
2570 @menu
2571 * Declarations and definitions::
2572 * Const::
2573 @end menu
2574
2575 @node Declarations and definitions
2576 @section Declarations and definitions
2577
2578 @cindex declarations and definitions, in source code
2579 @cindex source code declarations
2580 @cindex ANSI C
2581 @cindex declarations before statements, avoiding
2582 @cindex C, ANSI, required
2583 @cindex C99, avoided
2584
2585 @subsubheading C standards
2586
2587 The @TL{} build system no longer supports pre-ANSI C compilers. Thus
2588 all function prototypes and definitions must conform to the ANSI C
2589 standard (including @code{void} in the declaration of C functions with
2590 no parameters). On the other hand, TL is built for a wide variety of
2591 systems, not all of which support the C99 standard. Therefore using
2592 C99 features should be avoided if that can easily be done. In
2593 particular, C code must not contain declarations after statements or
2594 C++-style comments.
2595
2596 @pindex chktex
2597 @findex stpcpy
2598 If some C99 (or later) constructs must be used, the module should
2599 verify that they are available and otherwise provide an alternative.
2600 For example, the module @file{texk/chktex} uses the C99 function
2601 @code{stpcpy()} that may or may not be available on a particular
2602 system. It uses @code{AC_CHECK_DECLS([stpcpy])} in
2603 @file{configure.ac} to test this, and provides a perhaps
2604 less efficient alternative (in the file @file{Utility.h}):
2605
2606 @example
2607 #if !(defined HAVE_DECL_STPCPY && HAVE_DECL_STPCPY)
2608 static inline char *stpcpy(char *dest, const char *src)
2609 @{
2610 return strcpy(dest, src) + strlen(src);
2611 @}
2612 #endif
2613 @end example
2614
2615 @subsubheading Static functions
2616
2617 @cindex @code{static} functions
2618 Functions used in only one file should be declared @code{static}; they
2619 require no prototype except in forward declarations.
2620
2621 @subsubheading Extern functions
2622
2623 @cindex @code{extern} functions
2624 Functions not declared @code{static}, usually because they are used in
2625 several files, require an (@code{extern}) prototype in exactly one
2626 header file, which is included in the file defining the function and
2627 in all files using that function---this is the only way to guarantee
2628 consistency between definition and use. There should be no
2629 @code{extern} declarations sprinkled throughout the C code (with or
2630 without comments as to where that function is defined).
2631
2632 @subsubheading Variable declarations
2633
2634 @cindex variable declarations, in source code
2635 The declaration of global variables follows analogous rules: they are
2636 either declared @code{static} if used in only one file or declared
2637 @code{extern} in exactly one header and instantiated in exactly one
2638 file.
2639
2640 @node Const
2641 @section Const
2642
2643 @cindex @code{const}
2644
2645 The @code{const} feature of C is valuable, but easy to mis-use.
2646
2647 @subsubheading Function parameters
2648
2649 Ideally, a function parameter not modified by the function should be
2650 declared as @code{const}. This is important in particular for strings
2651 (@code{char*}) because the actual arguments are often string literals.
2652 It is perfectly legitimate and safe to use a type @code{char*} value
2653 for a type @code{const char*} variable (in an assignment, as
2654 initializer, as function argument, or as return value). It is equally
2655 safe to use a type @code{char**} value for a type @code{const
2656 char*const*} variable, but not for a type @code{const char**} variable
2657 since that might cause modification of a quantity supposed to be
2658 constant.
2659
2660 @cindex X11 headers, and @code{const}
2661 @cindex @code{libfreetype}, and @code{const}
2662 Getting all @code{const} qualifiers right can get quite involved but
2663 can almost always be done. There are only a couple notable
2664 exceptions: the X11 headers are full of declarations that ought to use
2665 @code{const} but do not; at one time, @file{libfreetype} also did not
2666 fully specify @code{const}, but this has not been checked recently.
2667
2668 @subsubheading What must be avoided with @code{const}
2669
2670 @cindex warning, discards qualifiers
2671 @cindex discards qualifiers warning
2672 The GCC compiler warnings ``assignment discards qualifiers@dots{}''
2673 and analogous warnings for ``initialization'', ``passing arg'', or
2674 ``return'' must be strenuously avoided in our own code. The only
2675 exception is when they are caused by X11 declarations or other third
2676 party code.
2677
2678 @subsubheading What should be avoided with @code{const}
2679
2680 @cindex type cast from const, avoiding
2681 A type cast, e.g., from @code{const char*} to @code{char*} does not
2682 solve any problems; depending on warning options, it may only hide
2683 them. Therefore such casts should be avoided whenever possible and
2684 otherwise must be carefully analyzed to make sure that they cannot
2685 cause the modification of quantities supposed to be constant.
2686
2687 @node Continuous integration
2688 @chapter Continuous integration
2689
2690 @cindex continuous integration
2691 @cindex Travis-CI
2692
2693 The @TL{} sources are subjected to continuous integration testing on
2694 Travis-CI (@url{https://travis-ci.org/TeX-Live/texlive-source}) via a
2695 git-svn mirror of the sources that is pushed to Github
2696 (@url{https://github.com/TeX-Live/texlive-source}). The git-svn mirror
2697 is updated (currently) at 30 minute intervals, and only the last
2698 commit pushed is tested on Travis-CI.
2699
2700 @menu
2701 * Transfer from Subversion to Github::
2702 * Automatic update of the Git mirror::
2703 * CI testing on Travis-CI::
2704 * Releases on Github::
2705 @end menu
2706
2707 @node Transfer from Subversion to Github
2708 @section Transfer from Subversion to Github
2709
2710 @pindex git-svn
2711 The git-svn program (@url{https://git-scm.com/docs/git-svn}) is used
2712 to check out the subtree @code{Build/source} of the canonical
2713 Subversion repository. The author index file used is not maintained
2714 in either Git or Subversion but can be provided on request.
2715
2716 @c TODO what should we do here with the author index file? It contains a
2717 @c mapping from subversion names to name/email as shown in git.
2718
2719 The initial checkout was done by invoking
2720 @example
2721 git svn --authors-file usermap clone \
2722 svn://@var{user}@@tug.org/texlive/trunk/Build/source
2723 @end example
2724
2725 @noindent where the @code{usermap} file maps Subversion user names to
2726 name and emails of the authors. Anonymous checkout is also possible:
2727 @example
2728 git svn --authors-file usermap clone \
2729 svn://tug.org/texlive/trunk/Build/source
2730 @end example
2731
2732 In the following, we will use @emph{admin} to refer to a user who has
2733 read/write access to the @TL{} subversion repository, and is also an
2734 administrator of the `@code{TeX-Live}' team at Github. The above
2735 initial checkout has been carried out by @emph{admin} on the server
2736 @code{texlive.info}.
2737
2738 On Github, a new git repository named @code{texlive-source} was
2739 created by @emph{admin} within the @code{TeX-Live} ``organization''
2740 (@url{https://github.com/TeX-Live}). The remote was added to the
2741 checkout with @code{git remote add origin
2742 git@@github.com:TeX-Live/texlive-source.git}.
2743
2744 To automate the update on Github, a new ssh key was generated and
2745 added to the @code{texlive-source} repository on Github as deployment
2746 key. Thus, pushes using this key can only go to the
2747 @code{texlive-source} repository and not anywhere else.
2748
2749 The usage of @code{git-svn} requires a strict discipline to keep a
2750 linear history in the master branch. Since we are aiming at a pure
2751 mirror facility on Github, we have decided to further restrict the
2752 @code{master} branch of the @code{texlive-source} repository on Github
2753 to changes by @emph{admin}.
2754
2755 This setup allows other developers to branch off @code{master} and
2756 push their branches to the Github repository, but all updates need to
2757 come from the local @code{master} (not the one on Github) to
2758 Subversion, back to @code{master} on @code{texlive.info}, and from
2759 there to Github.
2760
2761 @node Automatic update of the Git mirror
2762 @section Automatic update of the Git mirror
2763
2764 @emph{admin} has installed a cron job on @code{texlive.info} running
2765 every 30 minute which essentially runs @code{git svn rebase} and
2766 @code{git push} in the @code{master} branch of the checkout. The first
2767 command fetches the changes from the Subversion repository and updates
2768 the @code{master} branch with them, and the second pushes changes (if
2769 any) to Github.
2770
2771 @node CI testing on Travis-CI
2772 @section CI testing on Travis-CI
2773
2774 @pindex travis.yml
2775 The @code{source} tree of @TL{} contains a top-level file
2776 @code{.travis.yml} which controls the automatic testing on
2777 Travis-CI. @emph{admin} has registered with Travis-CI and allowed
2778 access to the Github's @code{TeX-Live} organization's
2779 @code{texlive-source} repository. The default settings are to build
2780 the last commit of each push. No further action is necessary on
2781 Travis-CI.
2782
2783 If changes have been pushed via the cron job above, Travis-CI will
2784 automatically checkout the last pushed commit and try building it.
2785
2786 @node Releases on Github
2787 @section Releases on Github
2788
2789 Given a git checkout of @code{texlive-source}:
2790
2791 @example
2792 git pull
2793 git tag build-svnNNNN
2794 git push --tags
2795 @end example
2796
2797 @noindent and the result will appear at
2798 @url{https://github.com/TeX-Live/texlive-source/releases}.
2799 Releases can also be made manually from that web page (see
2800 @code{tl-update-bindir} for hints).
2801
2802 @c made from pod doc.
2803 @include tlbuild-incl/install-tl.texi
2804 @include tlbuild-incl/tlmgr.texi
2805
2806 @node Index
2807 @unnumbered Index
2808
2809 @printindex cp
2810
2811 @bye