Imported Upstream version 2.2.4
[platform/upstream/expat.git] / README.md
1 # Expat, Release 2.2.4
2
3 This is Expat, a C library for parsing XML, started by
4 [James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997.
5 Expat is a stream-oriented XML parser.  This means that you register
6 handlers with the parser before starting the parse.  These handlers
7 are called when the parser discovers the associated structures in the
8 document being parsed.  A start tag is an example of the kind of
9 structures for which you may register handlers.
10
11 Windows users should use the
12 [`expat_win32` package](https://sourceforge.net/projects/expat/files/expat_win32/),
13 which includes both precompiled libraries and executables, and source code for
14 developers.
15
16 Expat is [free software](https://www.gnu.org/philosophy/free-sw.en.html).
17 You may copy, distribute, and modify it under the terms of the License
18 contained in the file
19 [`COPYING`](https://github.com/libexpat/libexpat/blob/master/expat/COPYING)
20 distributed with this package.
21 This license is the same as the MIT/X Consortium license.
22
23 If you are building Expat from a check-out from the
24 [Git repository](https://github.com/libexpat/libexpat/),
25 you need to run a script that generates the configure script using the
26 GNU autoconf and libtool tools.  To do this, you need to have
27 autoconf 2.58 or newer. Run the script like this:
28
29 ```console
30 ./buildconf.sh
31 ```
32
33 Once this has been done, follow the same instructions as for building
34 from a source distribution.
35
36 To build Expat from a source distribution, you first run the
37 configuration shell script in the top level distribution directory:
38
39 ```console
40 ./configure
41 ```
42
43 There are many options which you may provide to configure (which you
44 can discover by running configure with the `--help` option).  But the
45 one of most interest is the one that sets the installation directory.
46 By default, the configure script will set things up to install
47 libexpat into `/usr/local/lib`, `expat.h` into `/usr/local/include`, and
48 `xmlwf` into `/usr/local/bin`.  If, for example, you'd prefer to install
49 into `/home/me/mystuff/lib`, `/home/me/mystuff/include`, and
50 `/home/me/mystuff/bin`, you can tell `configure` about that with:
51
52 ```console
53 ./configure --prefix=/home/me/mystuff
54 ```
55
56 Another interesting option is to enable 64-bit integer support for
57 line and column numbers and the over-all byte index:
58
59 ```console
60 ./configure CPPFLAGS=-DXML_LARGE_SIZE
61 ```
62
63 However, such a modification would be a breaking change to the ABI
64 and is therefore not recommended for general use — e.g. as part of
65 a Linux distribution — but rather for builds with special requirements.
66
67 After running the configure script, the `make` command will build
68 things and `make install` will install things into their proper
69 location.  Have a look at the `Makefile` to learn about additional
70 `make` options.  Note that you need to have write permission into
71 the directories into which things will be installed.
72
73 If you are interested in building Expat to provide document
74 information in UTF-16 encoding rather than the default UTF-8, follow
75 these instructions (after having run `make distclean`).
76 Please note that we configure with `--without-xmlwf` as xmlwf does not
77 support this mode of compilation (yet):
78
79 1. Mass-patch `Makefile.am` files to use `libexpatw.la` for a library name:
80    <br/>
81    `find -name Makefile.am -exec sed
82        -e 's,libexpat\.la,libexpatw\.la,'
83        -e 's,libexpat_la,libexpatw_la,'
84        -i {} +`
85
86 1. Run `automake` to re-write `Makefile.in` files:<br/>
87    `automake`
88
89 1. For UTF-16 output as unsigned short (and version/error strings as char),
90    run:<br/>
91    `./configure CPPFLAGS=-DXML_UNICODE --without-xmlwf`<br/>
92    For UTF-16 output as `wchar_t` (incl. version/error strings), run:<br/>
93    `./configure CFLAGS="-g -O2 -fshort-wchar" CPPFLAGS=-DXML_UNICODE_WCHAR_T
94        --without-xmlwf`
95    <br/>Note: The latter requires libc compiled with `-fshort-wchar`, as well.
96
97 1. Run `make` (which excludes xmlwf).
98
99 1. Run `make install` (again, excludes xmlwf).
100
101 Using `DESTDIR` is supported.  It works as follows:
102
103 ```console
104 make install DESTDIR=/path/to/image
105 ```
106
107 overrides the in-makefile set `DESTDIR`, because variable-setting priority is
108
109 1. commandline
110 1. in-makefile
111 1. environment
112
113 Note: This only applies to the Expat library itself, building UTF-16 versions
114 of xmlwf and the tests is currently not supported.
115
116 When using Expat with a project using autoconf for configuration, you
117 can use the probing macro in `conftools/expat.m4` to determine how to
118 include Expat.  See the comments at the top of that file for more
119 information.
120
121 A reference manual is available in the file `doc/reference.html` in this
122 distribution.