2021-03-11 15:03:08 -03:00
# SerenityOS build instructions
2019-12-29 12:23:50 -03:00
2021-03-11 15:03:08 -03:00
## Prerequisites
2020-05-15 04:00:12 -03:00
2021-07-09 19:53:28 -03:00
Make sure you have all the dependencies installed:
2021-06-12 15:46:52 -03:00
2021-07-09 19:53:28 -03:00
### Debian / Ubuntu
2021-06-12 15:46:52 -03:00
```console
2021-08-30 11:08:36 -03:00
sudo apt install build-essential cmake curl libmpfr-dev libmpc-dev libgmp-dev e2fsprogs ninja-build qemu-system-i386 qemu-utils ccache rsync genext2fs unzip
2021-06-12 15:46:52 -03:00
```
2021-07-09 19:53:28 -03:00
#### GCC 10
2021-06-12 15:46:52 -03:00
On Ubuntu gcc-10 is available in the repositories of 20.04 (Focal) and later - add the `ubuntu-toolchain-r/test` PPA if you're running an older version:
2021-03-11 15:03:08 -03:00
```console
2021-03-04 08:14:03 -03:00
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
2019-12-29 12:23:50 -03:00
```
2021-07-30 13:46:55 -03:00
On Debian your system must be on the _testing_ or _unstable_ branch as gcc 10 is not available on _stable_ or in the backports. If you want to switch from _stable_ to _testing_ , see the instructions on the Debian website on [switching to testing ](https://wiki.debian.org/DebianTesting ). Alternatively, if you want to stay on _stable_ , you can build SerenityOS in a Debian testing or Ubuntu [Docker ](https://www.docker.com/ ) container.
2020-03-28 17:48:34 -03:00
2021-03-04 08:14:03 -03:00
Now on Ubuntu or Debian you can install gcc-10 with apt like this:
2021-03-11 15:03:08 -03:00
```console
2021-03-04 08:14:03 -03:00
sudo apt install gcc-10 g++-10
2020-04-13 12:20:47 -03:00
```
2021-07-09 19:53:28 -03:00
#### QEMU 5 or later
2021-03-04 08:14:03 -03:00
2021-07-09 19:53:28 -03:00
QEMU version 5 is available in Ubuntu 20.10. For earlier versions, you can build version 6 using the `Toolchain/BuildQemu.sh` script.
2021-06-12 15:46:52 -03:00
You may need the gtk+ 3.0 dev package:
2021-03-11 15:03:08 -03:00
```console
2021-07-09 19:53:28 -03:00
sudo apt install libpixman-1-dev libgtk-3-dev
2020-07-04 05:51:16 -03:00
```
2021-07-11 17:19:11 -03:00
### Windows
If you're on Windows you can use WSL2 to build SerenityOS. Please have a look at the [Windows guide ](BuildInstructionsWindows.md )
for details.
### Arch Linux / Manjaro
2021-03-11 15:03:08 -03:00
```console
2021-07-11 17:19:11 -03:00
sudo pacman -S --needed base-devel cmake curl mpfr libmpc gmp e2fsprogs ninja qemu qemu-arch-extra ccache rsync
2019-12-29 12:23:50 -03:00
```
2021-07-09 19:53:28 -03:00
### Other systems
2021-03-11 15:03:08 -03:00
2021-07-09 19:53:28 -03:00
There is also documentation for installing the build prerequisites for some less commonly used systems:
2019-12-29 12:23:50 -03:00
2021-08-29 12:10:21 -03:00
* [Other Linux distributions and \*NIX systems ](BuildInstructionsOther.md )
2021-07-09 19:53:28 -03:00
* [macOS ](BuildInstructionsMacOS.md )
2021-01-13 17:24:46 -03:00
2021-03-11 15:03:08 -03:00
## Build
2021-07-09 19:53:28 -03:00
In order to build SerenityOS you will first need to build the toolchain by running the following command:
2021-03-11 15:03:08 -03:00
```console
2021-07-14 14:34:29 -03:00
Meta/serenity.sh rebuild-toolchain
2020-05-06 12:40:06 -03:00
```
2020-05-15 04:00:12 -03:00
2021-07-09 19:53:28 -03:00
Later on, when you use `git pull` to get the latest changes, there's (usually) no need to rebuild the toolchain.
2021-04-10 04:34:11 -03:00
2021-07-09 19:53:28 -03:00
Run the following command to build and run SerenityOS:
2021-04-10 04:34:11 -03:00
```console
2021-07-14 14:34:29 -03:00
Meta/serenity.sh run
2020-05-06 12:40:06 -03:00
```
2021-07-09 19:53:28 -03:00
This will compile all of SerenityOS and install the built files into the `Build/i686/Root` directory inside your Git
repository. It will also build a disk image and start SerenityOS using QEMU.
2021-03-11 15:03:08 -03:00
2021-07-09 19:53:28 -03:00
Note that the `anon` user is able to become `root` without a password by default, as a development convenience.
2020-03-30 06:32:33 -03:00
To prevent this, remove `anon` from the `wheel` group and he will no longer be able to run `/bin/su` .
2021-07-09 19:53:28 -03:00
If you want to test whether your code changes compile without running the VM you can use
`Meta/serenity.sh build` . The `serenity.sh` script also provides a number of other commands. Run the script without
arguments for a list.
2021-06-20 10:07:21 -03:00
2021-03-11 15:03:08 -03:00
## Ports
2021-01-30 16:09:42 -03:00
2021-07-09 19:53:28 -03:00
To add a package from the ports collection to Serenity, for example curl, change into the `Ports/curl` directory and
run `./package.sh` . The source code for the package will be downloaded and the package will be built. The next time you
start Serenity, `curl` will be available.
2021-05-15 23:13:31 -03:00
2021-07-09 19:53:28 -03:00
## More information
2021-01-30 16:09:42 -03:00
2021-07-09 19:53:28 -03:00
At this point you should have a fully functioning VM for SerenityOS. The [advanced build instructions guide ](AdvancedBuildInstructions.md )
has more information for some less commonly used features of the build system.