beta-0.89.2
[luatex.git] / source / doc / tlbuild.texi
blobea5c854460e28796cf86c7f00be63ab147d2df34
1 \input texinfo
2 @setfilename tlbuild.info
4 @set version 2016
5 @set month-year February 2016
7 @set mytitle Building @TeX{} Live (@value{version})
8 @settitle @value{mytitle}
10 @macro TL
11 @TeX{} Live
12 @end macro
14 @copying
15 This file documents the @TL{} build system and more.
17 Copyright @copyright{} 2016 Karl Berry.@*
18 Copyright @copyright{} 2013, 2014, 2015 Karl Berry & Peter Breitenlohner.
20 Permission is granted to make and distribute verbatim copies of this
21 manual provided the copyright notice and this permission notice are
22 preserved on all copies.
24 @ignore
25 Permission is granted to process this file through TeX and print the
26 results, provided the printed document carries a copying permission
27 notice identical to this one except for the removal of this paragraph
28 (this paragraph not being relevant to the printed manual).
29 @end ignore
31 Permission is granted to copy and distribute modified versions of this
32 manual under the conditions for verbatim copying, provided that the
33 entire resulting derived work is distributed under the terms of a
34 permission notice identical to this one.
36 Permission is granted to copy and distribute translations of this manual
37 into another language, under the above conditions for modified versions,
38 except that this permission notice may be stated in a translation
39 approved by the @TeX{} Users Group.
40 @end copying
42 @c Put everything in one index (arbitrarily chosen to be the concept index).
43 @syncodeindex fn cp
44 @syncodeindex ky cp
45 @syncodeindex pg cp
46 @syncodeindex tp cp
47 @syncodeindex vr cp
49 @dircategory TeX
50 @direntry
51 * TLbuild: (tlbuild).           TeX Live configuration and development.
52 @end direntry
54 @titlepage
55 @title @value{mytitle}
56 @subtitle @value{version} release
57 @subtitle @value{month-year}
58 @author Peter Breitenlohner
59 @author Karl Berry
60 @author @url{http://tug.org/texlive}
62 @page
63 @vskip 0pt plus 1filll
64 @insertcopying
65 @end titlepage
67 @shortcontents
68 @contents
70 @ifnottex
71 @node Top
72 @top @value{mytitle}
74 For an overview of this manual, @pxref{Introduction}.
76 @menu
77 * Introduction::                About this manual.
78 * Overview of build system::    The @TL{} build system.
79 * Prerequisites::               Requirements for building @TL{}.
80 * Building::                    The overall build process.
81 * Installing::                  How and where installation happens (or not).
82 * Layout and infrastructure::   Autoconf macros, etc., in detail.
83 * Configure options::           List of all configure options.
84 * Cross compilation::           Building on host X for target Y.
85 * Coding conventions::          Conventions to follow.
86 * install-tl::                  The @TL{} installer.
87 * tlmgr::                       The native @TL{} package manager.
88 * Index::                       General index.
89 @end menu
90 @end ifnottex
93 @node Introduction
94 @chapter Introduction
96 @cindex introduction
98 This manual (dated @value{month-year}) corresponds to the @TL{}
99 @value{version} release.
101 This manual is aimed at system installers and programmers, and focuses
102 on how to configure, build, and develop the @TL{} (TL) sources.  It is
103 also available as plain text files in the source tree:
104 @file{source/README.*}.
106 The @file{source/README} file in the TL source tree provides the
107 maximally-terse information for doing a build, and portability
108 information for different systems, along with
109 @file{source/doc/README.solaris}.
111 For information on acquiring the TL sources, see
112 @url{http://tug.org/texlive/svn}.
114 This manual does not duplicate the (primarily user-level) information
115 found in other TL documentation resources, such as:
117 @itemize
118 @item The @TL{} web pages: @url{http://tug.org/texlive}.
120 @item The web page with an overview of how to build the binaries which 
121 are distributed with @TL{}: @url{http://tug.org/texlive/build.html}.
123 @item The @TL{} user manual: @url{http://tug.org/texlive/doc.html}, or
124 run @code{texdoc texlive}.
126 @item Other @TeX{}-related Texinfo manuals (@pxref{,,,web2c, Web2c},
127 @ref{,,,kpathsea, Kpathsea}, etc.):
128 @url{http://tug.org/texinfohtml/}, or check the @samp{TeX} category in
129 the GNU Info system.
131 @item Package documentation:
132 @url{http://tug.org/texlive/Contents/live/doc.html}, or the
133 @file{doc.html} file at the top level of the installed TL.
135 @end itemize
137 As an exception, the full documentation for @code{install-tl} and
138 @code{tlmgr} is included here, just because it is convenient to do so.
139 The same text is available online (linked from
140 @url{http://tug.org/texlive/doc.html}, or by invoking the program with
141 @samp{--help} (or look at the end of the source file).
144 @c The first word of the chapter/section title here is used to
145 @c construct the README.* filenames, so choose well.  (Or hack the script.)
147 @node Overview of build system
148 @chapter Overview of build system
150 @cindex build system, design of
152 @cindex Autoconf
153 @cindex Automake
154 @cindex Libtool
155 @cindex tests, running
156 The @TL{} build system was redesigned in 2009, consistently using
157 Autoconf, Automake, and Libtool.  Thus@*@ @ @ @code{configure &&
158 make && make check && make install}@*or the basically-equivalent
159 top-level @code{Build} script suffice to build and install the TL
160 programs.  The @code{make check} clause performs various tests of the
161 generated programs---not strictly required but strongly recommended.
162 Running @code{configure --help} will display a comprehensive list of
163 all @code{configure} options.
165 The main components of the TL build system are:
167 @table @file
168 @item libs/@var{lib}
169 Generic libraries.
171 @item texk/@var{lib}
172 @TeX{}-specific libraries in subdirectories, notably
173 @var{lib}=@code{kpathsea}.  (The other one is @file{texk/ptexenc}.)
175 @item texk/@var{prog}
176 @TeX{}-specific programs (that use Kpathsea).
178 @item utils/@var{prog}
179 Other programs (that don't use Kpathsea).
181 @end table
183 @pindex kpse-pkgs.m4
184 The primary design goal of the build system is modularity.  Each
185 program and library module (or package) specifies its own requirements
186 and properties, such as required libraries, whether an installed
187 (system) version of a library can be used, @code{configure} options to
188 be seen at the top-level, and more.  An explicit list of all available
189 modules is kept in only one, central, place (@file{m4/kpse-pkgs.m4}).
191 A second, related goal is to configure and build each library before
192 configuring any other (program or library) module which uses that
193 library.  This allows checking for properties and features of a
194 library built as part of the TL tree in much the same way as for a
195 system version of that library.
197 All generic libraries and several programs are maintained
198 independently.  The corresponding modules use (most of) the
199 distributed source tree and document any modifications of that source.
201 All this is for the sake of simplifying both upgrading of modules
202 maintained independently and integrating new modules into the
203 TL build system.  (Not to say that either task is trivial.)
206 @node Prerequisites
207 @chapter Prerequisites
209 @cindex prerequisites for building
210 @cindex requirements for building
212 @cindex compilers, C and C++
213 Overall, building the @TL{} programs, when using all libraries from
214 the TL source tree, requires only C and C++ compilers and GNU
215 @code{make}.  (If @code{make} from your @code{PATH} is not GNU make,
216 you can set @code{MAKE} in the environment to whatever is necessary.)
218 @cindex GNU @code{make}, required
219 @cindex @code{gmake}, required
220 @cindex FreeType
221 Indeed, GNU @code{make} is required only because of some
222 third-party libraries, notably FreeType; all the TL-maintained
223 directories (and Automake/Autoconf output in general) should work with
224 any reasonable @code{make}.
226 However, a few programs in the tree have additional requirements:
228 @table @file
229 @item web2c
230 @cindex @code{perl}, required by @code{web2c}, etc.
231 requires @code{perl} for some tests run by @code{make check}.
233 @item xdvik
234 @itemx xpdfopen
235 @cindex X11, required by X clients
236 require X11 headers and libraries, often in ``development'' packages
237 that are not installed by default.
239 @item xetex
240 @cindex @code{fontconfig} library, required by @code{xetex}
241 requires @file{fontconfig} (again both headers and library).
243 @item xindy
244 @cindex @code{clisp}, required by @code{xindy}
245 @cindex @code{ffcall}, required by @code{xindy}
246 requires GNU @code{clisp} and in addition @code{perl}, @code{latex},
247 and @code{pdflatex} to build the rules and/or documentation.
249 @end table
251 @noindent Lacking the required tools, building these
252 programs must avoided, e.g.,@*
253 @code{configure --without-x --disable-xetex --disable-xindy}
255 Modifying source files induces more requirements, as one might expect:
257 @itemize
258 @item
259 Modification of any @code{.y} or @code{.l} source files requires
260 @file{bison} or @file{flex} to updatete the corresponding C sources.
262 @item
263 Modification of the sources for @code{.info} files requires
264 @code{makeinfo}.
266 @item
267 Modification of any part of the build system (M4 macros,
268 @file{configure.ac}, @file{Makefile.am}, or their fragments) requires
269 GNU M4, GNU Autoconf, GNU Automake, and GNU Libtool to update the
270 generated files.  @xref{Build system tools}.
272 @end itemize
274 If you haven't modified any source files, and infrastructure tools
275 such as @code{autoconf} or @code{makeinfo} are still being run, check
276 your timestamps---notably, @code{use-commit-times} must be set to
277 @code{yes} in your Subversion configuration (@pxref{Build system
278 tools}).  Barring buggy commits, no infrastructure tools are needed to
279 do a normal build.
282 @node Building
283 @chapter Building
285 @cindex building
286 @cindex overall build process
288 @pindex Build @r{script}
289 The top-level @file{Build} script is intended to simplify building the
290 binaries distributed with @TL{} itself---we call this the ``native''
291 TL build.  It configures and makes everything in a subdirectory of the
292 main build tree (default @file{Work/}), installs everything in an
293 other subdirectory (default @file{inst/}), and finally runs @code{make
294 check}.  The exact directory and command names can be specified via
295 environment variables and a few leading options.  All remaining
296 arguments (assignments or options) are passed to the @file{configure}
297 script.  Please take a look at the script itself for more information;
298 it is not complicated.
300 @cindex source directory building, not supported
301 @cindex build directory, required
302 An alternative, and the one we will mainly discuss here, is to run
303 @code{configure} and @code{make} oneself in a suitable empty
304 subdirectory.  Building in the source directory itself is not
305 supported (sorry).
307 @menu
308 * Build iteration::     What @code{configure} and @code{make} do.
309 * Build problems::      If the build fails.
310 * Build in parallel::   Simultaneous @code{make} processes.
311 * Build distribution::  Making a distribution tarball.
312 * Build one package::   Example of working on just one program.
313 @end menu
316 @node Build iteration
317 @section Build iteration
319 @cindex build iteration
320 @cindex iteration through sources, by @code{configure} and @code{make}
322 Running the top-level @file{configure} script configures the top level
323 and the subdirectories @file{libs}, @file{utils}, and @file{texk}.
324 Running @code{make} at the top-level first iterates over all
325 @TeX{}-specific libraries, and then runs @code{make} in
326 @file{libs}, @file{utils}, and @file{texk} to iterate over all generic
327 libraries, utility programs, and @TeX{}-specific programs.  These
328 iterations consist of two steps:
330 @enumerate
331 @item
332 For each library or program module not yet configured, run
333 @code{configure}, adding the configure option @code{--disable-build}
334 if the module need not be built, otherwise running @code{make all}.
336 @item
337 For each library or program module that must be built, run
338 @code{make} for the selected target(s): @code{default} or
339 @code{all} to (re-)build, @code{check} to run tests, @code{install},
340 etc.
342 @end enumerate
344 Running the top-level @code{make} a second time iterates again over
345 all the library and program modules, but finds (should find) nothing
346 to be done unless some source files have been modified.
349 @node Build problems
350 @section Build problems
352 @cindex build problems
353 @cindex problems with build
354 @cindex failure to build
355 @vindex --no-clean Build @r{option}
356 If configuring or building a module fails, you should first find and fix the
357 problem, then perhaps remove the subdirectory for that module from the build
358 tree, and finally rerun the top-level @code{make} (or @file{Build} with
359 @code{--no-clean} as its first argument).
362 @node Build in parallel
363 @section Build in parallel
365 @cindex building in parallel
366 @cindex parallel build
367 @cindex cache for @code{configure}
369 @cindex dependencies, with several output files
370 @vindex -j make @r{option}
371 The TL build system carefully formulates dependencies as well as
372 @code{make} rules when a tool (such as @code{tangle}, @code{ctangle},
373 or @code{convert}) creates several output files.  This allows for
374 parallel builds (@code{make -j @var{n}} with @math{@var{n}>1} or even
375 @code{make -j}) that can considerably speed up the TL build.
377 @cindex cache file, for @code{configure}
378 @vindex -C configure @r{option}
379 Incidentally, a noticeable speed-up can also be (independently) gained
380 by using a configure cache file, i.e., with the option @code{-C}
381 (recommended).
384 @node Build distribution
385 @section Build distribution
387 @cindex building a distribution
388 @cindex distribution tarball, making
390 @cindex @code{dist} and @code{distcheck} targets for @code{make}
391 Running @code{make dist} at the top-level creates a tarball
392 @file{tex-live-@var{yyyy}-@var{mm}-@var{dd}.tar.xz} from the TL source
393 tree.  Running @code{make distcheck} also verifies that this tarball
394 suffices to build and install all of TL.
396 This is useful for checking consistency of the source tree and
397 Makefiles, but the result is not a complete or even usable @TeX{}
398 system, since all the support files are lacking; @pxref{Installing}.
401 @node Build one package
402 @section Build one package
404 @cindex build one package
405 @cindex one package, building
407 @vindex --disable-all-packages configure @r{option}
408 @cindex build on demand
409 To build one package, the basic idea is to use the @code{configure}
410 option @code{--disable-all-pkgs} (@pxref{@code{--disable-all-pkgs}}).
411 Then all program and library modules are configured but none are made.
412 However, the @file{Makefile}s still contain all build rules and
413 dependencies and can be invoked to build an individual program or
414 library and causes to first build any required libraries.
416 This ``build-on-demand'' procedure is used, e.g., in the @code{luatex}
417 repository to build Lua@TeX{}, essentially from a subset of the
418 complete @TL{} tree.  Similarly, when, e.g., building the original
419 e-@TeX{} has been disabled (as it is by default), one can run
420 @code{make etex} (or @code{make etex.exe}) in @file{texk/web2c/} to
421 build e-@TeX{} (although there is no comparably simple way to install
422 e-@TeX{}).
424 If you want to work on a single program within the TL sources, this is
425 the recommended way to do it.  Here is an example from start to
426 finish for working on @code{dvipdfm-x}.
428 @example
429 mkdir mydir && cd mydir  # new working directory
431 # Get sources (@url{http://tug.org/texlive/svn})
432 rsync -a --delete --exclude=.svn --exclude=Work \
433       tug.org::tldevsrc/Build/source/ .
435 # Create build directory:
436 mkdir Work && cd Work
438 # Do the configure:
439 ../configure --disable-all-pkgs --enable-dvipdfm-x \
440   -C CFLAGS=-g CXXFLAGS=-g >&outc
442 # Do the make:
443 make >&outm
445 # Test:
446 cd texk/dvipdfm-x
447 make check
448 @end example
450 Then you modify source files in @file{mydir/texk/dvipdfm-x} and rerun
451 @code{make} in @file{mydir/Work/texk/dvipdfm-x} to rebuild.
453 The second line of the @code{configure} invocation shows examples of
454 extra things you likely want to specify if you intend to hack the
455 sources (and not just build binaries): the @code{-C} speeds up
456 @code{configure}, and the @code{CFLAGS} and @code{CXXFLAGS} settings
457 eliminate compiler optimization for debugging purposes.
459 Of course, one should actually look at the output and check that
460 things are working.  There are many @code{configure} options you can
461 tweak as desired; check the output from @code{configure --help}.
463 @cindex size of source tree
464 Finally, the above retrieves the entire TL source tree (some 300mb).
465 It is natural to ask if this is really necessary.  Strictly speaking,
466 the answer is no, but it is vastly more convenient to do so.  If you
467 cut down the source tree, you must also give additional
468 @code{configure} flags to individually disable using system versions
469 of libraries, or the intricacies of the dependencies (such as
470 @code{teckit} requiring @code{zlib}) will have undesired side effects.
471 For an example, see the @code{build-pdftex.sh} script in the
472 @code{pdftex} development sources (@url{http://pdftex.org}), which are
473 indeed a cut-down TL source tree.
476 @node Installing
477 @chapter Installing
479 @cindex installing
480 This section discusses the results of @code{make install} in the
481 source tree.
483 @cindex support files, separate from build
484 @pindex texlive.tlpdb@r{, @TL{} database}
485 @pindex install-tl@r{, @TL{} installer}
486 @pindex plain.tex@r{, not in source tree}
487 The main consideration is that @code{make install} is not enough to
488 make a usable @TeX{} installation.  Beyond the compiled binaries,
489 (thousands of) support files are needed; just as a first example
490 @file{plain.tex} is not in the source tree.
492 These support files are maintained completely independently and are
493 not present in the source tree.  The best basis for dealing with them
494 is the @TL{} (plain text) database in
495 @file{Master/tlpkg/texlive.tlpdb}, and/or the @TL{} installer,
496 @code{install-tl}.  More information is under @file{Master/tlpkg} and
497 at @url{http://tug.org/texlive/distro.html}.
499 @menu
500 * Installation directories::    The prefix, @code{bindir}, etc., directories.
501 * Linked scripts::              Scripts not maintained in the sources.
502 * Distro builds::               Configuring and building for OS distributions.
503 @end menu
506 @node Installation directories
507 @section Installation directories
509 @cindex installation directories
510 @cindex directories, for installation
511 @cindex paths, for installation
513 Running @code{make install} (or @code{make install-strip}) installs
514 executables in @code{@var{bindir}}, libraries in @code{@var{libdir}},
515 headers in @code{@var{includedir}}, general data (including ``linked
516 scripts'', @pxref{Linked scripts}) in
517 @code{@var{datarootdir}/texmf-dist}, man pages in @code{@var{mandir}},
518 and Info files in @code{@var{infodir}}.
520 The values of these directories are determined by @code{configure}
521 and can be specified explictly as options such as
522 @code{--prefix=@var{prefix}} or @code{--bindir=@var{bindir}};
523 otherwise, they are given by their usual Autoconf defaults:
525 @example
526 @var{prefix}                  /usr/local
527 @var{exec_prefix}             @var{prefix}
528 @var{bindir}                  @var{exec_prefix}/bin
529 @var{libdir}                  @var{exec_prefix}/lib
530 @var{includedir}              @var{prefix}/include
531 @var{datarootdir}             @var{prefix}/share    
532 @var{mandir}                  @var{datarootdir}/man
533 @var{infodir}                 @var{datarootdir}/info
534 @end example
536 @noindent except possibly modified as follows:
538 @itemize @bullet
539 @item
540 If the option @code{--enable-multiplatform} is given,
541 @code{/@var{platform}} (i.e., the canonical platform name) is appended
542 to @code{@var{bindir}} and @code{@var{libdir}}.  This is implied for a
543 native TL build.
545 @item
546 @raggedright
547 In a native TL build, @code{@var{datarootdir}} is set to
548 @code{@var{prefix}}, @code{@var{infodir}} is set to
549 @code{@var{prefix}/texmf-dist/doc/info}, and @code{@var{mandir}} to
550 @code{@var{prefix}/texmf-dist/doc/man}, corresponding to the
551 directories used in the TL distribution.
552 @end raggedright
554 @end itemize
556 @noindent The top-level @file{configure} script displays all these
557 installation paths.
559 For the native TL build, the @code{Build} script leaves the binaries
560 in @file{./inst/bin/@var{std-platform-name}}.  The new binaries are
561 not directly usable from that location; they need to be copied to
562 @file{Master/bin/@var{tl-platform}}.  The other files and directories
563 that end up in @file{./inst/} are ignored.
566 @node Linked scripts
567 @section Linked scripts
569 @cindex linked scripts
570 @cindex scripts, linked and not maintained
572 @cindex symlinks, used for scripts
573 @cindex wrapper binary for scripts on Windows
574 @cindex Windows, invoking scripts on
575 Quite a few executables are architecture-independent shell, Perl, or
576 other interpreted scripts, rather than compiled binaries.  A few are
577 maintained as part of the TL source tree, but most are maintained
578 elsewhere with copies under @file{texk/texlive/linked_scripts}.
580 These so-called @dfn{linked scripts} are installed under
581 @code{@var{datarootdir}/texmf-dist/scripts}; for Unix-like systems a
582 symbolic link is made in @code{@var{bindir}}.  For example, a symlink
583 points from @code{@var{bindir}/ps2eps} to
584 @code{@var{datarootdir}/texmf-dist/scripts/ps2eps/ps2eps.pl}.  For
585 Windows, a standard wrapper binary (e.g.,
586 @code{@var{bindir}/ps2eps.exe}) serves the same purpose.  (The source
587 for the wrapper is in @file{texk/texlive/w32_wrapper}.)
589 One reason for this is to avoid having many copies of the same
590 script; a more important reason is that it guarantees the scripts will
591 stay in sync across the different supported operating systems.
593 @pindex asymptote
594 @pindex biber
595 @pindex xindy
596 @pindex xz
597 @pindex wget
598 Most important of all, we want the @code{@var{bindir}} resulting from
599 the build to be as close as possible to what is in the TL
600 distribution.  At present, there are a few exceptions---Asymptote,
601 Biber, Xindy---and each one creates considerable extra work.  We don't
602 want to add more.  (See @url{http://tug.org/texlive/build.html} for
603 information about building those exceptions, as well as the @code{xz}
604 and @code{wget} programs that are used in the TL infrastructure.)
607 @node Distro builds
608 @section Distro builds
610 @cindex distro, building for
611 @cindex operating system distribution, building for
612 @cindex system distribution, building for
614 @cindex GNU/Linux distro
615 @cindex BSD distro
616 Although they use the same code base, building for the native TL
617 distribution as shipped by the @TeX{} user groups is typically quite
618 different from a ``distro'' build needed by, e.g., a full GNU/Linux or
619 BSD operating system distribution.
621 @cindex shared libraries, using vs.@: avoiding
622 The native TL distribution uses shared libraries only when absolutely
623 necessary (@file{libc}, @file{libm}, X11 libraries, and
624 @file{libfontconfig}).  However, a distro typically wants to use as
625 many shared libraries as possible from elsewhere on the system,
626 including @TeX{}-specific libraries such as @file{libkpathsea} (even
627 though Kpathsea has never officially been released as a shared
628 library, but we digress).  In addition, the installation paths will,
629 in general, be completely different.
631 Here are the @code{configure} options that distro builds are likely to
632 find most relevant:
634 @table @code
635 @item --disable-native-texlive-build
636 This must be specified to avoid interference from the many tweaks we
637 do for the native TL build.
639 @item --with-banner-add=/@var{SomeDistro}
640 This isn't technically required, but is strongly recommended, so your
641 build and your distro can be distinguished from others.
643 @item --enable-shared
644 Build shared versions of the @TeX{}-specific libraries (uses
645 @code{libtool}).
647 @item --disable-static
648 Do not build the static versions of the @TeX{}-specific libraries.
650 @item --with-system-@var{lib}
651 Use system versions for as many libraries @var{lib} as possible.
652 @code{configure --help} will give you the list of possibilities.
654 @item --with-@var{lib}-includes=@var{dir}
655 @itemx --with-@var{lib}-libdir=@var{dir}
656 If needed, allows you to specify where the headers/code are for the
657 given library @var{lib}.
659 @item --prefix=/usr
660 @itemx --prefix=/opt/TeXLive
661 Or whatever your convention is.  The default is @file{/usr/local} and
662 you shouldn't install there for a distro.
664 @item --libdir=\$@{exec_prefix@}/lib64
665 May be needed for 64-bit bi-architecture (GNU/Linux) systems.
667 @end table
669 @cindex Preining, Norbert
670 @cindex adapting @TL{} for distros
671 You will need to take care of the support files mentioned above
672 (@pxref{Installing}), and many other issues, such as font maps,
673 languages, and formats, independently of the build.  Norbert Preining
674 has written a detailed article on adapting TL for distros:
675 @url{http://tug.org/TUGboat/tb34-3/tb108preining-distro.pdf}.  (If the
676 article needs updating in the future, perhaps we will merge it into
677 this document.)
680 @node Layout and infrastructure
681 @chapter Layout and infrastructure
683 @cindex layout of sources
684 @cindex source tree
686 The @TL{} source tree is the subtree rooted at @file{Build/source} of
687 the complete TL distribution and contains the sources for all executables
688 distributed by TL, as well as @code{configure} scripts and @code{make}
689 rules to build and install them together with some of their support
690 files.
692 @menu
693 * Build system tools::          If modifying infrastructure files.
694 * Top-level directories::
695 * Autoconf macros::             TL-specific Autoconf macros.
696 * Library modules::             Details on some specific libraries,
697 * Program modules::             and on some programs.
698 * Extending @TL{}::             Adding a new module.
699 @end menu
702 @node Build system tools
703 @section Build system tools
705 @cindex tools, for building
706 @cindex GNU tools, needed for building
707 @cindex infrastructure, tools needed for
709 As mentioned above (@pxref{Prerequisites}), a normal build requires
710 very little.  On the other hand, if you want to modify the @TL{}
711 infrastructure sources, such as @file{configure.ac} or
712 @file{Makefile.am} files, you will need to have several additional
713 tools installed.
715 In general, the TL build system uses the latest released versions of
716 the GNU build tools, installed directly from the original GNU releases
717 (e.g., by building them with @code{configure --prefix=/usr/local/gnu}
718 and having @env{PATH} start with @file{/usr/local/gnu/bin}).  We have
719 found that trying to use the versions of these tools packaged for
720 distros causes many extra hassles, so don't do that, tempting as it
721 may be.
723 Currently the versions we use are:
725 @display
726 @include build-tools.txt
727 @end display
729 @pindex reautoconf
730 @vindex --enable-maintainer-mode configure @r{option}
731 These versions should be used to update the generated files (e.g.,
732 @file{configure} or @file{Makefile.in}) in all or parts of the TL tree
733 after their dependencies have been changed.  This can be done
734 explicitly with the top-level @code{reautoconf} script or implicitly
735 by using the configure option @code{--enable-maintainer-mode}.
737 @cindex Subversion repository
738 @cindex timestamps, in repository
739 @vindex use-commit-times@r{, Subversion}
740 The files in the Subversion repository (see
741 @url{http://tug.org/texlive/svn}) are all up to date, but
742 unfortunately this may not be reflected by their timestamps.  (For
743 starters, be sure to set @file{use-commit-times=yes} in
744 @file{~/.subversion/config} or the equivalent.)
746 @cindex touching files to avoid rerunning
747 @pindex make -t
748 To avoid unnecessary runs of @code{bison}, @code{flex}, or
749 @code{makeinfo} it may be necessary to @code{touch} the generated
750 (@file{.c}, @file{.h}, or @file{.info}) files.  With
751 @code{--enable-maintainer-mode} it may also be necessary to
752 @code{touch} first @file{aclocal.m4}, then @file{configure} and
753 @file{config.h.in} (or @file{c-auto.in}), and finally all
754 @file{Makefile.in} files.  Perhaps @code{make -t} will help.
757 @node Top-level directories
758 @section Top-level directories
760 @cindex directories, top-level
761 @cindex top-level directories
763 Here is a brief description of the top-level directories in the @TL{}
764 source tree.
766 As mentioned at the beginning of @pxref{Overview of build
767 system}, the main source directories are @file{texk/}
768 (@TeX{}-specific programs and libraries), @file{utils/} (additional
769 programs), and @file{libs/} (generic libraries).
771 @cindex @file{am/} top-level directory
772 @cindex @file{m4/} top-level directory
773 The top-level directories @file{am/} and @file{m4/} contain
774 @file{Makefile.am} fragments and Autoconf macros, respectively, used
775 in many places.  Specifically, the file @file{m4/kpse-pkgs.m4}
776 contains lists of all program and library modules; missing modules are
777 silently ignored.  (This helps in creating cut-down source trees.)
779 Each module contributes fragments (in separate files) defining its
780 capabilities and requirements to the @file{configure.ac} scripts at
781 the top-level and in the subdirectories @file{libs}, @file{utils}, and
782 @file{texk}.  The fragments from program modules supply
783 @code{configure} options to disable or enable building them; those
784 from library modules specify if an installed (system) version of that
785 library can be used.  This ultimately determines which modules need to
786 be built---although all modules must be configured for the benefit of
787 @file{make} targets such as @code{dist} or @code{distcheck}.
789 @pindex config.guess@r{,} config.sub
790 @cindex Gnulib, used for common files
791 The top-level @file{build-aux/} directory contains the common files
792 @file{compile}, @file{config.guess}, @file{config.sub},
793 @file{depcomp}, etc.@ for most packages, pulled from the GNU Gnulib
794 sources (@url{http://www.gnu.org/software/gnulib}), which in turn
795 synchronizes with the appropriate ultimate upstream repository.  There
796 are, however, independent copies in, e.g.,
797 @file{libs/freetype2/freetype-*/builds/unix/}, and similar places.
798 The @code{reautoconf} script does not touch those, but a TL cron job
799 keeps them in sync (nightly).
801 @cindex @file{extra/} top-level directory
802 The directory @file{extra/} contains things which are not part of the
803 TL build, but are present just for (someone's) convenience, e.g.,
804 @file{epstopdf} which is developed here.
807 @node Autoconf macros
808 @section Autoconf macros
810 @cindex autoconf macros
812 @c Texinfo macro: @ovar(ARG)
813 @c ARG is the name of an optional argument; this is used for
814 @c documentation of macro arguments (@defmac lines).  Plain
815 @c brackets are treated specially and appear more distinct.
816 @macro ovar{varname}
817 [@var{\varname\}]
818 @end macro
820 @c @dvar(ARG, DEFAULT)
821 @c -------------------
822 @c The ARG is an optional argument, defaulting to DEFAULT.  To be used
823 @c for macro arguments in their documentation (@defmac).
824 @c @macro xxdvar{varname, default}
825 @c @r{[}@var{\varname\} = @samp{\default\}@r{]}
826 @c @end macro
828 Here we describe some of the Autoconf macros used in several
829 modules--not a complete list, by any means.  These general macros are
830 supplemented by module-specific macros in directories such as
831 @file{texk/dvipng/m4/}; some of those are described in @ref{Library
832 modules} and @pxref{Program modules}.
834 @menu
835 * Setup:     General setup macros.
836 * Programs:  Macros for programs.
837 * Compilers: Macros for compilers.
838 * Libraries: Macros for libraries.
839 * Flags:     Macros for library and header flags.
840 * Windows:   Macros for Windows.
841 @end menu
843 @node General setup macros
844 @subsection General setup macros
846 @cindex general setup macros
847 @cindex setup macros, general
848 @cindex macros, general setup
849 The TL sources use two general setup macros:
851 @defmac KPSE_BASIC (@var{name}, @ovar{more-options})
852 Initialize the basic TL infrastructure for module @var{name}:@*@ @ @
853 @code{AM_INIT_AUTOMAKE([foreign @var{more-options}])}@*@ @ @
854 @code{AM_MAINTAINER_MODE}@*@ @ @ @code{KPSE_COMPILER_WARNINGS}@*
855 and make sure the C compiler understands function prototypes.  This is
856 used for all generic library and program modules.
857 @end defmac
859 @defmac KPSE_COMMON (@var{name}, @ovar{more-options})
860 Like @code{KPSE_BASIC} but add:@*@ @ @ @code{LT_PREREQ([2.2.6])}@*@ @
861 @ @code{LT_INIT([win32-dll])}@*@ @ @ @code{AC_SYS_LARGEFILE}@*@ @ @
862 @code{AC_FUNC_FSEEKO}@*and check for frequently used functions,
863 headers, types, and structures.  This is used for @TeX{}-specific
864 modules.
865 @end defmac
868 @node Macros for programs
869 @subsection Macros for programs
871 @cindex macros, for programs
872 Macros for program checks:
874 @defmac KPSE_CHECK_LATEX
875 Set @code{LATEX} to the name of the first of @code{latex},
876 @code{elatex}, or @code{lambda} which exists in @code{PATH}, or to
877 @code{no} if none of them exists.  Call @code{AC_SUBST} for
878 @code{LATEX}.  The result of this test can be overridden by setting
879 the @code{LATEX} environment variable or the cache variable
880 @code{ac_cv_prog_LATEX}.
881 @end defmac
883 @defmac KPSE_CHECK_PDFLATEX
884 Check for @code{pdflatex} in @code{PATH} and set @code{PDFLATEX}.
885 @end defmac
887 @defmac KPSE_CHECK_PERL
888 Check for @code{perl} or @code{perl5} in @code{PATH} and set
889 @code{PERL}.
890 @end defmac
892 @defmac KPSE_PROG_LEX
893 Call @code{AC_PROG_LEX} and add the flag @code{-l} for @code{flex}.
894 @end defmac
897 @node Macros for compilers
898 @subsection Macros for compilers
900 @cindex macros, for compilers
902 Macros for compiler-related checks:
904 @defmac KPSE_COMPILER_WARNINGS
905 @vindex WARNING_C[XX]FLAGS
906 When using the (Objective) C/C++ compiler, set
907 @code{WARNING_[OBJ]C[XX]FLAGS} to suitable warning flags (depending on
908 the value given to or implied for @code{--enable-compiler-warnings}).
909 Call @code{AC_SUBST} for them.  At the moment this only works for GNU
910 compilers, but could be extended to others if necessary.
912 @vindex kpse_cv_warning_cflags
913 This macro caches its results in the @code{kpse_cv_warning_cflags},
914 @dots{} variables.
915 @end defmac
917 @defmac KPSE_COMPILER_VISIBILITY
918 When using the C or C++ compiler, try to set
919 @code{VISIBILITY_C[XX]FLAGS} to flags to hide external symbols.  Call
920 @code{AC_SUBST} for this variable.  At the moment this only tests for
921 the compiler option @code{-fvisibility=hidden}, but that could be
922 extended with more checks if necessary.
924 @vindex kpse_cv_visibility_c[xx]flags
925 This macro caches its results in the @code{kpse_cv_visibility_cflags}
926 or @code{kpse_cv_visibility_cxxflags} variable.
927 @end defmac
929 @defmac KPSE_CXX_HACK
930 @cindex static linking for C++
931 @cindex linking C++ libraries statically
932 @vindex --enable-cxx-runtime-hack configure @r{option}
933 @pindex libstc++@r{, statically linking}
934 Provide the configure option @code{--enable-cxx-runtime-hack}.  If
935 enabled and when using @code{g++}, try to statically link with
936 @file{libstdc++}, somewhat improving portability of the resulting
937 binary.
939 @vindex kpse_cv_cxx_hack
940 This macro caches its result in the @code{kpse_cv_cxx_hack} variable.
941 @end defmac
944 @node Macros for libraries
945 @subsection Macros for libraries
947 @cindex macros, for libraries
948 One macro for a library check:
950 @defmac KPSE_LARGEFILE (@var{variable}, @ovar{extra-define})
951 Call @code{AC_SYS_LARGEFILE} and @code{AC_FUNC_FSEEKO} and append
952 suitable @code{-D} flags (optionally including
953 @code{-D@var{extra-define}}) to @var{variable}.
954 @end defmac
957 @node Macros for library and header flags
958 @subsection Macros for library and header flags
960 @cindex macros, for library and header flags
961 @cindex flags, macros for library and header
962 @vindex KPSE_@var{LIB}_FLAGS
963 Each library module @file{libs/@var{lib}} or @file{texk/@var{lib}} is
964 supplemented by a macro @code{KPSE_@var{LIB}_FLAGS} (all uppercase)
965 that provides make variables for that library.  E.g., for
966 @file{libs/libpng}:
968 @defmac KPSE_LIBPNG_FLAGS
969 Provide the configure option @code{--with-system-libpng}.  Set and
970 @code{AC_SUBST} @code{make} variables for modules using this library (either
971 an installed version or from the @TL{} tree): @code{LIBPNG_INCLUDES} for use
972 in @code{CPPFLAGS}, @code{LIBPNG_LIBS} for use in @code{LDADD},
973 @code{LIBPNG_DEPEND} for use as dependency, and @code{LIBPNG_RULE} defining
974 @code{make} rules to rebuild the library.
975 @end defmac
977 @defmac KPSE_ADD_FLAGS (@var{name})
978 Temporarily extend @code{CPPFLAGS} and @code{LIBS} with the values required
979 for the library module @code{@var{name}}.
980 @end defmac
982 @defmac KPSE_RESTORE_FLAGS
983 Restore @code{CPPFLAGS} and @code{LIBS} to their original values.
984 @end defmac
986 As an example, the @file{configure.ac} file for a hypothetical program
987 @file{utils/foo} using @file{libpng}, and hence @file{zlib}, would
988 contain
989 @example
990 KPSE_ZLIB_FLAGS
991 KPSE_LIBPNG_FLAGS
992 @end example
994 @noindent and its @file{Makefile.am} would be along these lines:
995 @example
996 bin_PROGRAMS = foo
997 AM_CPPFLAGS = $@{LIBPNG_INCLUDES@} $@{ZLIB_INCLUDES@}
998 foo_LDADD = $@{LIBPNG_LIBS@} $@{ZLIB_LIBS@}
999 foo_DEPENDENCIES = $@{ZLIB_DEPEND@} $@{LIBPNG_DEPEND@}
1000 ## Rebuild libz
1001 @@ZLIB_RULE@@
1002 ## Rebuild libpng
1003 @@LIBPNG_RULE@@
1004 @end example
1006 If it was necessary to examine whether certain @file{zlib} or
1007 @file{libpng} features were available, @file{configure.ac} should be
1008 continued this way:
1009 @example
1010 KPSE_ADD_FLAGS([zlib])
1011 @dots{} # @r{tests for @file{zlib} features, if any}
1012 KPSE_ADD_FLAGS([libpng])
1013 @dots{} # @r{tests for @file{libpng} features}
1014 KPSE_RESTORE_FLAGS # @r{restore @code{CPPFLAGS} and @code{LIBS}}
1015 @end example
1018 @node Macros for Windows
1019 @subsection Macros for Windows
1021 @cindex macros, for Windows
1022 @cindex Windows, macros for
1023 Windows differs in several aspects from Unix-like systems, many of
1024 them due to the lack of symbolic links.
1026 @defmac KPSE_CHECK_WIN32
1027 @vindex kpse_cv_have_win32
1028 Check if compiling for a Windows system.  The result is @code{no} for
1029 Unix-like systems (including Cygwin), @code{mingw32} for Windows with
1030 GCC, or @code{native} for Windows with MSVC.  The result is cached in
1031 the @code{kpse_cv_have_win32} variable.
1032 @end defmac
1034 @defmac KPSE_COND_WIN32
1035 @vindex WIN32@r{, Automake conditional}
1036 Call @code{KPSE_CHECK_WIN32} and define the Automake conditional
1037 @code{WIN32} (@code{true} if the value of @code{kpse_cv_have_win32} is
1038 not @code{no}).
1039 @end defmac
1041 @defmac KPSE_COND_MINGW32
1042 @vindex MINGW32@r{, Automake conditional}
1043 Call @code{KPSE_COND_WIN32} and define the Automake conditional
1044 @code{MINGW32} (@code{true} if the value of @code{kpse_cv_have_win32} is
1045 @code{mingw32}).
1046 @end defmac
1048 @defmac KPSE_COND_WIN32_WRAP
1049 @vindex WIN32_WRAP@r{, Automake conditional}
1050 @pindex runscript.exe
1051 Call @code{KPSE_COND_WIN32} and define the Automake conditional
1052 @code{WIN32_WRAP} (@code{true} if the standard Windows wrapper
1053 (@file{texk/texlive/w32_wrapper/runscript.exe}) exists.  This wrapper
1054 is used on Windows instead of symlinks for the ``linked scripts''
1055 (@pxref{Linked scripts}).
1056 @end defmac
1058 @defmac KPSE_WIN32_CALL
1059 @pindex callexe.c
1060 Call @code{KPSE_COND_WIN32}, check if the file
1061 @file{texk/texlive/w32_wrapper/callexe.c} exists; if it does, create a
1062 symlink in the build tree.  Compiling @file{callexe.c} with
1063 @code{-DEXEPROG='"@var{foo}.exe"'} and installing @file{callexe.exe}
1064 as @code{@var{bar}.exe} is used on Windows instead of a symlink
1065 @code{@var{bar}->@var{foo}} for Unix-like systems.
1066 @end defmac
1069 @node Library modules
1070 @section Library modules
1072 @cindex library modules
1073 @cindex modules, for libraries
1074 Here we discuss some specifics for a few of the libraries in TL, both
1075 for the details themselves, and as a way of illuminating the general
1076 structure and variation.
1078 @menu
1079 * @code{png} library::       @file{libs/libpng}
1080 * @code{zlib} library::      @file{libs/zlib}
1081 * @code{freetype} library::  @file{libs/freetype2}
1082 * @code{kpathsea} library::  @file{texk/kpathsea}
1083 @end menu
1085 @node @code{png} library
1086 @subsection The @code{png} library in @file{libs/libpng}
1088 @pindex png @r{library}
1089 @pindex libpng @r{library}
1090 @set libpngversion libpng-1.6.16
1091 This generic library uses the source tree in, e.g., the subdirectory
1092 @file{@value{libpngversion}} with all modifications for TL recorded in
1093 @file{@value{libpngversion}-PATCHES/*}.  The @file{configure.ac} fragment
1094 @file{ac/withenable.ac} contains
1096 @example
1097 KPSE_WITH_LIB([libpng], [zlib])
1098 @end example
1100 @noindent specifying the module name, and indicating the dependency on
1101 @code{zlib}.  A third literal argument @code{tree} would specify that
1102 the library from the @TL{} tree cannot be replaced by a system
1103 version.  That not being the case here, a second fragment
1104 @file{ac/libpng.ac} contains
1106 @findex KPSE_TRY_LIB
1107 @example
1108 KPSE_TRY_LIB([libpng],
1109              [#include <png.h>],
1110              [png_structp png; png_voidp io; png_rw_ptr fn;
1111 png_set_read_fn(png, io, fn);])
1112 @end example
1114 @noindent thus providing the simple C code
1116 @example
1117 #include <png.h>
1118 int main ()
1119 @{ png_structp png; png_voidp io; png_rw_ptr fn;
1120   png_set_read_fn(png, io, fn);
1121   return 0; @}
1122 @end example
1124 @findex KPSE_TRY_LIBXX
1125 @noindent which Autoconf uses to verify the usability of a system
1126 version with C code.  The analogous macro @code{KPSE_TRY_LIBXX} would
1127 check using C++ code.  These fragments are included by
1128 @file{configure.ac} at the top level.
1130 For this library, among many other modules, a proxy build system for
1131 TL is used (@file{configure.ac}, @file{Makefile.am}, and
1132 @file{include/Makefile.am}), ignoring the distributed one.
1133 Consequently, a few generated files and auxiliary scripts are removed
1134 from the distributed source tree.  The public headers @file{png.h},
1135 @file{pngconf.h}, and @file{pnglibconf.h} are ``installed'' (as
1136 symlinks) under @file{include/} in the build tree exactly as they are
1137 for a system version under, e.g., @file{/usr/include/}.
1139 @pindex kpse-libpng-flags.m4
1140 @vindex KPSE_LIBPNG_FLAGS
1141 The module is supplemented by the file @file{m4/kpse-libpng-flags.m4}
1142 that defines the M4 macro @code{KPSE_LIBPNG_FLAGS} used by all modules
1143 depending on this library in their @file{configure.ac} to generate the
1144 @code{make} variables @code{LIBPNG_INCLUDES} for use in
1145 @code{CPPFLAGS}, @code{LIBPNG_LIBS} for use in @code{LDADD},
1146 @code{LIBPNG_DEPEND} for use as dependencies, and @code{LIBPNG_RULE}
1147 defining @code{make} rules to rebuild the library.
1149 @file{m4/kpse-libpng-flags.m4} also supplies the configure option
1150 @code{--with-system-libpng} and uses @code{pkg-config} to determine
1151 the flags required for the system library.
1154 @node @code{zlib} library
1155 @subsection The @code{zlib} library in @file{libs/zlib}
1157 @pindex zlib @r{library}
1159 @pindex kpse-zlib-flags.m4
1160 This generic library is very much analogous to @code{libpng}, but
1161 without the dependency on any other library.  The file
1162 @file{m4/kpse-zlib-flags.m4} supplies the configure option
1163 @code{--with-system-zlib}, as well as @code{--with-zlib-includes} and
1164 @code{--with-zlib-libdir} to specify non-standard locations of the
1165 @code{zlib} headers and/or library.
1168 @node @code{freetype} library
1169 @subsection The @code{freetype} library in @file{libs/freetype2}
1171 @pindex freetype @r{library}
1173 @pindex freetype-config
1174 This module uses a wrapper build system with an almost trivial
1175 @file{configure.ac} and with a @file{Makefile.am} that invokes
1176 @code{configure} and @code{make} for the distributed source, followed
1177 by @code{make install} with the build tree as destination.  The flags
1178 required for the system library are obtained through
1179 @code{freetype-config}.
1182 @node @code{kpathsea} library
1183 @subsection The @code{kpathsea} library in @file{texk/kpathsea}
1185 @pindex kpathsea @r{library}
1187 This is one of the @TeX{}-specific libraries that are maintained as
1188 part of @TL{} (@pxref{,,, kpathsea, Kpathsea}).  Despite being a core
1189 part of the @TeX{} system, it is not a terribly special case in the
1190 infrastructure.  The @TeX{} libraries are Libtool libraries (static
1191 and/or shared) and are installed by @code{make install} together with
1192 the programs.  They are, however, not part of the TL DVD as
1193 distributed by @TeX{} user groups, and have never been officially
1194 released for standalone use.
1196 @pindex --with-system-kpathsea
1197 It is possible, and perhaps even useful for distro builds (@pxref{Distro
1198 builds}), to specify the configure option @code{--with-system-kpathsea} in
1199 order to use a system version of the library.  Programs outside the TL tree
1200 should use @code{pkg-config} for the required flags.
1202 @pindex kpathsea.ac
1203 @pindex mktex.ac
1204 @vindex --enable-mktextfm-default
1205 @pindex mktextfm
1206 In addition to @file{ac/withenable.ac} and @file{ac/kpathsea.ac} there
1207 is a third fragment @file{ac/mktex.ac} included by both
1208 @file{ac/withenable.ac} and @file{configure.ac} that supplies
1209 configure options such as @code{--enable-mktextfm-default}, which
1210 determine the compile time default of whether or not to run
1211 @code{mktextfm} to generate a missing @file{.tfm} file.  In any case,
1212 however, the command line options @code{-mktex=tfm} or
1213 @code{-no-mktex=tfm} for the @TeX{}-like engines override this default.
1216 @node Program modules
1217 @section Program modules
1219 @cindex program modules
1220 @cindex modules, for programs
1221 As with libraries (@pxref{Library modules}), here we discuss the
1222 details for a few of the programs in TL.
1224 @menu
1225 * @code{t1utils} package:: @file{utils/t1utils}
1226 * @code{xindy} package::   @file{utils/xindy}
1227 * @code{xdvik} package::   @file{texk/xdvik}
1228 * @code{asymptote}::       @file{utils/asymptote}
1229 @end menu
1232 @node @code{t1utils} package
1233 @subsection The @code{t1utils} package in @file{utils/t1utils}
1235 @pindex t1utils @r{package}
1236 @set t1utilsversion t1utils-1.39
1238 Once again we use the distributed source tree @file{@value{t1utilsversion}}
1239 with modifications documented in @file{@value{t1utilsversion}-PATCHES/*} and
1240 a proxy build system consisting of @file{configure.ac} and
1241 @file{Makefile.am}.  The fragment @file{ac/withenable.ac} contains
1243 @example
1244 KPSE_ENABLE_PROG([t1utils])
1245 @end example
1247 @noindent specifying the module name without any dependencies, and
1248 supplies the configure option @code{--disable-t1utils}.
1251 @node @code{xindy} package
1252 @subsection The @code{xindy} package in @file{utils/xindy}
1254 @pindex xindy
1255 @set xindyversion xindy-2.5.1
1257 This module uses the distributed source tree @file{@value{xindyversion}}
1258 with modifications documented in @file{@value{xindyversion}-PATCHES/*}, a
1259 proxy @file{configure.ac}, and a wrapper @file{Makefile.am} that descends
1260 into @file{@value{xindyversion}}.  The @code{xindy} build requires that the
1261 distributed @file{Makefile}s allow a @code{VPATH} build, can handle all
1262 targets, and do not refer to @code{$@{top_srcdir@}} or
1263 @code{$@{top_builddir@}}.  The fragment @code{ac/withenable.ac} contains
1265 @example
1266 KPSE_ENABLE_PROG([xindy], , [disable native])
1267 m4_include(kpse_TL[utils/xindy/ac/xindy.ac])
1268 m4_include(kpse_TL[utils/xindy/ac/clisp.ac])
1269 @end example
1271 @noindent where @code{disable} in the third argument indicates that
1272 @code{xindy} is only built if explicitly enabled by the user with
1273 @code{configure --enable-xindy} (the need for @code{clisp} is too
1274 painful to require by default), and @code{native} disallows cross
1275 compilation.  The additional fragments @file{ac/xindy.ac} and
1276 @file{ac/clisp.ac} specify more @code{configure} options to be seen at
1277 the top level with @file{ac/xindy.ac} also included by
1278 @file{configure.ac}.
1281 @node @code{xdvik} package
1282 @subsection The @code{xdvik} package in @file{texk/xdvik}
1284 @pindex xdvik
1286 This package is maintained as part of the @TL{} tree with sources in
1287 its top level directory and the subdirectory @file{gui}.  The fragment
1288 @code{ac/withenable.ac} contains
1290 @example
1291 dnl extra_dirs = texk/xdvik/squeeze
1292 KPSE_ENABLE_PROG([xdvik], [kpathsea freetype2], [x])
1293 m4_include(kpse_TL[texk/xdvik/ac/xdvik.ac])
1294 @end example
1296 @pindex squeeze/configure.ac
1297 @cindex cross compilation, with host binary
1298 @noindent thus specifying the dependency on the @code{kpathsea},
1299 @code{freetype}, and X11 libraries.  The M4 comment (following
1300 @code{dnl}) signals the subsidiary @file{squeeze/configure.ac}.  This
1301 is needed because the main executable @file{xdvi-bin} (to be installed
1302 as, e.g., @file{xdvi-xaw}) is for the @code{host} system whereas the
1303 auxiliary program @file{squeeze/squeeze} has to run on the
1304 @code{build} system and in a cross compilation they differ.
1306 @vindex --with-xdvi-x-toolkit
1307 The additional fragment @code{ac/xdvik.ac} is also included by
1308 @file{configure.ac} and supplies the configure option
1309 @code{--with-xdvi-x-toolkit} also seen at the top-level.
1312 @node @code{asymptote}
1313 @subsection The subdirectory @file{utils/asymptote}
1315 @pindex asymptote
1316 @pindex xasy
1318 @cindex OpenGL, required for Asymptote
1319 This subdirectory contains the sources for @file{asy} and @file{xasy}
1320 but due to its complexity and prerequisites (e.g., OpenGL) it is
1321 not part of the TL build system.  These programs must be built and
1322 installed independently, but are included on the TL DVD together with
1323 their support files.
1326 @node Extending @TeX{} Live
1327 @section Extending @TeX{} Live
1329 @cindex extending @TL{}
1330 @cindex adding to @TL{}
1332 This section outlines the basic process for adding new packages to the
1333 TL build system.
1335 @menu
1336 * Adding a new program module::
1337 * Adding a new generic library module::
1338 * Adding a new @TeX{}-specific library module::
1339 @end menu
1342 @node Adding a new program module
1343 @subsection Adding a new program module
1345 @cindex adding a new program
1346 @cindex program module, adding
1348 @vindex kpse_texk_pkgs
1349 A @TeX{}-specific program module in a subdirectory
1350 @file{texk/@var{prog}} may use the @TeX{}-specific libraries and is
1351 included by adding its name @file{@var{prog}} to the M4 list
1352 @code{kpse_texk_pkgs} defined in @file{m4/kpse-pkgs.m4}.
1354 @vindex kpse_utils_pkgs
1355 A generic program module in a subdirectory @file{utils/@var{prog}}
1356 must not use the @TeX{}-specific libraries and is included by adding
1357 its name @file{@var{prog}} to the M4 list @code{kpse_utils_pkgs} in
1358 @file{m4/kpse-pkgs.m4}.
1360 @pindex withenable.ac@r{, for new modules}
1361 @findex KPSE_ENABLE_PROG
1362 In either case, apart from the program sources and build system
1363 (@file{configure.ac} and @file{Makefile.am}), the subdirectory
1364 @file{texk/@var{prog}} or @file{utils/@var{prog}} must provide a
1365 fragment @file{ac/withenable.ac} that contains the M4 macro
1366 @code{KPSE_ENABLE_PROG} defined in @file{m4/kpse-setup.m4} with
1367 @code{@var{prog}} as the mandatory first argument and three optional
1368 arguments:
1370 @enumerate
1371 @item a list of required libraries from the TL tree;
1373 @item a list of options (@code{disable} if this module is not to be
1374 built without the configure option @code{--enable-@var{prog}},
1375 @code{native} if cross compilation is not possible, @code{x} if the
1376 program requires X11 libraries);
1378 @item and a comment added to the help text for the @code{configure}
1379 option @code{--enable-@var{prog}} or @code{--disable-@var{prog}}.
1380 @end enumerate
1382 If the module requires specific configure options to be seen at the
1383 top-level, they should be defined in an additional fragment
1384 @file{ac/@var{prog}.ac} included from @file{ac/withenable.ac} and
1385 @file{configure.ac}.
1388 @node Adding a new generic library module
1389 @subsection Adding a new generic library module
1391 @cindex adding a new generic library
1392 @cindex generic library module, adding
1393 @cindex library module, generic, adding
1395 @vindex kpse_libs_pkgs
1396 A generic library module in a subdirectory @file{libs/@var{lib}} must
1397 not depend on @TeX{}-specific libraries, by definition.  It is
1398 included by adding its name @file{@var{lib}} to the M4 list
1399 @code{kpse_libs_pkgs} in @file{m4/kpse-pkgs.m4}---before any other
1400 libraries from the @TL{} tree on which it depends.
1402 @findex KPSE_WITH_LIB
1403 As with program modules, the subdirectory @file{libs/@var{lib}} must
1404 contain the sources and build system for the library (and any
1405 installable support programs) and a fragment @file{ac/withenable.ac}
1406 that contains the M4 macro @code{KPSE_WITH_LIB} defined in
1407 @file{m4/kpse-setup.m4} with @code{@var{lib}} as the mandatory first
1408 argument and two optional arguments: a list of required libraries from
1409 the TL tree, and a list of options (currently there is only one:
1410 specify @code{tree} if this library cannot be replaced by a system
1411 version).
1413 @findex KPSE_TRY_LIB
1414 @findex KPSE_TRY_LIBXX
1415 If a system version can be used, a second fragment
1416 @file{ac/@var{lib}.ac} is needed, containing the M4 macro
1417 @code{KPSE_TRY_LIB} (or @code{KPSE_TRY_LIBXX}) with @code{@var{lib}}
1418 as the mandatory first argument and two additional arguments for the
1419 Autoconf macro @code{AC_LANG_PROGRAM} used to compile and link a small
1420 C (or C++) program as sanity check for using the system library.
1422 @vindex KPSE_@var{LIB}_FLAGS
1423 In addition a file @file{m4/kpse-@var{lib}-flags} (at the top level)
1424 must define the M4 macro @code{KPSE_@var{LIB}_FLAGS} (all uppercase)
1425 setting up the @code{make} variables @code{@var{LIB}_INCLUDES},
1426 @code{@var{LIB}_LIBS}, @code{@var{LIB}_DEPEND}, and
1427 @code{@var{LIB}_RULE} with the values required for @code{CPPFLAGS},
1428 @code{LDADD}, dependencies, and a (multi-line) @code{make} rule to
1429 rebuild the library when necessary.  All of that is needed for the
1430 library from the TL tree and, if supported, for a system version.
1432 @vindex --with-system-@var{lib}
1433 @vindex KPSE_@var{LIB}_SYSTEM_FLAGS
1434 @vindex KPSE_ALL_SYSTEM_FLAGS
1435 If a system library is allowed, @code{KPSE_@var{LIB}_FLAGS} also
1436 provides the configure option @code{--with-system-@var{lib}} and uses
1437 the additional M4 macro @code{KPSE_@var{LIB}_SYSTEM_FLAGS} to generate
1438 the @code{make} variables for a system library.  Furthermore the
1439 definition of the M4 macro @code{KPSE_ALL_SYSTEM_FLAGS} in
1440 @file{m4/kpse-pkgs.m4} must be extended by the line:@*@ @ @
1441 @code{AC_REQUIRE([KPSE_@var{LIB}_SYSTEM_FLAGS])}
1444 @node Adding a new @TeX{}-specific library module
1445 @subsection Adding a new @TeX{}-specific library module
1447 @cindex adding a new @TeX{}-specific library
1448 @cindex @TeX{}-specific library module, adding
1449 @cindex library module, @TeX{}-specific, adding
1451 A @TeX{}-specific library module in a subdirectory
1452 @file{texk/@var{lib}} may depend on other @TeX{}-specific libraries
1453 but must not depend on any generic library from the TL tree.  It is
1454 included in the same general ways as a generic library (see the
1455 previous section), with these modifications:
1457 @itemize @bullet
1458 @item
1459 @vindex kpse_texlibs_pkgs
1460 The library name @code{@var{lib}} is added to the M4 list
1461 @code{kpse_texlibs_pkgs} also in @file{m4/kpse-pkgs.m4}.
1463 @item
1464 @findex KPSE_WITH_TEXLIB
1465 The fragment @code{ac/withenable.ac} must use @code{KPSE_WITH_TEXLIB}.
1466 @end itemize
1469 @node Configure options
1470 @chapter Configure options
1472 @cindex @code{configure} options
1474 Corresponding to the large number of program and library modules there
1475 are a large number @code{configure} options, most of which are
1476 described here.  The command@*@ @ @ @code{configure --help}@*at the
1477 top level gives an exhaustive list of all global options and a few
1478 important module-specific ones, whereas, e.g.,@*@ @ @
1479 @code{texk/lcdf-typetools/configure --help}@* also displays the
1480 @code{lcdf-typetools} specific options, which are not shown at the
1481 top-level.
1483 @cindex environment variables, for @code{configure}
1484 The help text also mentions several influential environment variables,
1485 but for @TL{} it is better to specify them as assigments on the
1486 command line.
1488 The @file{./Build} script used to make the binaries shipped with @TL{}
1489 invokes the top-level @code{configure} with a few additional options
1490 (@pxref{Building}).  The defaults discussed below are those for the
1491 actual @code{configure} script; invoking @code{configure} via
1492 @file{./Build} may yield different results.
1494 Defaults for most options are set at the top level and propagated
1495 explicitly to all subdirectories.  Options specified on the command
1496 line are checked for consistency but never modified.
1498 @menu
1499 * Global configure options::
1500 * Program-specific configure options::
1501 * Library-specific configure options::
1502 * Variables for configure::
1503 @end menu
1506 @node Global configure options
1507 @section Global configure options
1509 @cindex global @code{configure} options
1510 @cindex @code{configure} options, global
1511 Here are the global configure options.
1513 @menu
1514 * @code{--disable-native-texlive-build}::
1515 * @code{--prefix} @code{--bindir} @dots{}::
1516 * @code{--disable-largefile}::
1517 * @code{--disable-missing}::
1518 * @code{--enable-compiler-warnings=}@var{level}::
1519 * @code{--enable-cxx-runtime-hack}::
1520 * @code{--enable-maintainer-mode}::
1521 * @code{--enable-multiplatform}::
1522 * @code{--enable-shared}::
1523 * @code{--enable-silent-rules}::
1524 * @code{--without-ln-s}::
1525 * @code{--without-x}::
1526 @end menu
1529 @node @code{--disable-native-texlive-build}
1530 @subsection @code{--disable-native-texlive-build}
1532 @vindex --disable-native-texlive-build
1533 If enabled (the default), build for a TL binary distribution as
1534 shipped by the @TeX{} user groups.  This requires GNU @code{make} and
1535 implies @code{--enable-multiplatform} and
1536 @code{--enable-cxx-runtime-hack} (unless they are explicitly disabled),
1537 and enforces @code{--disable-shared}.
1539 If building TL for a GNU/Linux or other distribution, this should be
1540 disabled and system versions of most libraries would be used
1541 (@pxref{Distro builds}).  This may fail without GNU @code{make}, but
1542 will be tried regardless.
1544 @vindex --enable-texlive-build
1545 A related option, @code{--enable-texlive-build}, is automatically
1546 passed to all subdirectories (and cannot be disabled).  Subdirectories
1547 that can also be built independently from the TL tree (such as
1548 @file{utils/xindy} and @file{texk/dvipng}) can use this option, e.g.,
1549 to choose TL-specific installation paths.
1552 @node @code{--prefix} @code{--bindir} @dots{}
1553 @subsection @code{--prefix}, @code{--bindir}, @dots{}
1555 @vindex --prefix configure @r{option}
1556 @vindex --bindir configure @r{option}
1557 These standard Autoconf options specify various installation
1558 directories as usual.  For the complete list, @pxref{Installation
1559 directories}.
1561 @vindex DESTDIR
1562 Also as usual, all values are prefixed by the value of @code{DESTDIR},
1563 if set, on the @code{make} command line (@pxref{Staged Installs, ,
1564 Installation in a temporary location, automake, GNU Automake}).
1567 @node @code{--disable-largefile}
1568 @subsection @code{--disable-largefile}
1570 @vindex --disable-largefile
1571 @cindex large file support
1572 @cindex LFS (large file support)
1573 Omit large file support (LFS), needed on most 32-bit Unix systems for
1574 files with 2GB or more.  Regardless of this, the size of @code{DVI}
1575 and @code{GF} files must always be @math{<2}GB, due to the file format
1576 specifications.
1578 @cindex size of PDF and PS files
1579 @cindex PDF files, size of
1580 @cindex PostScript files, size of
1581 With LFS, there is no fixed limit on the size of PDF files created by
1582 @file{pdftex} or PostScript files created by @file{dvips}.  The size
1583 of PDF images included by @file{pdftex} or @file{luatex} must, however,
1584 be @math{<2}GB when using @file{poppler} version@tie{}0.22 or before
1585 (even on 64-bit systems with LFS).
1588 @node @code{--disable-missing}
1589 @subsection @code{--disable-missing}
1591 @vindex --disable-missing
1592 Immediately terminate the build process if a requested program or feature
1593 must be disabled, e.g., due to missing libraries.  This can help when
1594 figuring out a specific (sub)set of modules to enable.
1597 @node @code{--enable-compiler-warnings=}@var{level}
1598 @subsection @code{--enable-compiler-warnings=}@var{level}
1600 @vindex --enable-compiler-warnings=@var{level}
1601 Enable various levels of compiler warnings for (Objective) C and C++:
1602 the @var{level} value can be one of: @code{no min yes max all}.
1603 The default is @code{yes} in @code{maintainer-mode} (see below) and
1604 @code{min} otherwise.  This option defines
1605 @code{WARNING_[OBJ]C[XX]FLAGS} but these flags are not used in all
1606 library and program modules.  Using them should help to resolve
1607 portability problems.
1609 At present, these warning flags are only defined for the GNU compilers
1610 but flags for other compilers could be added when needed.
1613 @node @code{--enable-cxx-runtime-hack}
1614 @subsection @code{--enable-cxx-runtime-hack}
1616 If enabled (as it is for the native TL build) and when using
1617 @code{g++}, try to statically link with @code{libstdc++}, somewhat
1618 improving portability of the resulting binary.  @xref{Macros for
1619 compilers}.
1622 @node @code{--enable-maintainer-mode}
1623 @subsection @code{--enable-maintainer-mode}
1625 @vindex --enable-maintainer-mode
1626 Enable @file{make} rules and dependencies not useful (and sometimes
1627 confusing) to the casual user.  This requires current versions of the
1628 GNU build tools (@pxref{Build system tools}), as it automatically
1629 rebuilds infrastructure files as needed.  @xref{maintainer-mode,,
1630 @code{missing} and @code{AM_MAINTAINER_MODE}, automake, GNU Automake}.
1633 @node @code{--enable-multiplatform}
1634 @subsection @code{--enable-multiplatform}
1636 @vindex --enable-multiplatform
1637 @vindex exec_prefix
1638 @vindex --bindir configure @r{option}
1639 @vindex --libdir configure @r{option}
1640 If enabled and @code{--bindir=@var{dir}} or @code{--libdir=@var{dir}}
1641 are not specified, install executables and libraries in per-platform
1642 subdirectories of @file{@var{eprefix}/bin} and
1643 @file{@var{eprefix}/lib} where @var{eprefix} is the value given or
1644 implied for @code{exec_prefix}.  In any case, the values for
1645 @code{bindir} and @code{libdir} are automatically propagated to all
1646 subdirectories.
1649 @node @code{--enable-shared}
1650 @subsection @code{--enable-shared}
1652 @vindex --enable-shared
1653 Build shared versions of the @TeX{}-specific libraries such as
1654 @file{libkpathsea}.  This is not allowed for a native TL build (i.e.,
1655 @code{--disable-native-texlive-build} must also be specified).
1658 @node @code{--enable-silent-rules}
1659 @subsection @code{--enable-silent-rules}
1661 @vindex --enable-silent-rules
1662 Enable the use of less verbose build rules.  When using GNU
1663 @code{make} (or another @code{make} implementation supporting nested
1664 variable expansions), you can specify @code{V=1} on the @code{make} command
1665 line to get more verbosity, or @code{V=0} to get less, regardless of
1666 this option.
1669 @node @code{--without-ln-s}
1670 @subsection @code{--without-ln-s}
1672 @vindex --without-ln-s
1673 Required when using a system without a working @code{ln -s} to build
1674 binaries for a Unix-like system.  However, @code{make install} will
1675 not create anything useful and might even fail.
1678 @node @code{--without-x}
1679 @subsection @code{--without-x}
1681 @vindex --without-x
1682 Disable all programs using the X Window System.
1685 @node Program-specific configure options
1686 @section Program-specific configure options
1688 @cindex program-specific @code{configure} options
1689 @cindex @code{configure} options, program-specific
1690 Here are (some of) the program-specific @code{configure} options.
1692 @menu
1693 * @code{--enable-@var{prog}} @code{--disable-@var{prog}}::
1694 * @code{--disable-all-pkgs}::
1695 * Configure options for @file{texk/web2c}::
1696 * Configure options for @file{texk/bibtex-x}::
1697 * Configure options for @file{texk/dvipdfm-x}::
1698 * Configure options for @file{texk/dvisvgm}::
1699 * Configure options for @file{texk/texlive}::
1700 * Configure options for @file{texk/xdvik}::
1701 * Configure options for @file{utils/xindy}::
1702 @end menu
1705 @node @code{--enable-@var{prog}} @code{--disable-@var{prog}}
1706 @subsection @code{--enable-@var{prog}}, @code{--disable-@var{prog}}
1708 @vindex --enable-@var{prog}
1709 @vindex --disable-@var{prog}
1710 Do or do not build and install the program(s) of the module @code{@var{prog}}.
1713 @node @code{--disable-all-pkgs}
1714 @subsection @code{--disable-all-pkgs}
1716 @vindex --disable-all-pkgs
1717 Do not build any program modules by default---only those explicitly
1718 enabled.  This is useful when one wants to work on only a single
1719 program, which is specified with an additional @code{--enable} option,
1720 e.g., @code{--enable-dvipdfm-x}.  It's still simplest to check out and
1721 configure the whole source tree, but at least only the program you are
1722 interested in, and its dependencies, are built.  The @code{configure}
1723 will generally take less than a minute with everything disabled.  (It
1724 is a good idea to run @code{make check} after doing this, and after
1725 making any changes, to ensure that whatever tests have been written
1726 still pass.)
1728 Without this option, all modules are built except those that are
1729 explicitly disabled or specify @code{disable} in their
1730 @file{ac/withenable.ac} fragment.
1733 @node Configure options for @file{texk/web2c}
1734 @subsection Configure options for @file{texk/web2c}
1736 @cindex @code{configure} options, for @code{web2c}
1738 @vindex --with-banner-add=@var{str}
1739 @noindent @code{--with-banner-add=@var{str}}@*Add @code{@var{str}} to the
1740 default version string (@code{TeX Live @var{year}} or @code{Web2C
1741 @var{year}}) appended to banner lines.  This is ignored for a native
1742 TL build, but distro builds should specify, e.g.,
1743 @code{/@var{SomeDistro}}.
1745 @vindex --with-editor=@var{cmd}
1746 @noindent @code{--with-editor=@var{cmd}}@*Specify the command
1747 @code{@var{cmd}} to invoke from the @code{e} option of @TeX{}-like engines,
1748 replacing the default @code{vi +%d '%s'} for Unix or @code{texworks
1749 --position=%d "%s"} for Windows.
1751 @vindex --with-fontconfig-includes=@var{dir}
1752 @vindex --with-fontconfig-libdir=@var{dir}
1753 @noindent @code{--with-fontconfig-includes=@var{dir}},
1754 @code{--with-fontconfig-libdir=@var{dir}}@*Building Xe@TeX{} on
1755 non-Mac systems requires the @code{fontconfig} library headers and
1756 code.  If one or both of these options are given, the required flags
1757 are derived from them; otherwise, they are determined via
1758 @file{pkg-config} (if present).
1760 @cindex X toolkit
1761 @pindex libXt
1762 @pindex Xlib
1763 @noindent @code{--with-mf-x-toolkit}@*Use the X toolkit (@file{libXt}) for
1764 Metafont (the default is to use the lowest-level @file{Xlib} support;
1765 it seems this has the best chance of working across X installations
1766 nowadays).
1768 @vindex --disable-dump-share
1769 @cindex LittleEndian architectures
1770 @noindent @code{--disable-dump-share}@*Make the @code{fmt}/@code{base}
1771 dump files architecture dependent (somewhat faster on LittleEndian
1772 architectures).
1774 @vindex --disable-ipc
1775 @cindex interprocess communication
1776 @noindent @code{--disable-ipc}@*Disable @TeX{}'s @code{--ipc} option.
1778 @vindex --disable-mf-nowin
1779 @pindex mf-nowin
1780 @noindent @code{--disable-mf-nowin}@*Do not build a separate
1781 non-graphically-capable Metafont (@file{mf-nowin}).
1783 @vindex --disable-tex
1784 @vindex --enable-etex
1785 @pindex web2c.ac
1786 @noindent @code{--disable-tex}, @code{--enable-etex}, @dots{}@*Do not or
1787 do build the various @TeX{}, Metafont, and MetaPost engines (defaults are
1788 defined in the fragment @file{texk/web2c/ac/web2c.ac}).
1790 @vindex --disable-web-progs
1791 @noindent @code{--disable-web-progs}@*Do not build the core WEB programs
1792 @file{bibtex}, @dots{}, @file{weave}.  Useful if, e.g., you only want
1793 to (re)build some engines.
1795 @vindex --enable-auto-core
1796 @cindex preloaded binaries
1797 @noindent @code{--enable-auto-core}@*This option causes @TeX{} and Metafont
1798 to produce a core dump when a particular hacky filename is
1799 encountered, for use in creating preloaded binaries.  This is rarely
1800 done nowadays.
1802 @vindex --enable-libtool-hack
1803 @pindex libtool@r{, hack for avoiding excessive linking}
1804 @noindent @code{--enable-libtool-hack}@*
1805 If enabled (which is the default for all platforms), prevents
1806 @code{libtool} from linking explicitly with dependencies of
1807 @file{libfontconfig} such as @file{libexpat}.
1809 @vindex --enable-*win @r{for Metafont window support}
1810 @noindent @code{--enable-*win}@*Include various types of other window
1811 support for Metafont (EPSF output, @code{mftalk}, old terminals, @dots{}).
1813 @vindex --enable-tex-synctex
1814 @vindex --disable-etex-synctex
1815 @cindex synctex
1816 @noindent @code{--enable-tex-synctex}, @code{--disable-etex-synctex},
1817 @dots{}@*Build the @TeX{} engines with or without @code{SyncTeX}
1818 support; ignored for a native @TL{} build, defaults are again defined
1819 in @file{texk/web2c/ac/web2c.ac}.
1821 @vindex --disable-synctex
1822 @cindex synctex
1823 @noindent @code{--disable-synctex}
1824 @*Do not build the @code{SyncTeX} library and tool.
1827 @node Configure options for @file{texk/bibtex-x}
1828 @subsection Configure options for @file{texk/bibtex-x}
1830 @cindex @code{configure} options, for @code{bibtex-x}
1831 @pindex bibtex8
1832 @pindex bibtexu
1833 @pindex bibtex-x
1834 The programs @code{bibtex8} and @code{bibtexu} have been merged into the
1835 module @code{bibtex-x} (extended Bib@TeX{}).
1837 @vindex --disable-bibtex8
1838 @noindent @code{--disable-bibtex8}@*Do not build the @file{bibtex8} program.
1840 @vindex --disable-bibtexu
1841 @noindent @code{--disable-bibtexu}@*Do not build the @file{bibtexu} program
1842 (building @file{bibtexu} requires @code{ICU} libraries).
1845 @node Configure options for @file{texk/dvipdfm-x}
1846 @subsection Configure options for @file{texk/dvipdfm-x}
1848 @cindex @code{configure} options, for @code{dvipdfm-x}
1849 @pindex dvipdfmx
1850 @pindex xdvipdfmx
1852 The former modules @code{dvipdfmx} (extended DVI to PDF converter) and
1853 @code{xdvipdfmx} (the same, as used by Xe@TeX{}) have been merged into
1854 @code{dvipdfm-x} at the source level.  Two separate binaries are still
1855 created by default.  In addition, @file{dvipdfm} is created as a
1856 symlink to @file{dvipdfmx}, with backward-compatible (very slightly
1857 different) behavior.
1859 @vindex --disable-dvipdfmx
1860 @noindent @code{--disable-dvipdfmx}@*Do not build the @file{dvipdfmx}
1861 program with the @file{dvipdfm} symlink.
1863 @vindex --disable-xdvipdfmx
1864 @noindent @code{--disable-xdvipdfmx}@*Do not build the @file{xdvipdfmx}
1865 program.
1868 @node Configure options for @file{texk/dvisvgm}
1869 @subsection Configure options for @file{texk/dvisvgm}
1871 @cindex @code{configure} options, for @file{dvisvgm}
1872 @pindex dvisvgm
1874 @vindex --with-system-libgs
1875 @noindent @code{--with-system-libgs}@*Build @file{dvisvgm} using installed
1876 Ghostscript (@code{gs}) headers and library (not allowed for a native
1877 TL build).  The default is to load the @code{gs} library at runtime if
1878 possible, or otherwise disable support for PostScript specials.
1880 @vindex --without-libgs
1881 @noindent @code{--without-libgs}@*Build @file{dvisvgm} without PostScript
1882 support at all.  Because the dynamic loading just mentioned defeats all
1883 attempts at static linking, the result can crash due to library
1884 incompatibilities, e.g., on CentOS 5.
1886 @vindex --with-libgs-includes@r{,} -libdir
1887 @noindent @code{--with-libgs-includes=@var{dir}},
1888 @code{--with-libgs-libdir=@var{dir}}@*Specify non-standard locations
1889 of the Ghostscript headers and library.
1892 @node Configure options for @file{texk/texlive}
1893 @subsection Configure options for @file{texk/texlive}
1895 @cindex @code{configure} options, for @file{texk/texlive}
1896 @vindex --disable-linked-scripts
1897 @noindent @code{--disable-linked-scripts}@*Do not install the ``linked
1898 scripts'' (@pxref{Linked scripts}), except for the TL scripts required
1899 to run @code{texlinks}.
1902 @node Configure options for @file{texk/xdvik}
1903 @subsection Configure options for @file{texk/xdvik}
1905 @cindex @code{configure} options, for @file{xdvik}
1906 @pindex xdvik
1908 @vindex --with-gs=@var{filename}
1909 @noindent @code{--with-gs=@var{filename}}@*Hardwire the location of Ghostscript
1910 (@file{gs}).
1912 @vindex --with-xdvi-x-toolkit=@var{kit}
1913 @pindex motif
1914 @pindex xaw
1915 @noindent @code{--with-xdvi-x-toolkit=@var{kit}}@*Use toolkit
1916 @code{@var{kit}} for @file{xdvik}, one of: @code{motif xaw xaw3d
1917 neXtaw}.  The default is @code{motif} if available, else @code{xaw}.
1919 @vindex --enable-xi2-scrolling
1920 @pindex XInput
1921 @pindex scrolling
1922 @noindent @code{--enable-xi2-scrolling}@*Use XInput 2.1 ``smooth scrolling''
1923 if available.  (default: yes, except for a native TL build).
1926 @node Configure options for @file{utils/xindy}
1927 @subsection Configure options for @file{utils/xindy}
1929 @cindex @code{configure} options, for @file{xindy}
1930 @pindex xindy
1932 @vindex --enable-xindy-rules
1933 @noindent @code{--enable-xindy-rules}@*Build and install @code{xindy} rules
1934 (default: yes, except for a native TL build).
1936 @vindex --enable-xindy-docs
1937 @noindent @code{--enable-xindy-docs}@*Build and install @code{xindy}
1938 documentation (default: yes, except for a native TL build).
1940 @vindex --with-clisp-runtime=@var{filename}
1941 @pindex lisp.run@r{,} lisp.exe
1942 @cindex CLISP
1943 @noindent @code{--with-clisp-runtime=@var{filename}}@*Specifies the
1944 Full path for the CLISP runtime file (@file{lisp.run} or
1945 @file{lisp.exe}) to be installed.  When specified as @code{default}
1946 (the default for a native TL build) the path is determined by the
1947 CLISP executable; the value @code{system} (not allowed for a native TL
1948 build, but the default for a non-native one) indicates that
1949 @file{xindy} will use the installed version of @file{clisp} (which
1950 must be identical to the one used to build @file{xindy}).
1953 @node Library-specific configure options
1954 @section Library-specific configure options
1956 @cindex library-specific @code{configure} options
1957 @cindex @code{configure} options, library-specific
1958 Here are (some of) the library-specific @code{configure} options,
1959 starting with this generic one:
1961 @vindex --with-system-@var{lib}
1962 @noindent @code{--with-system-@var{lib}}
1964 Use an installed (system) version of the library @code{@var{lib}};
1965 this option exists for most libraries, but is not allowed for a native
1966 TL build.  Using a system version implies also using the system
1967 versions of all libraries (if any) that @var{lib} depends on.
1969 @vindex --with-@var{lib}-includes=@var{dir}@r{,} -libdir
1970 For many libraries @code{--with-@var{lib}-includes=@var{dir}} and
1971 @code{--with-@var{lib}-libdir=@var{dir}} can specify non-standard
1972 search locations; others use @file{pkg-config} or similar to determine
1973 the required flags.
1975 The top-level @file{configure} script performs a consistency check for all
1976 required system libraries and bails out if tests fail.
1978 @menu
1979 * Configure options for @code{kpathsea}::
1980 * Configure options for system @code{poppler}::
1981 @end menu
1984 @node Configure options for @code{kpathsea}
1985 @subsection Configure options for @code{kpathsea}
1987 @cindex @code{configure} options, for @code{kpathsea}
1989 @noindent @code{--enable-@var{cmd}-default},
1990 @code{--disable-@var{cmd}-default}@*Determine the compile time default
1991 whether or not to run @var{cmd}, one of:
1992 @table @code
1993 @item mkocp
1994 (Omega compiled translation process file)
1995 @item mkofm
1996 (Omega font metrics file)
1997 @item mktexfmt
1998 (format/base dump file)
1999 @item mktexmf
2000 (Metafont source)
2001 @item mktexpk
2002 (PK bitmap font)
2003 @item mktextex
2004 (@TeX{} source)
2005 @item mktextfm
2006 (TFM file)
2007 @end table
2009 @noindent to generate the specified type of file dynamically.
2010 The default can be overridden by the user in any case.
2013 @node Configure options for system @code{poppler}
2014 @subsection Configure options for system @code{poppler}
2016 @cindex @code{configure} options, for system @code{poppler}
2018 @pindex poppler
2019 @pindex xpdf @r{as library}
2020 Building Lua@TeX{} (or LuaJIT@TeX{}) and Xe@TeX{} requires
2021 @code{poppler}, either from the TL tree or system headers and
2022 library.  Building pdf@TeX{} requires either @code{xpdf} from
2023 the @TL{} tree or system @code{poppler} headers and library.
2025 @vindex --with-system-poppler
2026 @noindent @code{--with-system-poppler}@*Use a system version (0.18 or
2027 newer) of @code{poppler} for Lua@TeX{} (or LuaJIT@TeX{}) and Xe@TeX{},
2028 and use @file{pkg-config} to obtain the required flags.
2030 @vindex --with-system-xpdf
2031 @noindent @code{--with-system-xpdf}@*Use a system version (0.12 or better)
2032 of @code{poppler} (and @file{pkg-config}) for pdf@TeX{} instead of
2033 @code{xpdf} from the TL tree.  @xref{@code{--disable-largefile}}.
2035 @node Variables for configure
2036 @section Variables for configure
2038 @cindex variables for @code{configure}
2039 @cindex @code{configure} variables
2041 The values for these variables can be specified as @code{configure}
2042 arguments of the form @code{@var{VAR}=@var{value}}.  They can also be
2043 defined in the environment, but that might not work for cross
2044 compilations.
2046 @vtable @code
2047 @item CC
2048 @itemx CXX
2049 @itemx CPPFLAGS
2050 And plenty more.  As usual with Autoconf, these variables specify the
2051 name (or full path) of compilers, preprocessor flags, and similar.
2052 @xref{Preset Output Variables,, autoconf, GNU Autoconf}.
2054 @item CLISP
2055 @pindex clisp
2056 Name (or full path) of the @file{clisp} executable, used to build
2057 @code{xindy}.
2059 @item FT2_CONFIG
2060 @itemx ICU_CONFIG
2061 @itemx PKG_CONFIG
2062 @pindex freetype-config
2063 @pindex icu-config
2064 @pindex libfreetype
2065 @cindex ICU libraries
2066 These specify the name (or path) for the @file{freetype-config},
2067 @file{icu-config}, and @file{pkg-config} commands used to determine the
2068 flags required for system versions of @file{libfreetype}, the ICU
2069 libraries, or many other libraries.
2071 @item KPSEWHICH
2072 @pindex kpsewhich
2073 Name (or path) of an installed @file{kpsewhich} binary, used by
2074 @code{make check} to determine the location of, e.g.,
2075 @file{cmbx10.tfm}.
2077 @item MAKE
2078 @itemx SED
2079 And more. Name (or path) of the @code{make}, @code{sed}, and similar
2080 programs; used at the top level and propagated to all subdirectories.
2082 @item PERL
2083 @itemx LATEX
2084 @itemx PDFLATEX
2085 Name (or full path) for the @file{perl}, @file{latex}, and @file{pdflatex}
2086 commands used, e.g., to build the @code{xindy} documentation.
2088 @end vtable
2091 @node Cross compilation
2092 @chapter Cross compilation
2094 @cindex cross compilation
2095 In a cross compilation a @dfn{build} system is used to create
2096 binaries to be executed on a @dfn{host} system with different
2097 hardware and/or operating system.
2099 @cindex native cross compilation
2100 In simple cases, the build system can execute binaries for the host
2101 system.  This typically occurs for bi-arch systems where, e.g.,
2102 @code{i386-linux} binaries can run on @code{x86_64-linux} systems and
2103 @code{win32} binaries can run on @code{win64} systems.  Although
2104 sometimes called ``native cross'', technically this is not cross
2105 compilation at all.  In most such cases it suffices to specify
2106 suitable compiler flags.  It might be useful to add the configure
2107 option @code{--build=@var{host}} to get the correct canonical host
2108 name, but note that this should @emph{not} be @code{--host=@var{host}}
2109 (@pxref{Hosts and Cross-Compilation,,, autoconf, GNU Autoconf}).
2111 In order to build, e.g., 32-bit binaries with @command{clang} on a 64-bit
2112 MacOSX system one could use:
2114 @example
2115 TL_BUILD_ENV="CC='clang -arch i386' \
2116   CXX='clang++ -arch i386' \
2117   OBJCXX='clang++ -arch i386'" \
2118   ./Build --build=i386-apple-darwin
2119 @end example
2121 @menu
2122 * Cross configuring::           Configuring for cross compilation.
2123 * Cross problems::              Cross compilation problems.
2124 @end menu
2127 @node Cross configuring
2128 @section Cross configuring
2130 @cindex cross compilation configuring
2131 @cindex configuring, for cross compilation
2133 @vindex --host=@var{host}
2134 @vindex --build=@var{host}
2135 In a standard cross compilation, binaries for the host system cannot
2136 execute on the build system and it is necessary to specify the
2137 configure options @code{--host=@var{host}} and
2138 @code{--build=@var{build}} with two different values.
2140 Building binaries requires suitable ``cross'' tools, e.g., compiler,
2141 linker, and archiver, and perhaps a ``cross'' version of
2142 @code{pkg-config} and similar to locate host system libraries.
2143 Autoconf expects that these cross tools are given by their usual
2144 variables or found under their usual name prefixed with
2145 @code{@var{host}-}.  Here a list of such tools and corresponding
2146 variables:
2148 @example
2149 @code{ar}                AR
2150 @code{freetype-config}   FT2_CONFIG
2151 @code{g++}               CXX
2152 @code{gcc}               CC
2153 @code{icu-config}        ICU_CONFIG
2154 @code{objdump}           OBJDUMP
2155 @code{pkg-config}        PKG_CONFIG
2156 @code{ranlib}            RANLIB
2157 @code{strip}             STRIP
2158 @end example
2160 @cindex @code{mingw32}
2161 @noindent In order to, e.g., build @code{mingw32} binaries on
2162 @code{x86_64-linux} with a cross compiler found as
2163 @file{i386-pc-mingw32-gcc} one would specify
2165 @example
2166 --host=i386-pc-mingw32 --build=x86_64-linux-gnu
2167 @end example
2169 @noindent or perhaps
2171 @example
2172 --host=mingw32 --build=x86_64-linux CC=i386-pc-mingw32-gcc
2173 @end example
2175 @noindent but this latter, especially, might require adding @code{CXX} and others.
2177 Configure arguments such as @code{CFLAGS=@dots{}} refer to the cross
2178 compiler.  If necessary, you can specify compilers and flags for the
2179 few auxiliary C and C++ programs required for the build process as
2180 configure arguments
2182 @vindex BUILDCC@r{,} BUILDCFLAGS@r{, @dots{}}
2183 @example
2184 BUILDCC=@dots{}
2185 BUILDCPPFLAGS=@dots{}
2186 BUILDCFLAGS=@dots{}
2187 BUILDCXX=@dots{}
2188 BUILDCXXFLAGS=@dots{}
2189 BUILDLDFLAGS=@dots{}
2190 @end example
2193 @node Cross problems
2194 @section Cross problems
2196 @cindex cross compilation problems
2198 The fact that binaries for the host system cannot be executed on the
2199 build system causes some problems.
2201 One problem is that configure tests using @code{AC_RUN_IFELSE} can
2202 compile and link the test program but cannot execute it.  Such tests
2203 should be avoided if possible and otherwise must supply a pessimistic
2204 test result.
2206 @pindex squeeze
2207 @pindex web2c @r{program}
2208 @cindex @code{freetype} cross compiling
2209 @vindex CC_BUILD
2210 Another problem arises if the build process must execute some
2211 (auxiliary or installable) programs.  Auxiliary programs can be placed
2212 into a subdirectory that is configured natively as is done for
2213 @file{texk/web2c/web2c}, @file{texk/dvipsk/squeeze}, and
2214 @file{texk/xdvik/squeeze}.  The module @file{libs/freetype2} uses the
2215 value of @code{CC_BUILD}, @file{@var{build}-gcc}, @file{gcc}, or
2216 @file{cc} as the compiler for the auxiliary program.
2218 @cindex ICU cross compiling
2219 The situation for installable programs needed by the build process is
2220 somewhat different.  A rather expensive possibility, chosen for the ICU
2221 libraries in module @file{libs/icu}, is to first compile natively for
2222 the build system and in a second step to use these (uninstalled)
2223 programs during the cross compilation.
2225 @pindex tangle
2226 @pindex ctangle
2227 @pindex otangle
2228 @pindex tie
2229 This approach would also be possible for the tools such as
2230 @file{tangle} used in the module @file{texk/web2c} to build the WEB
2231 programs, but that would require first building a native
2232 @code{kpathsea} library.  To avoid this complication, cross
2233 compilation of the WEB or CWEB programs requires sufficiently recent
2234 installed versions of @file{tangle}, @file{ctangle}, @file{otangle},
2235 and @file{tie}.
2237 @cindex @code{xindy} cross compiling impossible
2238 Building @code{xindy} requires running the host system @file{clisp}
2239 binary, thus cross compilation is not possible.
2242 @node Coding conventions
2243 @chapter Coding conventions
2245 @cindex coding conventions
2246 @cindex conventions, coding
2248 Ideally, building all of @TL{} with @code{--enable-compiler-warnings=max}
2249 should produce no (GCC) compiler warnings at all.  In spite of
2250 considerable efforts into that direction we are still far from that goal and
2251 there are reasons that we may never fully reach it.  Below are some rules
2252 about declarations of functions or variables and the use of @code{const}. 
2253 These rules should be applied to all parts of the @TL{} tree, except some of
2254 those maintained independently.
2256 @menu
2257 * Declarations and definitions::
2258 * Const::
2259 @end menu
2262 @node Declarations and definitions
2263 @section Declarations and definitions
2265 @cindex declarations and definitions, in source code
2266 @cindex source code declarations
2267 @cindex ANSI C
2268 @cindex C, ANSI, required
2269 @cindex C99, avoided
2271 @subsubheading C standards
2273 The @TL{} build system no longer supports pre-ANSI C compilers.  Thus
2274 all function prototypes and definitions must conform to the ANSI C
2275 standard (including @code{void} in the declaration of C functions with
2276 no parameters).  On the other hand, TL is built for a wide variety of
2277 systems, not all of which support the C99 standard.  Therefore using
2278 C99 features should be avoided if that can easily be done.  In
2279 particular C code must not contain declarations after statements or
2280 C++-style comments.
2282 @pindex chktex
2283 @findex stpcpy
2284 If some C99 (or later) constructs must be used, the module should
2285 verify that they are available and otherwise provide an alternative.
2286 For example, the module @file{texk/chktex} uses the C99 function
2287 @code{stpcpy()} that may or may not be available on a particular
2288 system.  It uses @code{AC_CHECK_DECLS([stpcpy])} in
2289 @file{configure.ac} to test this, and provides the perhaps slightly
2290 less efficient alternative
2292 @example
2293 #if !(defined HAVE_DECL_STPCPY && HAVE_DECL_STPCPY)
2294 static inline char *stpcpy(char *dest, const char *src)
2296   return strcpy(dest, src) + strlen(src);
2298 #endif
2299 @end example
2301 @noindent in the file @file{Utility.h}.
2304 @subsubheading Static functions
2306 @cindex @code{static} functions
2307 Functions used in only one file should be declared @code{static}; they
2308 require no prototype except as forward declaration.
2310 @subsubheading Extern functions
2312 @cindex @code{extern} functions
2313 Functions not declared @code{static}, usually because they are used in
2314 several files, require an (@code{extern}) prototype in exactly one
2315 header file, which is included in the file defining the function and
2316 in all files using that function---this is the only way to guarantee
2317 consistency between definition and use.  There should be no
2318 @code{extern} declarations sprinkled throughout the C code (with or
2319 without comments as to where that function is defined).
2321 @subsubheading Variable declarations
2323 @cindex variable declarations, in source code
2324 The declaration of global variables follows analogous rules: they are
2325 either declared @code{static} if used in only one file or declared
2326 @code{extern} in exactly one header and instantiated in exactly one
2327 file.
2329 @node Const
2330 @section Const
2332 @cindex @code{const}
2334 The @code{const} feature of C is valuable, but easy to mis-use.
2336 @subsubheading Function parameters
2338 Ideally, a function parameter not modified by the function should be
2339 declared as @code{const}.  This is important in particular for strings
2340 (@code{char*}) because the actual arguments are often string literals.
2341 It is perfectly legitimate and safe to use a type @code{char*} value
2342 for a type @code{const char*} variable (in an assignment, as
2343 initializer, as function argument, or as return value).  It is equally
2344 safe to use a type @code{char**} value for a type @code{const
2345 char*const*} variable, but not for a type @code{const char**} variable
2346 since that might cause modification of a quantity supposed to be
2347 constant.
2349 @cindex X11 headers, and @code{const}
2350 @cindex @code{libfreetype}, and @code{const}
2351 Getting all @code{const} qualifiers right can get quite involved but
2352 can almost always be done.  There are only a couple notable
2353 exceptions: the X11 headers are full of declarations that ought to use
2354 @code{const} but do not, and the same is true to some extent for
2355 @file{libfreetype} (but, thankfully, not for @code{zlib} nowadays).
2357 @subsubheading What must be avoided with @code{const}
2359 @cindex warning, discards qualifiers
2360 @cindex discards qualifiers warning
2361 The GCC compiler warnings ``assignment discards qualifiers@dots{}''
2362 and analogous warnings for ``initialization'', ``passing arg'', or
2363 ``return'' must be strenously avoided in our own code.  The only
2364 exception is when they are caused by X11 headers or macros or other
2365 third party code.
2367 @subsubheading What should be avoided with @code{const}
2369 @cindex type cast, avoiding
2370 A type cast, e.g., from @code{const char*} to @code{char*} does not
2371 solve any problems; depending on warning options, it may only hide
2372 them.  Therefore such casts should be avoided whenever possible and
2373 otherwise must be carefully analyzed to make sure that they cannot
2374 cause the modification of quantities supposed to be constant.
2376 @c made from pod doc.
2377 @include tlbuild-incl/install-tl.texi
2378 @include tlbuild-incl/tlmgr.texi
2380 @node Index
2381 @unnumbered Index
2383 @printindex cp
2385 @bye