xz: Fix return value type in io_write_buf().
[xz/debian.git] / INSTALL
blobc42a968aa46bf22f17cac7d01424a86a226a594d
2 XZ Utils Installation
3 =====================
5     0. Preface
6     1. Supported platforms
7        1.1. Compilers
8        1.2. Platform-specific notes
9             1.2.1. AIX
10             1.2.2. IRIX
11             1.2.3. MINIX 3
12             1.2.4. OpenVMS
13             1.2.5. Solaris, OpenSolaris, and derivatives
14             1.2.6. Tru64
15             1.2.7. Windows
16             1.2.8. DOS
17        1.3. Adding support for new platforms
18     2. configure options
19        2.1. Static vs. dynamic linking of liblzma
20        2.2. Optimizing xzdec and lzmadec
21     3. xzgrep and other scripts
22        3.1. Dependencies
23        3.2. PATH
24     4. Troubleshooting
25        4.1. "No C99 compiler was found."
26        4.2. "No POSIX conforming shell (sh) was found."
27        4.3. configure works but build fails at crc32_x86.S
28        4.4. Lots of warnings about symbol visibility
31 0. Preface
32 ----------
34     If you aren't familiar with building packages that use GNU Autotools,
35     see the file INSTALL.generic for generic instructions before reading
36     further.
38     If you are going to build a package for distribution, see also the
39     file PACKAGERS. It contains information that should help making the
40     binary packages as good as possible, but the information isn't very
41     interesting to those making local builds for private use or for use
42     in special situations like embedded systems.
45 1. Supported platforms
46 ----------------------
48     XZ Utils are developed on GNU/Linux, but they should work on many
49     POSIX-like operating systems like *BSDs and Solaris, and even on
50     a few non-POSIX operating systems.
53 1.1. Compilers
55     A C99 compiler is required to compile XZ Utils. If you use GCC, you
56     need at least version 3.x.x. GCC version 2.xx.x doesn't support some
57     C99 features used in XZ Utils source code, thus GCC 2 won't compile
58     XZ Utils.
60     XZ Utils takes advantage of some GNU C extensions when building
61     with GCC. Because these extensions are used only when building
62     with GCC, it should be possible to use any C99 compiler.
65 1.2. Platform-specific notes
67 1.2.1. AIX
69     If you use IBM XL C compiler, pass CC=xlc_r to configure. If
70     you use CC=xlc instead, you must disable threading support
71     with --disable-threads (usually not recommended).
74 1.2.2. IRIX
76     MIPSpro 7.4.4m has been reported to produce broken code if using
77     the -O2 optimization flag ("make check" fails). Using -O1 should
78     work.
80     A problem has been reported when using shared liblzma. Passing
81     --disable-shared to configure works around this. Alternatively,
82     putting "-64" to CFLAGS to build a 64-bit version might help too.
85 1.2.3. MINIX 3
87     The default install of MINIX 3 includes Amsterdam Compiler Kit (ACK),
88     which doesn't support C99. Install GCC to compile XZ Utils.
90     MINIX 3.1.8 and older have bugs in /usr/include/stdint.h, which has
91     to be patched before XZ Utils can be compiled correctly. See
92     <http://gforge.cs.vu.nl/gf/project/minix/tracker/?action=TrackerItemEdit&tracker_item_id=537>.
94     MINIX 3.2.0 and later use a different libc and aren't affected by
95     the above bug.
97     XZ Utils doesn't have code to detect the amount of physical RAM and
98     number of CPU cores on MINIX 3.
100     See section 4.4 in this file about symbol visibility warnings (you
101     may want to pass gl_cv_cc_visibility=no to configure).
104 1.2.4. OpenVMS
106     XZ Utils can be built for OpenVMS, but the build system files
107     are not included in the XZ Utils source package. The required
108     OpenVMS-specific files are maintained by Jouk Jansen and can be
109     downloaded here:
111         http://nchrem.tnw.tudelft.nl/openvms/software2.html#xzutils
114 1.2.5. Solaris, OpenSolaris, and derivatives
116     The following linker error has been reported on some x86 systems:
118         ld: fatal: relocation error: R_386_GOTOFF: ...
120     This can be worked around by passing gl_cv_cc_visibility=no
121     as an argument to the configure script.
124 1.2.6. Tru64
126     If you try to use the native C compiler on Tru64 (passing CC=cc to
127     configure), you may need the workaround mention in section 4.1 in
128     this file (pass also ac_cv_prog_cc_c99= to configure).
131 1.2.7. Windows
133     Building XZ Utils on Windows is supported under MinGW + MSYS,
134     MinGW-w64 + MSYS, and Cygwin. There is windows/build.bash to
135     ease packaging XZ Utils with MinGW(-w64) + MSYS into a
136     redistributable .zip or .7z file. See windows/INSTALL-Windows.txt
137     for more information.
139     It might be possible to build liblzma with a non-GNU toolchain too,
140     but that will probably require writing a separate makefile. Building
141     the command line tools with non-GNU toolchains will be harder than
142     building only liblzma.
144     Even if liblzma is built with MinGW, the resulting DLL or static
145     library can be used by other compilers and linkers, including MSVC.
146     Thus, it shouldn't be a problem to use MinGW to build liblzma even
147     if you cannot use MinGW to build the rest of your project. See
148     windows/README-Windows.txt for details.
151 1.2.8. DOS
153     There is an experimental Makefile in the "dos" directory to build
154     XZ Utils on DOS using DJGPP. Support for long file names (LFN) is
155     needed. See dos/README for more information.
157     GNU Autotools based build hasn't been tried on DOS. If you try, I
158     would like to hear if it worked.
161 1.3. Adding support for new platforms
163     If you have written patches to make XZ Utils to work on previously
164     unsupported platform, please send the patches to me! I will consider
165     including them to the official version. It's nice to minimize the
166     need of third-party patching.
168     One exception: Don't request or send patches to change the whole
169     source package to C89. I find C99 substantially nicer to write and
170     maintain. However, the public library headers must be in C89 to
171     avoid frustrating those who maintain programs, which are strictly
172     in C89 or C++.
175 2. configure options
176 --------------------
178     In most cases, the defaults are what you want. Many of the options
179     below are useful only when building a size-optimized version of
180     liblzma or command line tools.
182     --enable-encoders=LIST
183     --disable-encoders
184                 Specify a comma-separated LIST of filter encoders to
185                 build. See "./configure --help" for exact list of
186                 available filter encoders. The default is to build all
187                 supported encoders.
189                 If LIST is empty or --disable-encoders is used, no filter
190                 encoders will be built and also the code shared between
191                 encoders will be omitted.
193                 Disabling encoders will remove some symbols from the
194                 liblzma ABI, so this option should be used only when it
195                 is known to not cause problems.
197     --enable-decoders=LIST
198     --disable-decoders
199                 This is like --enable-encoders but for decoders. The
200                 default is to build all supported decoders.
202     --enable-match-finders=LIST
203                 liblzma includes two categories of match finders:
204                 hash chains and binary trees. Hash chains (hc3 and hc4)
205                 are quite fast but they don't provide the best compression
206                 ratio. Binary trees (bt2, bt3 and bt4) give excellent
207                 compression ratio, but they are slower and need more
208                 memory than hash chains.
210                 You need to enable at least one match finder to build the
211                 LZMA1 or LZMA2 filter encoders. Usually hash chains are
212                 used only in the fast mode, while binary trees are used to
213                 when the best compression ratio is wanted.
215                 The default is to build all the match finders if LZMA1
216                 or LZMA2 filter encoders are being built.
218     --enable-checks=LIST
219                 liblzma support multiple integrity checks. CRC32 is
220                 mandatory, and cannot be omitted. See "./configure --help"
221                 for exact list of available integrity check types.
223                 liblzma and the command line tools can decompress files
224                 which use unsupported integrity check type, but naturally
225                 the file integrity cannot be verified in that case.
227                 Disabling integrity checks may remove some symbols from
228                 the liblzma ABI, so this option should be used only when
229                 it is known to not cause problems.
231     --disable-xz
232     --disable-xzdec
233     --disable-lzmadec
234     --disable-lzmainfo
235                 Don't build and install the command line tool mentioned
236                 in the option name.
238                 NOTE: Disabling xz will skip some tests in "make check".
240                 NOTE: If xzdec is disabled and lzmadec is left enabled,
241                 a dangling man page symlink lzmadec.1 -> xzdec.1 is
242                 created.
244     --disable-lzma-links
245                 Don't create symlinks for LZMA Utils compatibility.
246                 This includes lzma, unlzma, and lzcat. If scripts are
247                 installed, also lzdiff, lzcmp, lzgrep, lzegrep, lzfgrep,
248                 lzmore, and lzless will be omitted if this option is used.
250     --disable-scripts
251                 Don't install the scripts xzdiff, xzgrep, xzmore, xzless,
252                 and their symlinks.
254     --disable-assembler
255                 liblzma includes some assembler optimizations. Currently
256                 there is only assembler code for CRC32 and CRC64 for
257                 32-bit x86.
259                 All the assembler code in liblzma is position-independent
260                 code, which is suitable for use in shared libraries and
261                 position-independent executables. So far only i386
262                 instructions are used, but the code is optimized for i686
263                 class CPUs. If you are compiling liblzma exclusively for
264                 pre-i686 systems, you may want to disable the assembler
265                 code.
267     --enable-unaligned-access
268                 Allow liblzma to use unaligned memory access for 16-bit
269                 and 32-bit loads and stores. This should be enabled only
270                 when the hardware supports this, i.e. when unaligned
271                 access is fast. Some operating system kernels emulate
272                 unaligned access, which is extremely slow. This option
273                 shouldn't be used on systems that rely on such emulation.
275                 Unaligned access is enabled by default on x86, x86-64,
276                 and big endian PowerPC.
278     --enable-small
279                 Reduce the size of liblzma by selecting smaller but
280                 semantically equivalent version of some functions, and
281                 omit precomputed lookup tables. This option tends to
282                 make liblzma slightly slower.
284                 Note that while omitting the precomputed tables makes
285                 liblzma smaller on disk, the tables are still needed at
286                 run time, and need to be computed at startup. This also
287                 means that the RAM holding the tables won't be shared
288                 between applications linked against shared liblzma.
290                 This option doesn't modify CFLAGS to tell the compiler
291                 to optimize for size. You need to add -Os or equivalent
292                 flag(s) to CFLAGS manually.
294     --enable-assume-ram=SIZE
295                 On the most common operating systems, XZ Utils is able to
296                 detect the amount of physical memory on the system. This
297                 information is used by the options --memlimit-compress,
298                 --memlimit-decompress, and --memlimit when setting the
299                 limit to a percentage of total RAM.
301                 On some systems, there is no code to detect the amount of
302                 RAM though. Using --enable-assume-ram one can set how much
303                 memory to assume on these systems. SIZE is given as MiB.
304                 The default is 128 MiB.
306                 Feel free to send patches to add support for detecting
307                 the amount of RAM on the operating system you use. See
308                 src/common/tuklib_physmem.c for details.
310     --disable-threads
311                 Disable threading support. This makes some things
312                 thread-unsafe, meaning that if multithreaded application
313                 calls liblzma functions from more than one thread,
314                 something bad may happen.
316                 Use this option if threading support causes you trouble,
317                 or if you know that you will use liblzma only from
318                 single-threaded applications and want to avoid dependency
319                 on libpthread.
321     --enable-symbol-versions
322                 Use symbol versioning for liblzma. This is enabled by
323                 default on GNU/Linux, other GNU-based systems, and
324                 FreeBSD.
326     --enable-debug
327                 This enables the assert() macro and possibly some other
328                 run-time consistency checks. It makes the code slower, so
329                 you normally don't want to have this enabled.
331     --enable-werror
332                 If building with GCC, make all compiler warnings an error,
333                 that abort the compilation. This may help catching bugs,
334                 and should work on most systems. This has no effect on the
335                 resulting binaries.
338 2.1. Static vs. dynamic linking of liblzma
340     On 32-bit x86, linking against static liblzma can give a minor
341     speed improvement. Static libraries on x86 are usually compiled as
342     position-dependent code (non-PIC) and shared libraries are built as
343     position-independent code (PIC). PIC wastes one register, which can
344     make the code slightly slower compared to a non-PIC version. (Note
345     that this doesn't apply to x86-64.)
347     If you want to link xz against static liblzma, the simplest way
348     is to pass --disable-shared to configure. If you want also shared
349     liblzma, run configure again and run "make install" only for
350     src/liblzma.
353 2.2. Optimizing xzdec and lzmadec
355     xzdec and lzmadec are intended to be relatively small instead of
356     optimizing for the best speed. Thus, it is a good idea to build
357     xzdec and lzmadec separately:
359       - To link the tools against static liblzma, pass --disable-shared
360         to configure.
362       - To select somewhat size-optimized variant of some things in
363         liblzma, pass --enable-small to configure.
365       - Tell the compiler to optimize for size instead of speed.
366         E.g. with GCC, put -Os into CFLAGS.
368       - xzdec and lzmadec will never use multithreading capabilities of
369         liblzma. You can avoid dependency on libpthread by passing
370         --disable-threads to configure.
372       - There are and will be no translated messages for xzdec and
373         lzmadec, so it is fine to pass also --disable-nls to configure.
375       - Only decoder code is needed, so you can speed up the build
376         slightly by passing --disable-encoders to configure. This
377         shouldn't affect the final size of the executables though,
378         because the linker is able to omit the encoder code anyway.
380     If you have no use for xzdec or lzmadec, you can disable them with
381     --disable-xzdec and --disable-lzmadec.
384 3. xzgrep and other scripts
385 ---------------------------
387 3.1. Dependencies
389     POSIX shell (sh) and bunch of other standard POSIX tools are required
390     to run the scripts. The configure script tries to find a POSIX
391     compliant sh, but if it fails, you can force the shell by passing
392     gl_cv_posix_shell=/path/to/posix-sh as an argument to the configure
393     script.
395     Some of the scripts require also mktemp. The original mktemp can be
396     found from <http://www.mktemp.org/>. On GNU, most will use the mktemp
397     program from GNU coreutils instead of the original implementation.
398     Both mktemp versions are fine for XZ Utils (and practically for
399     everything else too).
402 3.2. PATH
404     The scripts assume that the required tools (standard POSIX utilities,
405     mktemp, and xz) are in PATH; the scripts don't set the PATH themselves.
406     Some people like this while some think this is a bug. Those in the
407     latter group can easily patch the scripts before running the configure
408     script by taking advantage of a placeholder line in the scripts.
410     For example, to make the scripts prefix /usr/bin:/bin to PATH:
412         perl -pi -e 's|^#SET_PATH.*$|PATH=/usr/bin:/bin:\$PATH|' \
413                 src/scripts/xz*.in
416 4. Troubleshooting
417 ------------------
419 4.1. "No C99 compiler was found."
421     You need a C99 compiler to build XZ Utils. If the configure script
422     cannot find a C99 compiler and you think you have such a compiler
423     installed, set the compiler command by passing CC=/path/to/c99 as
424     an argument to the configure script.
426     If you get this error even when you think your compiler supports C99,
427     you can override the test by passing ac_cv_prog_cc_c99= as an argument
428     to the configure script. The test for C99 compiler is not perfect (and
429     it is not as easy to make it perfect as it sounds), so sometimes this
430     may be needed. You will get a compile error if your compiler doesn't
431     support enough C99.
434 4.2. "No POSIX conforming shell (sh) was found."
436     xzgrep and other scripts need a shell that (roughly) conforms
437     to POSIX. The configure script tries to find such a shell. If
438     it fails, you can force the shell to be used by passing
439     gl_cv_posix_shell=/path/to/posix-sh as an argument to the configure
440     script.
443 4.3. configure works but build fails at crc32_x86.S
445     The easy fix is to pass --disable-assembler to the configure script.
447     The configure script determines if assembler code can be used by
448     looking at the configure triplet; there is currently no check if
449     the assembler code can actually actually be built. The x86 assembler
450     code should work on x86 GNU/Linux, *BSDs, Solaris, Darwin, MinGW,
451     Cygwin, and DJGPP. On other x86 systems, there may be problems and
452     the assembler code may need to be disabled with the configure option.
454     If you get this error when building for x86-64, you have specified or
455     the configure script has misguessed your architecture. Pass the
456     correct configure triplet using the --build=CPU-COMPANY-SYSTEM option
457     (see INSTALL.generic).
460 4.4. Lots of warnings about symbol visibility
462     On some systems where symbol visibility isn't supported, GCC may
463     still accept the visibility options and attributes, which will make
464     configure think that visibility is supported. This will result in
465     many compiler warnings. You can avoid the warnings by forcing the
466     visibility support off by passing gl_cv_cc_visibility=no as an
467     argument to the configure script. This has no effect on the
468     resulting binaries, but fewer warnings looks nicer and may allow
469     using --enable-werror.