xref: /haiku/docs/develop/packages/Bootstrapping.rst (revision 03d384bbfb07c49b1046cc684326b04fb2ecb6a3)
1*03d384bbSLeorize===================
2*03d384bbSLeorizeBootstrapping Haiku
3*03d384bbSLeorize===================
4*03d384bbSLeorize
5*03d384bbSLeorizeEven a very basic Haiku requires a set of third-party packages (ICU, zlib,...),
6*03d384bbSLeorizea Haiku sufficiently complete to build software even more
7*03d384bbSLeorize(binutils, gcc, make,...). So whenever something fundamental in Haiku
8*03d384bbSLeorize(the architecture ABI, the ABI of libroot) changes in a binary incompatible way,
9*03d384bbSLeorizeor when Haiku is ported to a new architecture, it is necessary to bootstrap
10*03d384bbSLeorizeHaiku and a basic set of required third-party packages. This document describes
11*03d384bbSLeorizehow this process works.
12*03d384bbSLeorize
13*03d384bbSLeorizePrerequisites
14*03d384bbSLeorize=============
15*03d384bbSLeorize
16*03d384bbSLeorize- So far the bootstrap build has only been tested on Linux. It will probably
17*03d384bbSLeorize  also work on FreeBSD and other Unixes. Haiku is not yet supported as a build
18*03d384bbSLeorize  platform.
19*03d384bbSLeorize- A required prerequisite for the bootstrap build is a checkout of the
20*03d384bbSLeorize  haikuporter, the haikuports, and the haikuports.cross repositories from the
21*03d384bbSLeorize  `Github HaikuPorts site`_.
22*03d384bbSLeorize
23*03d384bbSLeorize  .. _Github HaikuPorts site: https://github.com/haikuports/
24*03d384bbSLeorize
25*03d384bbSLeorize- Additional build tools are required for the build platform:
26*03d384bbSLeorize
27*03d384bbSLeorize  - autoconf
28*03d384bbSLeorize  - automake
29*03d384bbSLeorize  - cmake (For compiling python_bootstrap)
30*03d384bbSLeorize  - ncurses_development (For compiling texinfo_bootstrap)
31*03d384bbSLeorize
32*03d384bbSLeorize- All the usual prerequisites for building Haiku.
33*03d384bbSLeorize
34*03d384bbSLeorizeConfiguring and Building
35*03d384bbSLeorize========================
36*03d384bbSLeorize
37*03d384bbSLeorize1. Configure the Haiku build with all usual parameters, but add the
38*03d384bbSLeorize   ``--bootstrap`` option with its three parameters, the paths to the checked
39*03d384bbSLeorize   out haikuporter *script* (eg. ``../haikuporter/haikuporter``),
40*03d384bbSLeorize   haikuports.cross, and haikuports repositories folders::
41*03d384bbSLeorize
42*03d384bbSLeorize     .../configure ... --bootstrap path/to/haikuporter path/to/haikuports.cross path/to/haikuports
43*03d384bbSLeorize
44*03d384bbSLeorize   It is important that you build outside the tree, as otherwise the build will
45*03d384bbSLeorize   fail!
46*03d384bbSLeorize#. Build a bootstrap Haiku image::
47*03d384bbSLeorize
48*03d384bbSLeorize     jam -q @bootstrap-raw
49*03d384bbSLeorize
50*03d384bbSLeorize#. Boot the bootstrap Haiku (e.g. in a virtual machine), edit the file
51*03d384bbSLeorize   "/boot/home/haikuports/haikuports.config" -- entering your email address in
52*03d384bbSLeorize   the "PACKAGER" field -- and finally open a Terminal and build the third-party
53*03d384bbSLeorize   packages::
54*03d384bbSLeorize
55*03d384bbSLeorize     cd haikuports
56*03d384bbSLeorize     haikuporter --do-bootstrap
57*03d384bbSLeorize
58*03d384bbSLeorizeIn the "packages" subdirectory the built packages are collected. This is the
59*03d384bbSLeorizeinitial set of packages for the HaikuPorts packages repository, plus the source
60*03d384bbSLeorizepackages the Haiku build system put in your generated directory under
61*03d384bbSLeorize"objects/haiku/<arch>/packaging/repositories/HaikuPorts-sources-build/packages"
62*03d384bbSLeorize(ignore the "rigged" source packages). With these packages a HaikuPorts package
63*03d384bbSLeorizerepository can be built and in turn a regular Haiku can be built using it.
64*03d384bbSLeorizeFurther packages can then be built on the regular Haiku.
65*03d384bbSLeorize
66*03d384bbSLeorizeFurther hints:
67*03d384bbSLeorize
68*03d384bbSLeorize- Of course, as usual, "-j<number>" can be passed to the jam building the
69*03d384bbSLeorize  bootstrap Haiku. Building the bootstrap third-party packages, which is part of
70*03d384bbSLeorize  this process, will take quite some time anyway. Since those packages are built
71*03d384bbSLeorize  sequentially, the jam variable "HAIKU_PORTER_CONCURRENT_JOBS" can be defined
72*03d384bbSLeorize  to the number of jobs that shall be used to build a package.
73*03d384bbSLeorize- Instead of "bootstrap-raw" the build profile "bootstrap-vmware" can be used as
74*03d384bbSLeorize  well. You can also define your own build profile, e.g. for building to a
75*03d384bbSLeorize  partition. As long as its name starts with "bootstrap-" that will result in a
76*03d384bbSLeorize  bootstrap Haiku.
77*03d384bbSLeorize- ``haikuporter`` also supports the "-j<number>" option to specify the number of
78*03d384bbSLeorize  jobs to use. Even on real hardware this step will nevertheless take a long
79*03d384bbSLeorize  time.
80*03d384bbSLeorize- The jam variable HAIKU_PORTER_EXTRA_OPTIONS can be defined to any options that
81*03d384bbSLeorize  should be passed to ``haikuporter`` (``--debug`` is handy for showing python
82*03d384bbSLeorize  strack traces, for instance).
83*03d384bbSLeorize
84*03d384bbSLeorizeHow it works
85*03d384bbSLeorize============
86*03d384bbSLeorizeBuilding the bootstrap Haiku image is in principle quite similar to building a
87*03d384bbSLeorizeregular Haiku image, save for the following differences:
88*03d384bbSLeorize
89*03d384bbSLeorize- Some parts of a regular Haiku that aren't needed for building packages are
90*03d384bbSLeorize  omitted (e.g. the Demos, MediaPlayer, the OpenGL API,...).
91*03d384bbSLeorize- Certain third-party packages that aren't needed for building packages are
92*03d384bbSLeorize  omitted as well.
93*03d384bbSLeorize- The third-party packages are not downloaded from some package repository.
94*03d384bbSLeorize  Instead for each package a bootstrap version is built from the sources using
95*03d384bbSLeorize  ``haikuporter`` and the respective build recipe from haikuports.cross.
96*03d384bbSLeorize- ``haikuporter`` itself and ready-to-build ("rigged") source packages for all
97*03d384bbSLeorize  needed final third-party packages are copied to the image.
98*03d384bbSLeorize
99*03d384bbSLeorizeObviously the last two points are the juicy parts. Building a bootstrap
100*03d384bbSLeorizethird-party package -- unless it is a pure data package -- requires certain
101*03d384bbSLeorizeparts of Haiku; usually the headers, libroot and other libraries, and the glue
102*03d384bbSLeorizecode. For some Haiku libraries we do already need certain third-party packages.
103*03d384bbSLeorizeSo there's a bit of ping pong going on:
104*03d384bbSLeorize
105*03d384bbSLeorize- Initially the build system builds a package
106*03d384bbSLeorize  "haiku_cross_devel_sysroot_stage1_<arch>.hpkg". It contains the essentials for
107*03d384bbSLeorize  cross-compiling bootstrap third-party packages, but nothing that itself
108*03d384bbSLeorize  depends on a third-party package.
109*03d384bbSLeorize- Once all third-party packages required for it have been built, a more complete
110*03d384bbSLeorize  "haiku_cross_devel_sysroot_<arch>.hpkg" is built. It is used to cross-compile
111*03d384bbSLeorize  the remaining third-party packages.
112*03d384bbSLeorize
113*03d384bbSLeorizeThe rigged source packages (and regular source packages) are built via
114*03d384bbSLeorize``haikuporter`` from the regular haikuports repository checkout. haikuports
115*03d384bbSLeorizecontains build recipes for a lot of software. Which source packages should be
116*03d384bbSLeorizebuilt is determined by the build system by checking what packages are needed for
117*03d384bbSLeorizethe target build profile used by the bootstrap process. This defaults to
118*03d384bbSLeorize"minimum-raw", but it can be changed by setting the jam variable
119*03d384bbSLeorize"HAIKU_BOOTSTRAP_SOURCES_PROFILE"
120*03d384bbSLeorize(i.e. ``jam -sHAIKU_BOOTSTRAP_SOURCES_PROFILE=@release-raw -q @bootstrap-raw``
121*03d384bbSLeorizewill include source packages for all packages needed by release image).
122*03d384bbSLeorize
123*03d384bbSLeorizeHaiku Architecture Ports
124*03d384bbSLeorize========================
125*03d384bbSLeorizeWhen preparing a new Haiku architecture port for the bootstrap build the
126*03d384bbSLeorizefollowing things need to be considered:
127*03d384bbSLeorize
128*03d384bbSLeorize- There need to be repository definitions
129*03d384bbSLeorize  "build/jam/repositories/HaikuPorts/<arch>" and
130*03d384bbSLeorize  "build/jam/repositories/HaikuPortsCross/<arch>". The former lists the packages
131*03d384bbSLeorize  available for a regular Haiku, i.e. it must include at least the packages
132*03d384bbSLeorize  needed for a basic Haiku image that can build third-party packages. The latter
133*03d384bbSLeorize  lists the available bootstrap third-party packages.
134*03d384bbSLeorize- There needs to be "src/data/package_infos/<arch>/haiku", a package info for
135*03d384bbSLeorize  the Haiku system package (currently also used for the bootstrap package).
136*03d384bbSLeorize- In the haikuports.cross repository all build recipes need to support the
137*03d384bbSLeorize  architecture (the architecture must be listed in the "ARCHITECTURES"
138*03d384bbSLeorize  variable). Some software may need to be patched for cross-building to work for
139*03d384bbSLeorize  the architecture.
140*03d384bbSLeorize- In the haikuports repository all build recipes for required software need to
141*03d384bbSLeorize  support the architecture.
142*03d384bbSLeorize
143*03d384bbSLeorizeIf the Haiku architecture port doesn't support a working userland yet, the
144*03d384bbSLeorizeprocess obviously cannot go further than building the bootstrap Haiku image.
145