| 1 |
(This file was generated by makeinfo and splitinfo.gawk.) |
| 2 |
(Released under the old-style GNU documentation license; |
| 3 |
see sources or other output files for full text.) |
| 4 |
|
| 5 |
4 Building |
| 6 |
********** |
| 7 |
|
| 8 |
The top-level 'Build' script is intended to simplify building the |
| 9 |
binaries distributed with TeX Live itself--we call this the "native" TL |
| 10 |
build. It runs 'configure && make world', which builds everything in a |
| 11 |
subdirectory of the main source tree (default 'Work/'), installs |
| 12 |
everything in another subdirectory (default 'inst/'), and finally runs |
| 13 |
'make check'. The exact directory and command names can be specified |
| 14 |
via environment variables and a few leading options. All remaining |
| 15 |
arguments (assignments or options) are passed to the 'configure' script. |
| 16 |
Please take a look at the './Build' source file for more information; it |
| 17 |
is a straightforward shell script. |
| 18 |
|
| 19 |
An alternative, and the one we will mainly discuss here, is to run |
| 20 |
'configure' and 'make' in a suitable empty subdirectory. Building in |
| 21 |
the source directory itself is not supported (sorry). |
| 22 |
|
| 23 |
4.1 Build iteration |
| 24 |
=================== |
| 25 |
|
| 26 |
Running the top-level 'configure' script configures the top level and |
| 27 |
the subdirectories 'libs', 'utils', and 'texk'. Running 'make' at the |
| 28 |
top level first iterates over the TeX-specific libraries, and then runs |
| 29 |
'make' in 'libs', 'utils', and 'texk' to iterate over the generic |
| 30 |
libraries, utility programs, and TeX-specific programs, respectively. |
| 31 |
These iterations consist of two steps: |
| 32 |
|
| 33 |
1. For each library or program module not yet configured, run |
| 34 |
'configure', adding the configure option '--disable-build' if the |
| 35 |
module need not be built, otherwise running 'make all'. |
| 36 |
|
| 37 |
2. For each library or program module that must be built, run 'make' |
| 38 |
for the selected target(s): 'default' or 'all' to (re-)build, |
| 39 |
'check' to run tests, 'install', etc. |
| 40 |
|
| 41 |
Running the top-level 'make' a second time iterates again over all |
| 42 |
the library and program modules, and finds (should find) nothing to be |
| 43 |
done. |
| 44 |
|
| 45 |
4.2 Build in parallel |
| 46 |
===================== |
| 47 |
|
| 48 |
The TL build system carefully formulates dependencies as well as 'make' |
| 49 |
rules when a tool (such as 'tangle', 'ctangle', and 'convert') creates |
| 50 |
several output files. This allows for parallel builds ('make -j N' with |
| 51 |
N>1 or even 'make -j') that can considerably speed up the TL build. |
| 52 |
|
| 53 |
If you're using TL's 'Build' script, you can enable '-j' with the |
| 54 |
environment variable 'TL_MAKE_FLAGS', as in: 'env |
| 55 |
TL_MAKE_FLAGS=-j`nproc` ./Build'. |
| 56 |
|
| 57 |
Independently, a noticeable speed-up can also be gained by using a |
| 58 |
configure cache file, i.e., specifying the 'configure' option '-C' |
| 59 |
(recommended). |
| 60 |
|
| 61 |
4.3 Build distribution |
| 62 |
====================== |
| 63 |
|
| 64 |
Running 'make dist' or related targets at the top level outputs an error |
| 65 |
message and fails. We no longer try to keep 'make dist' working, |
| 66 |
although it could be restored if there is some use for it. |
| 67 |
|
| 68 |
The 'dist' target used to create a tarball |
| 69 |
'tex-live-YYYY-MM-DD.tar.xz' from the TL source tree, and 'distcheck' |
| 70 |
also verifies that this tarball suffices to build and install all of TL. |
| 71 |
|
| 72 |
However, the result was not a complete or even usable TeX system, |
| 73 |
since all the support files are lacking. We do not actually distribute |
| 74 |
any such tarball, and have no plans to do so. |
| 75 |
|
| 76 |
See Installing, for more information on what to do with the results |
| 77 |
of a build. |
| 78 |
|
| 79 |
4.4 Build one package |
| 80 |
===================== |
| 81 |
|
| 82 |
To build one package, the basic idea is to use the 'configure' option |
| 83 |
'--disable-all-pkgs' (see --disable-all-pkgs). Then all program and |
| 84 |
library modules are configured but none are made. However, the |
| 85 |
'Makefile's still contain all build rules and dependencies and can be |
| 86 |
invoked to build an individual program or library, first building any |
| 87 |
required libraries. |
| 88 |
|
| 89 |
Here is an example from start to finish for working on 'dvipdfm-x'. |
| 90 |
Unfortunately, this does not suffice for building the TeX engines; see |
| 91 |
the next section. |
| 92 |
|
| 93 |
mkdir mydir && cd mydir # new working directory |
| 94 |
|
| 95 |
# Get sources (<https://tug.org/texlive/svn>), e.g.: |
| 96 |
rsync -a --delete --exclude=.svn --exclude=Work \ |
| 97 |
tug.org::tldevsrc/Build/source/ . |
| 98 |
|
| 99 |
# Create build directory: |
| 100 |
mkdir Work && cd Work |
| 101 |
|
| 102 |
# Do the configure: |
| 103 |
../configure --disable-all-pkgs --enable-dvipdfm-x \ |
| 104 |
-C CFLAGS=-g CXXFLAGS=-g >&outc || echo fail |
| 105 |
|
| 106 |
# Do the make: |
| 107 |
make >&outm || echo fail |
| 108 |
|
| 109 |
# Run the tests: |
| 110 |
cd texk/dvipdfm-x |
| 111 |
make check |
| 112 |
|
| 113 |
# Run the new binary in the build tree, finding support files |
| 114 |
# in a separate tree for a TeX Live release YYYY |
| 115 |
# (Bourne shell syntax): |
| 116 |
TEXMFROOT=/usr/local/texlive/YYYY \ |
| 117 |
TEXMFCNF=$TEXMFROOT/texmf-dist/web2c \ |
| 118 |
./xdvipdfmx ... |
| 119 |
|
| 120 |
Then you can modify source files in 'mydir/texk/dvipdfm-x' and rerun |
| 121 |
'make' in 'mydir/Work/texk/dvipdfm-x' to rebuild; that build directory |
| 122 |
is where the binary ends up and where you can run a debugger, etc. |
| 123 |
|
| 124 |
The second line of the 'configure' invocation shows examples of extra |
| 125 |
things you likely want to specify if you intend to hack the sources (and |
| 126 |
not just build binaries): the '-C' speeds 'configure' by enabling a |
| 127 |
cache file, and the 'CFLAGS' and 'CXXFLAGS' settings eliminate compiler |
| 128 |
optimization for debugging purposes. |
| 129 |
|
| 130 |
Of course, you need to actually look at the output and check that |
| 131 |
things are working. There are many 'configure' options you can tweak as |
| 132 |
desired; check the output from 'configure --help'. It is also a good |
| 133 |
idea to run 'make check' after making any changes, to ensure that |
| 134 |
whatever tests have been written still pass. |
| 135 |
|
| 136 |
Reducing source download size |
| 137 |
............................. |
| 138 |
|
| 139 |
The above retrieves the entire TL source tree (several hundred |
| 140 |
megabytes). It is natural to ask if this is really necessary. Strictly |
| 141 |
speaking, the answer is no, but it is vastly more convenient to do so. |
| 142 |
If you cut down the source tree, you must also give additional |
| 143 |
'configure' flags to individually disable using system versions of |
| 144 |
libraries, or the intricacies of the dependencies (such as 'teckit' |
| 145 |
requiring 'zlib') will have undesired side effects. For an example of |
| 146 |
this approach, see the 'build-pdftex.sh' script in the 'pdftex' |
| 147 |
development source (details at <http://pdftex.org>), which is indeed |
| 148 |
such a cut-down TL source tree. |
| 149 |
|
| 150 |
GCC used by default |
| 151 |
................... |
| 152 |
|
| 153 |
By default, the 'gcc' compilers will be used if present; otherwise, |
| 154 |
individual packages may use something different. You can explicitly |
| 155 |
specify the compilers to be used with the environment variables 'CC', |
| 156 |
'CXX', and 'OBJCXX'. |
| 157 |
|
| 158 |
Removing C+11 dependency |
| 159 |
........................ |
| 160 |
|
| 161 |
Some libraries and programs require C++11; one such is XeTeX. If you |
| 162 |
want to build with an older compiler lacking such support, you need to |
| 163 |
(re)move those source directories; unfortunately, specifying '--disable' |
| 164 |
for them does not suffice. It's also necessary to specify |
| 165 |
'--disable-xetex' explicitly. Specifically, before running 'configure |
| 166 |
--disable-xetex ...': |
| 167 |
|
| 168 |
rm -rf libs/icu libs/graphite2 texk/dvisvgm texk/web2c/xetexdir |
| 169 |
|
| 170 |
Also, even with '--disable-all-pkgs', dependencies are (currently) |
| 171 |
checked. One notable case: if a (non-MacOS) system does not have |
| 172 |
'fontconfig', XeTeX cannot be built (see Prerequisites), and 'configure' |
| 173 |
will terminate even with '--disable-xetex'. To proceed without such |
| 174 |
dependencies, specify '--enable-missing' also. |
| 175 |
|
| 176 |
As of 2022, HarfBuzz also requires C++11. Therefore even more would |
| 177 |
have to be disabled and removed, notably including 'luahbtex', the |
| 178 |
standard engine used for LuaLaTeX. Removing that would not be |
| 179 |
acceptable for builds intended for distribution; but perhaps for testing |
| 180 |
the above information could still be useful. |
| 181 |
|
| 182 |
In general, the TL 'configure' will run in all directories. |
| 183 |
Therefore a general workaround for build problems is to remove failing |
| 184 |
directories from the tree, and also specify the relevant '--disable-...' |
| 185 |
option(s). |
| 186 |
|
| 187 |
Patches to improve all this would be most welcome. |
| 188 |
|
| 189 |
4.5 Build one engine |
| 190 |
==================== |
| 191 |
|
| 192 |
Unfortunately, there is one common case where the steps in the preceding |
| 193 |
section to build one package (see Build one package) do not suffice: |
| 194 |
wanting to build one, or a subset, of the TeX engines (or other Web2c |
| 195 |
programs). |
| 196 |
|
| 197 |
The simplest way to do this is to disable everything and then |
| 198 |
explicitly specify what to make. For example, to build only the |
| 199 |
original TeX: |
| 200 |
|
| 201 |
cd Work # top build directory |
| 202 |
../configure --without-x --disable-shared --disable-all-pkgs \ |
| 203 |
--enable-tex --disable-synctex --disable-xetex \ |
| 204 |
--enable-missing -C CFLAGS=-g CXXFLAGS=-g |
| 205 |
make |
| 206 |
cd texk/web2c # cd engine build directory |
| 207 |
make tex # must specify target |
| 208 |
|
| 209 |
The first 'make' run will configure everything, and even build the |
| 210 |
libraries, even though the packages are disabled. |
| 211 |
|
| 212 |
The source tree can be cut down to just what is needed for the given |
| 213 |
engine (the separate pdfTeX and LuaTeX source repositories do this, for |
| 214 |
example), but see caveats in previous section. When the |
| 215 |
'--disable-xetex' and '--enable-missing' options are needed is also |
| 216 |
explained in the previous section. |
| 217 |
|
| 218 |
If you want to debug an X-related program or shared library setup, or |
| 219 |
other variants, change the 'configure' options accordingly. Either |
| 220 |
'../Build' or '../configure' can be run. |
| 221 |
|
| 222 |
Then it is necessary to again specify the target engine ('tex', in |
| 223 |
the above) in the 'make'. |
| 224 |
|
| 225 |
All these complications are rather unfortunate. Patches are welcome. |
| 226 |
|
| 227 |
Testing one engine |
| 228 |
.................. |
| 229 |
|
| 230 |
To run only the tests for a given engine, say 'hitex': |
| 231 |
|
| 232 |
make -C $ww check SUBDIRS=. TESTS='$(hitex_tests)' |
| 233 |
|
| 234 |
where '$ww' is the web2c build directory, that is, |
| 235 |
'ww=/.../Build/source/Work/texk/web2c'. |
| 236 |
|
| 237 |
It's also possible to run individual tests the same way, using the |
| 238 |
test name exactly as specified in the '.am' file: |
| 239 |
|
| 240 |
make -C $ww check SUBDIRS=. TESTS=hitexdir/tests/hello.test |
| 241 |
|
| 242 |
Without the 'SUBDIRS=.', errors like this will show up, since 'make' |
| 243 |
will descend into every directory. |
| 244 |
|
| 245 |
fatal: making test-suite.log: failed to create hitexdir/tests/hello.test |
| 246 |
|
| 247 |
If you get tired of looking at the 'Entering'/'Leaving directory' |
| 248 |
lines, you can add the (GNU) make option '--no-print-dir'. |
| 249 |
|
| 250 |
You may find it useful to put lengthy incantations like this into a |
| 251 |
trivial shell script with a short name (say, 'hitch'). Then you just |
| 252 |
run 'hitch' and edit the file when necessary to change the options. |
| 253 |
|
| 254 |
4.6 Cross compilation |
| 255 |
===================== |
| 256 |
|
| 257 |
In a cross compilation a "build" system is used to create binaries to be |
| 258 |
executed on a "host" system with different hardware and/or operating |
| 259 |
system. |
| 260 |
|
| 261 |
In simple cases, the build system can execute binaries for the host |
| 262 |
system. This typically occurs for bi-arch systems where, e.g., |
| 263 |
'i386-linux' binaries can run on 'x86_64-linux' systems and 'win32' |
| 264 |
binaries can run on 'win64' systems. Although sometimes called "native |
| 265 |
cross", technically this is not cross compilation at all. In most such |
| 266 |
cases it suffices to specify suitable compiler flags. It might be |
| 267 |
useful to add the configure option '--build=HOST' to get the correct |
| 268 |
canonical host name, but note that this should _not_ be '--host=HOST' |
| 269 |
(see (autoconf)Hosts and Cross-Compilation). |
| 270 |
|
| 271 |
In order to build, e.g., 32-bit binaries with 'clang' on a 64-bit |
| 272 |
MacOS system one could use: |
| 273 |
|
| 274 |
TL_BUILD_ENV="CC='clang -arch i386' \ |
| 275 |
CXX='clang++ -arch i386' \ |
| 276 |
OBJCXX='clang++ -arch i386'" \ |
| 277 |
./Build --build=i386-apple-darwin |
| 278 |
|
| 279 |
4.6.1 Cross configuring |
| 280 |
----------------------- |
| 281 |
|
| 282 |
In a standard cross compilation, binaries for the host system cannot |
| 283 |
execute on the build system and it is necessary to specify the configure |
| 284 |
options '--host=HOST' and '--build=BUILD' with two different values. |
| 285 |
|
| 286 |
Building binaries requires suitable "cross" tools, e.g., compiler, |
| 287 |
linker, and archiver, and perhaps a "cross" version of 'pkg-config' and |
| 288 |
similar to locate host system libraries. Autoconf expects that these |
| 289 |
cross tools are given by their usual variables or found under their |
| 290 |
usual name prefixed with 'HOST-'. Here a list of such tools and |
| 291 |
corresponding variables: |
| 292 |
|
| 293 |
ar AR |
| 294 |
freetype-config FT2_CONFIG |
| 295 |
g++ CXX |
| 296 |
gcc CC |
| 297 |
icu-config ICU_CONFIG |
| 298 |
objdump OBJDUMP |
| 299 |
pkg-config PKG_CONFIG |
| 300 |
ranlib RANLIB |
| 301 |
strip STRIP |
| 302 |
|
| 303 |
In order to, e.g., build 'mingw32' binaries on 'x86_64-linux' with a |
| 304 |
cross compiler found as 'i386-pc-mingw32-gcc' one would specify |
| 305 |
|
| 306 |
--host=i386-pc-mingw32 --build=x86_64-linux-gnu |
| 307 |
|
| 308 |
or perhaps |
| 309 |
|
| 310 |
--host=mingw32 --build=x86_64-linux CC=i386-pc-mingw32-gcc |
| 311 |
|
| 312 |
but this latter, especially, might require adding 'CXX' and others. |
| 313 |
|
| 314 |
Configure arguments such as 'CFLAGS=...' refer to the cross compiler. |
| 315 |
If necessary, you can specify compilers and flags for the few auxiliary |
| 316 |
C and C++ programs required for the build process as configure arguments |
| 317 |
|
| 318 |
BUILDCC=... |
| 319 |
BUILDCPPFLAGS=... |
| 320 |
BUILDCFLAGS=... |
| 321 |
BUILDCXX=... |
| 322 |
BUILDCXXFLAGS=... |
| 323 |
BUILDLDFLAGS=... |
| 324 |
|
| 325 |
4.6.2 Cross problems |
| 326 |
-------------------- |
| 327 |
|
| 328 |
The fact that binaries for the host system cannot be executed on the |
| 329 |
build system causes some problems. |
| 330 |
|
| 331 |
One problem is that configure tests using 'AC_RUN_IFELSE' can compile |
| 332 |
and link the test program but cannot execute it. Such tests should be |
| 333 |
avoided if possible and otherwise must supply a pessimistic test result. |
| 334 |
|
| 335 |
Another problem arises if the build process must execute some |
| 336 |
(auxiliary or installable) programs. Auxiliary programs can be placed |
| 337 |
into a subdirectory that is configured natively as is done for |
| 338 |
'texk/web2c/web2c', 'texk/dvipsk/squeeze', and 'texk/xdvik/squeeze'. |
| 339 |
The module 'libs/freetype2' uses the value of 'CC_BUILD', 'BUILD-gcc', |
| 340 |
'gcc', or 'cc' as the compiler for the auxiliary program. |
| 341 |
|
| 342 |
The situation for installable programs needed by the build process is |
| 343 |
somewhat different. A rather expensive possibility, chosen for the ICU |
| 344 |
libraries in module 'libs/icu', is to first compile natively for the |
| 345 |
build system and in a second step to use these (uninstalled) programs |
| 346 |
during the cross compilation. |
| 347 |
|
| 348 |
This approach would also be possible for the tools such as 'tangle' |
| 349 |
used in the module 'texk/web2c' to build the WEB programs, but that |
| 350 |
would require first building a native 'kpathsea' library. To avoid this |
| 351 |
complication, cross compilation of programs written in (C)WEB requires |
| 352 |
sufficiently recent installed versions of 'tangle', 'ctangle', |
| 353 |
'otangle', and 'tie'. |
| 354 |
|
| 355 |
Building 'xindy' requires running the host system 'clisp' binary, |
| 356 |
thus cross compilation is painful, but possible. |
| 357 |
|