sanos home

Building sanos from source

Although Sanos can be build under Sanos itself, you need to cross-compile it on another system first. To build sanos from source you first need to download from the download page and unzip it into a directory (e.g. c:\sanos or ~/sanos).

The source code for sanos can be compiled under Windows or Linux. I use Microsoft Visual C version 7 (i.e. Visual Studio.NET 2002) to compile the source code. The boot sector is made using NASM.

For the various ways to build sanos see the following sections:


Building sanos on Windows using Microsoft Visual C and NMAKE


You can build sanos from a command line using the Makefile in the root directory of the sanos distribution. If your Visual Studio is not placed in its default location you need to have your path setup for Visual Studio. This is most easily done by running vsvars32.bat. This file is usually located in C:\Program Files\Microsoft Visual Studio .NET\Vc7\bin.

The Makefile compiles and links all the code and builds a boot floppy image in win\img\sanos.flp. See here for booting and installing this image.

The root directory of the sanos source distribution contains a Makefile, that can be used to build sanos. After running vsvars32.bat you can build sanos by running:

c:\sanos> nmake sanos
The Makefile first builds the sanos specific win32 based tools:

These tools are placed in the win\tools directory. Next, all the sanos executable files are compiled, linked, and placed in the win\install directory. The following components are built:

The only expected build warning is in osldr:

LINK : warning LNK4096: /BASE value '0x10000' is invalid for Windows 95 and Windows 98; image may not run

You can then build different install medias from these files:


Building sanos using other versions of Visual Studio


You can use the following versions of Visual Studio for building sanos:

You can also use the Express (i.e. "free") versions of Visual Studio.


Building sanos on Windows using sanos SDK crosstools


If you do not have Microsoft Visual Studio installed you can build sanos using the cross-compile toolchain in the bin directory. These are the sanos executables for the compiler, assembler, and other build tools. The bin directory also contains a SOW version of os.dll, which allows the build tools to be run under Windows. This way you can build sanos without needing any other tools than the crosstools distributed together with the sanos source distribution. You can build a Sanos VMDK image with this command:

bin\make -f Makefile.cross

This will produce a virtual disk image in cross/img/sanos.vmdk that can be used for running Sanos on a PC emulator.


Building sanos under Linux using GCC


You can also cross-compile Sanos under Linux. You'll need to have GCC installed. When building under Linux, GCC is used for compiling the Sanos build tools (cc, as, ar, mkdfs) as Linux binaries and these are then used for building Sanos. You can build a Sanos VMDK image with this command:

make -f Makefile.linux sanos vmdk

This will produce a virtual disk image in linux/img/sanos.vmdk that can be used for running Sanos on a PC emulator.


Building sanos under sanos


Sanos is self-contained in the sense that is can build itself. After the initial bootstrap build it no longer relies on Windows or Linux for building.

The Sanos C compiler (TCC) has been extended with a number of MSVC extensions, for example inline assembler with MASM syntax, so it can compile all the sanos code. The sanos SDK contains all the code and all the tools needed to build sanos from scratch and makefiles for building the various components.

The master makefile for building sanos is located in /usr/src. You can re-build all the sanos components with the following commands:

/$ cd /usr/src
/usr/src$ make install
/usr/src$ reboot

This will build the following components:

After rebooting sanos will no longer contain any code from the original build under Windows or Linux.