blob: 252f39dd4f8245f351f9f2f63fb324c28f6f32e3 [file] [log] [blame]
Lasse Collinbcc4b362009-03-22 13:12:47 +02001
2XZ Embedded
3===========
4
5 XZ Embedded is a relatively small, limited implementation of the .xz
6 file format. Currently only decoding is implemented.
7
8 XZ Embedded was written for use in the Linux kernel, but the code can
9 be easily used in other environments too, including regular userspace
10 applications.
11
12 This README contains information that is useful only when the copy
13 of XZ Embedded isn't part of the Linux kernel tree. You should also
14 read linux/Documentation/xz.txt even if you aren't using XZ Embedded
15 as part of Linux; information in that file is not repeated in this
16 README.
17
18Compiling the Linux kernel module
19
20 cd linux/lib/xz
21 make -C /path/to/kernel/source \
22 CONFIG_XZ_DEC=m KCPPFLAGS=-I"$(pwd)/../../include" M="$(pwd)"
23
24 The xz_dec module depends on crc32 module, so make sure that you have
25 it enabled (CONFIG_CRC32).
26
27Compiler requirements
28
29 XZ Embedded should compile as either GNU-C89 (used in the Linux
30 kernel) or with any C99 compiler. Getting the code to compile with
31 non-GNU C89 compiler or a C++ compiler should be quite easy as
32 long as there is a data type for unsigned 64-bit integer (or the
33 code is modified not to support large files, which needs some more
34 care than just using 32-bit integer instead of 64-bit).
35
36 If you use GCC, try to use a recent version. For example, on x86,
37 xz_dec_lzma2.c compiled with GCC 3.3.6 is 15-25 % slower than when
38 compiled with GCC 4.3.3.
39
40Embedding into userspace applications
41
42 To embed the XZ decoder, copy the following files into a single
43 directory in your source code tree:
44
45 linux/include/linux/xz.h
46 linux/lib/xz/xz_crc32.c
47 linux/lib/xz/xz_dec_lzma2.c
48 linux/lib/xz/xz_dec_stream.c
49 linux/lib/xz/xz_lzma2.h
50 linux/lib/xz/xz_private.h
51 linux/lib/xz/xz_stream.h
52
53 Alternatively, xz.h may be placed into a different directory but then
54 that directory must be in the compiler include path when compiling
55 the .c files.
56
57 Your code should use only the functions declared in xz.h. The rest of
58 the .h files are meant only for internal use in XZ Embedded.
59
60 If you are including XZ Embedded into a shared library, you very
61 probably should rename the xz_* functions to prevent symbol
62 conflicts in case your library is linked against some other library
63 or application that also has XZ Embedded in it (which may even be
64 a different version of XZ Embedded). TODO: Provide an easy way
65 to do this.
66
67 NOTE: Please don't create a shared library of XZ Embedded itself
68 unless it is fine to rebuild everything depending on that shared
69 library everytime you upgrade to a newer version of XZ Embedded.
70 There are no API or ABI stability guarantees between different
71 versions of XZ Embedded.
72
73Specifying the calling convention
74
75 XZ_FUNC macro was included to support declaring functions with __init
76 in Linux. Outside Linux, it can be used to specify the calling
77 convention on systems that support multiple calling conventions.
Lasse Collin9009d212009-03-24 11:01:52 +020078 For example, on Windows, you may make all functions use the stdcall
Lasse Collinbcc4b362009-03-22 13:12:47 +020079 calling convention by defining XZ_FUNC=__stdcall when building and
80 using the functions from XZ Embedded.
81