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