1
2Building XZ Utils on Windows
3============================
4
5Introduction
6------------
7
8    This document explains shortly where to get and how to install the
9    build tool that are needed to build XZ Utils on Windows. The final
10    binary package will be standalone in sense that it will depend only
11    on DLLs that are included in all Windows installations.
12
13    These instructions don't apply to Cygwin. XZ Utils can be built under
14    Cygwin in the same way as many other packages.
15
16    These instructions don't apply to MinGW and MSYS developers either,
17    who may want to package XZ Utils for MinGW or MSYS distributions.
18    You know who you are, and will probably use quite different configure
19    options etc. than what is described here.
20
21
22Installing the toolchain(s)
23---------------------------
24
25    Some of the following is needed:
26      - MSYS is always needed to use the GNU Autotools based build system.
27      - MinGW builds 32-bit x86 binaries.
28      - MingW-w32 builds 32-bit x86 executables too.
29      - MinGW-w64 builds 64-bit x86-64 binaries.
30
31    So you need to pick between MinGW and MinGW-w32 when building
32    32-bit version. You don't need both.
33
34    You might find 7-Zip <http://7-zip.org/> handy when extracting
35    some files (especially the .tar.lzma files). The ready-made
36    build script will also use 7-Zip to create the distributable
37    .zip and .7z files.
38
39    I used the following directory structure but you can use whatever
40    you want. Just note that I will use these in my examples. Each of
41    these should have a subdirectory "bin":
42
43        C:\devel\tools\msys
44        C:\devel\tools\mingw
45        C:\devel\tools\mingw-w32
46        C:\devel\tools\mingw-w64
47
48
49Installing MSYS
50
51    You can download MSYS from MinGW's Sourceforge page:
52
53        http://sourceforge.net/projects/mingw/files/
54
55    It's under "MSYS Base System". I recommend using MSYS 1.0.11
56    (MSYS-1.0.11.exe or msysCORE-1.0.11-bin.tar.gz) because that
57    package includes all the required tools. At least some of the
58    later versions include only a subset and thus you would need to
59    download the rest separately. The old version will work fine for
60    building XZ Utils.
61
62    You can use either the .exe or .tar.gz package. I prefer .tar.gz,
63    because it can be extracted into any directory and later removed
64    without worrying about uninstallers.
65
66
67Installing MinGW
68
69    You can download the required packages from MinGW's Sourceforge page:
70
71        http://sourceforge.net/projects/mingw/files/
72
73    These version numbers were the latest when I wrote this document, but
74    you probably should pick the latest versions:
75
76        MinGW Runtime -> mingwrt-3.17-mingw32-dev.tar.gz
77        MinGW API for MS-Windows -> w32api-3.14-mingw32-dev.tar.gz
78        GNU Binutils -> binutils-2.20-1-bin.tar.gz
79        GCC Version 4 -> gcc-full-4.4.0-mingw32-bin-2.tar.lzma
80
81    The full GCC package is quite big, but if you want a smaller
82    download, you will need to download more than one file, so I'm
83    using the full package in this document for simplicity.
84
85    Extract the packages in the above order, possibly overwriting files
86    from packages that were extracted earlier.
87
88
89Installing MinGW-w32 or MinGW-w64
90
91    You can find the latest MinGW-w32 and MinGW-w64 builds here:
92
93        http://sourceforge.net/projects/mingw-w64/files/
94
95    Locate the appropriate files:
96
97        Toolchains targeting Win32 -> mingw-w32-*-mingw*.zip
98        Toolchains targeting Win64 -> mingw-w64-*-mingw*.zip
99
100    I don't know what is the most recommended one. I used sezero's
101    versions from "Personal Builds", since they seemed to have
102    a stable GCC (judging from the GCC version number only).
103
104    If you will install both MinGW-w32 and MinGW-w64, remember to
105    extract them into different directories.
106
107
108Building XZ Utils
109-----------------
110
111    Start MSYS by going to the directory C:\devel\tools\msys and running
112    msys.bat there (double-click or use command prompt). It will start
113    at "home" directory, which is C:\devel\tools\msys\home\YourUserName.
114
115    If you have xz-5.x.x.tar.gz in C:\devel, you should be able to build
116    it now with the following commands:
117
118        cd /c/devel
119        tar xzf xz-5.x.x.tar.gz
120        cd xz-5.x.x
121        bash windows/build.bash
122
123    If you used some other directory than C:\devel\tools for the build
124    tools, edit the variables near the beginning of build.bash first.
125
126    If you want to build manually, read the buildit() function in
127    build.bash. Look especially at the latter configure invocation.
128
129    Be patient. Running configure and other scripts used by the build
130    system is (very) slow under Windows.
131
132
133Using a snapshot from the Git repository
134
135    To use a snapshot, the build system files need to be generated with
136    autogen.sh or "autoreconf -fi" before trying to build using the
137    above build instructions. You can install the relevant extra packages
138    from MinGW or use Cygwin or use e.g. a GNU/Linux system to create a
139    source package with the required build system files.
140
141