NAMEdevelopment — operating system development instructions
DESCRIPTIONReleases come with the system source code in /src as a git(1) repository. It can be modified, compiled and installed on the current system. The source code is built with a make(1) build system. The source code can be located in any location, if so, simply substitute /src with the real location. These instructions only apply to building the operating system from within itself, those building it from another operating system needs to follow cross-development(7) instead.
cd /src make distclean # fully clean build directory make install-build-tools # install new tools make clean-build-tools # clean for real build below
cd /src make # build new operating system in /src/sysroot make sysmerge # upgrade current operating system with /src/sysroot
Root MakefileThe /src/Makefile handles the high level build of the operating system. The important targets are:
- (default) Build each component in turn and install them into the sysroot.
- Make all build tools.
- Clean the component directories and the port source code. (clean-core, clean-ports)
- Clean the directories of all build tools.
- Run every clean target such that the source code is ready for distribution. (clean-builds, clean-core, clean-ports, clean-release, clean-repository, clean-sysroot)
- Install all build tools after making them.
- Create a release iso in the /src/builds directory after making all.
- Clean everything except binary packages. (clean-builds, clean-core, clean-ports, clean-release, clean-sysroot)
- Make iso and construct release directory tree in /src/release suitable for online publishing.
- Make iso and place it in the current directory as sortix.iso.
- Upgrade the current operating system using the sysroot after making the all target.
- Like sysmerge but delay the upgrade until the next boot.
- Create the sysroot and install only the headers of the standard library and kernel into it. This is useful when bootstrapping the runtime libraries of the compiler that need to know about libc prior to building libc.
- The platform of the current operating system. This defaults to the current machine and operating system.
- Specifies platform on which the compiled code will run. This defaults to the current machine and operating system. This is used when cross-compiling the operating system. When cross-compiling the operating system, it must be set to one of i686-sortix and x86_64-sortix. This must be unset when building the build tools as they run on the current operating system. The compiler tools are prefixed with this variable if it does not match BUILD.
- Specifies compiler optimization options that gets added to CFLAGS and CXXFLAGS.
- Specifies whether the source code is included in the sysroot. This must be one of no, yes or git and defaults to git if git(1) is installed and yes otherwise.
- Specifies the compression algorithm used in iso files. This must be one of none, gzip or xz and defaults to xz.
ComponentsThe operating systems components, such as libc and the kernel, each have their own directory by that name. It contains a makefile that can build and install that component. This allows building and installing only that component onto the current operating system.
cd /src/libc make make install
DirectoriesIn addition to the directories for each operating system component, there are these special directories:
- If this directory exists, each subdirectory can contain the source code for a port that gets built along with the rest of the system.
- The release root makefile target creates this directory and populates it with a directory structure suitable for online publishing of a release.
- If ports are present, this directory is made when binary packages are built and they are stored here. This works as a cache so ports don't have to be rebuilt every time the operating system is. Packages are also copied from here rather than the sysroot when making releases.
- This directory is made when building the operating system and the freshly made files are installed here. The build system uses this as the system root which forces the compiler to look here for headers and libraries. This ensures a clean bootstrap where files from the current operating system do not leak into the new system.
- If this directory exists, it is added to the initrd of the produced iso and can contain additional system files.
Build ToolsSome components are used to build the source code and must match the versions in the source code being built. These are currently:
PortsYou can place the source code for ports in srctix(7) format (has a tixbuildinfo(7) file) in the /src/ports directory and they will get built automatically when and installed into the sysroot when building the whole operating system. Installable binary packages are created in the /src/repository/$HOST directory using tix-build(8) directory and can be installed with tix-install(8). If an existing binary package exists in the repository, it is used instead of the building the port again.
PatchesThe source code is managed as a git(1) repository and you can make your own changes and commit them. A good approach is to set up your own local development branch and work there:
git checkout -b local git add utils/hello.c git commit -m 'Add hello(1).'
git format-patch master..local