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