xref: /haiku/ReadMe.Compiling.md (revision ca087b05323d3c05f7fe807df017ce4133604b67)
1Building Haiku
2==========================
3This is a overview into the process of building HAIKU from source.
4An online version is available at <https://www.haiku-os.org/guides/building/>.
5
6Official releases of Haiku are at <https://www.haiku-os.org/get-haiku>.
7The (unstable) nightly builds are available at <https://download.haiku-os.org/>.
8
9We currently support the following platforms:
10 * Haiku
11 * Linux
12 * FreeBSD
13 * macOS
14
15Required Software
16----------------------------
17Tools provided within Haiku's repositories:
18 * `jam` (Jam 2.5-haiku-20111222)
19 * Haiku's cross-compiler (needed only for non-Haiku platforms)
20
21The tools to compile Haiku will vary, depending on the platform that you are
22using to build Haiku. When building from Haiku, all of the necessary
23development tools are included in official releases (e.g. R1/alpha4) and in the
24nightly builds.
25
26 * `git`
27 * `gcc`/`g++` and binutils (`as`, `ld`, etc., required by GCC)
28 * (GNU) `make`
29 * `bison` (2.4 or better)
30 * `flex` and `lex` (usually a mini shell script invoking `flex`)
31 * `makeinfo` (part of `texinfo`, only needed for building GCC 4)
32 * `autoheader` (part of `autoconf`, needed for building GCC)
33 * `automake` (needed for building GCC)
34 * `gawk`
35 * `nasm`
36 * `wget`
37 * `[un]zip`
38 * `cdrtools` (preferred) or `genisoimage`
39 * case-sensitive file system
40
41Whether they are installed can be tested by running them in a shell with
42the `--version` parameter.
43
44The following libraries (and their respective headers) are required:
45 * `curl`
46 * `zlib`
47
48### Haiku for ARM
49If you want to compile Haiku for ARM, you will also need:
50
51 * `mkimage` (<http://www.denx.de/wiki/U-Boot/WebHome>)
52 * Mtools (<https://gnu.org/software/mtools/intro.html>)
53
54### On macOS
55
56Disk Utility can create a case-sensitive disk image of at least 3 GiB in size.
57The following ports need to be installed:
58 * `expat`
59 * `gawk`
60 * `gettext`
61 * `libiconv`
62 * `gsed`
63 * `cdrtools`
64 * `nasm`
65 * `wget`
66 * `less`
67 * `mpfr`
68 * `gmp`
69 * `libmpc`
70 * `bison` (updated to the latest version)
71
72More information about individual distributions of Linux and BSD can be found
73at <https://haiku-os.org/guides/building/pre-reqs>.
74
75Downloading Haiku's sources
76--------------------------------------------------
77There are two parts to Haiku's sources &mdash; the code for Haiku itself and a set
78of build tools for compiling Haiku on an operating system other than Haiku.
79The buildtools are needed only for non-Haiku platforms.
80
81Anonymous checkout:
82```
83git clone https://git.haiku-os.org/haiku
84git clone https://git.haiku-os.org/buildtools
85```
86(You can also use the `git://` protocol, but it is not secure).
87
88If you have commit access:
89```
90git clone ssh://git.haiku-os.org/haiku
91git clone ssh://git.haiku-os.org/buildtools
92```
93
94Building Jam
95-------------------------------------------
96(*This step applies only to non-Haiku platforms.*)
97
98Change to the `buildtools` folder and run the following commands to
99generate and install `jam`:
100```
101cd buildtools/jam
102make
103sudo ./jam0 install
104```
105Or,  if you don't want to install `jam` systemwide:
106```
107./jam0 -sBINDIR=$HOME/bin install
108```
109
110Configuring the build
111-------------------------------------
112The `configure` script generates a file named `BuildConfig` in the
113`generated/build` directory. As long as `configure` is not modified (!) and the
114cross-compilation tools have not been updated, there is no need to call it again.
115For rebuilding, you only need to invoke `jam` (see below). If you don't
116update the source tree very frequently, you may want to execute `configure`
117after each update just to be on the safe side.
118
119Depending on your goal, there are several different ways to configure Haiku.
120The first way is to call configure from within your Haiku checkout's root. That
121will prepare a folder named 'generated', which will contain the compiled objects.
122Another option is to manually created one or more `generated.*` folders and run
123configure from within them. For example, imagine the following directory setup:
124```
125buildtools/
126haiku/
127haiku/generated.x86gcc2
128```
129
130### Configure a GCC 2.95/GCC 5 Hybrid, from a non-Haiku platform
131```bash
132cd haiku/generated.x86gcc2
133../configure \
134	--build-cross-tools x86_gcc2 ../../buildtools/ \
135	--build-cross-tools x86
136```
137
138### Configure an x86_64 (GCC 5) build, from a non-Haiku platform
139```
140cd haiku/generated.x86_64
141../configure --build-cross-tools x86_64 ../../buildtools/
142```
143
144### Configure a GCC 2.95/GCC 5 Hybrid, from Haiku
145```
146cd haiku/generated.x86gcc2
147../configure --target-arch x86_gcc2 --target-arch x86
148```
149
150Additional information about GCC Hybrids can be found on the website,
151<https://www.haiku-os.org/guides/building/gcc-hybrid>.
152
153### Configure options
154The various runtime options for configure are documented in its onscreen help
155```bash
156./configure --help
157```
158
159Building via Jam
160----------------------------
161
162Haiku can be built in either of two ways, as disk image file (e.g. for use
163with emulators, to be written directly to a usb stick, burned as a compact
164disc) or as installation in a directory.
165
166### Running Jam
167
168There are various ways in which you can run `jam`:
169
170 * If you have a single generated folder, you can run 'jam' from the top level of Haiku's trunk.
171 * If you have one or more generated folders, (e.g. generated.x86gcc2),
172   you can `cd` into that directory and run `jam`.
173 * In either case, you can `cd` into a certain folder in the source tree (e.g.
174   src/apps/debugger) and run jam -sHAIKU_OUTPUT_DIR=<path to generated folder>
175
176Be sure to read `build/jam/UserBuildConfig.ReadMe` and `UserBuildConfig.sample`,
177as they contain information on customizing your build of Haiku.
178
179### Building a Haiku anyboot file
180```
181jam -q @anyboot-image
182```
183
184This generates an image file named `haiku-anyboot.image` in your output
185directory under `generated/`.
186
187### Building a VMware image file
188```
189jam -q @vmware-image
190```
191This generates an image file named `haiku.vmdk` in your output
192directory under `generated/`.
193
194### Directory Installation
195```
196HAIKU_INSTALL_DIR=/Haiku jam -q @install
197```
198
199Installs all Haiku components into the volume mounted at "/Haiku" and
200automatically marks it as bootable. To create a partition in the first place
201use DriveSetup and initialize it to BFS.
202
203Note that installing Haiku in a directory only works as expected under Haiku,
204but it is not yet supported under Linux and other non-Haiku platforms.
205
206### Building individual components
207If you don't want to build the complete Haiku, but only a certain
208app/driver/etc. you can specify it as argument to jam, e.g.:
209```
210jam -q Debugger
211```
212Alternatively, you can `cd` to the directory of the component you want to
213build and run `jam` from there. **NOTE:** if your generated directory is named
214something other than `generated/`, you will need to tell `jam` where it is:
215```
216jam -q -sHAIKU_OUTPUT_DIR=<path to generated folder>
217```
218You can also force the rebuild of a component by using the `-a` parameter:
219```
220jam -qa Debugger
221```
222
223Running
224----------------
225Generally there are two ways of running Haiku: on real hardware using a
226partition, and on emulated hardware using an emulator (like VirtualBox, or QEMU).
227
228### On Real Hardware
229If you have installed Haiku to its own partition you can include this
230partition in your bootmanager and try to boot Haiku like any other OS you
231have installed. To include a new partition in the Haiku bootmanager, start
232the BootManager configurator by running:
233```
234BootManager
235```
236
237### On Emulated Hardware
238For emulated hardware you should build a disk image (see above). How to set up
239this image depends on your emulator. If you use QEMU, you can usually just
240provide the path to the image as command line argument to the `qemu`
241executable.
242