Prex Home > Document Index > Prex Build Guide

Prex Build Guide

For Prex version 0.9.0, 2009/10/01

Table of Contents


Getting Source

You can download the source files at the download page.
Some binary files may be available there.

Prerequisite Tools

The following tools are required to build Prex.

Now, PCC or other compilers can be used for build.

Compiling Prex on Linux

Step 1. Prepare Toolchain

Prepare the following packages. GCC and Binutils should be built appropriately for your target architecture if you cross-compile Prex.

Step 2. Unpack Sources

Unpack the sources and move to top level directory of the source tree.
$ cd /usr/src
$ tar zxvf prex-X.X.X.tar.gz
$ cd prex-X.X.X

Step 3. Configure

Setup target architecture and platform. The following sample shows the setting for x86-pc target.
$ ./configure --target=x86-pc

Step 4. Make

Run make.
$ make

(Tips)

If you want to run 'make' in the subdirectory, you have to set the SRCDIR as follows:
$ export SRCDIR=/usr/src/prex-X.X.X

Compiling Prex on Windows

Cygwin is required to build Prex on Windows environment.

Please note that we can not use the default gcc version included in Cygwin. This is because the pre-compiled gcc in Cygwin is built to generate a native Windows binary (PE format). Since Prex supports only ELF file format, you have to prepare the toolchain for i386-elf with the following steps. (Target Platform is x86-pc here.)

Step 1. Install Cygwin

You can find the latest Cygwin setup program at this site. Download setup.exe and run it. During Cygwin installation, you have to select at least the following packages in addition to the default selection.
Note 1: flex and perl are not required to build Prex itself. They are required to build "binutils and gcc".
Note 2: gmp and mpfr are also required to build gcc 4.3.

Step 2. Unpack Archives

You have to download and unpack the following files.
$ cd /usr/src
$ tar zxvf binitils-2.15.tar.gz
$ tar zxvf gcc-core-3.4.3.tar.gz

Step 3. Build Binutils

Configure and build binutils.

$ mkdir binutils-2.15-i386-elf
$ cd binutils-2.15-i386-elf
$ ../binutils-2.15/configure --prefix=/usr/local/i386 --target=i386-elf --disable-nls
$ make
$ make install

You must set the path to this binutils before compiling gcc.

$ export PATH=/usr/local/i386/bin:$PATH
$ cd /usr/src

Step 4. Build gcc

$ mkdir gcc-3.4.3-i386-elf
$ cd gcc-3.4.3-i386-elf
$ ../gcc-3.4.3/configure --prefix=/usr/local/i386 --target=i386-elf \
 --with-gnu-as --with-gnu-ld --disable-nls --enable-languages=c --without-headers \
 --without-libs --disable-libssp
$ make LANGUAGES="c"
$ make LANGUAGES="c" install
$ cd /usr/src

Step 5. Configure Prex and make

$ cd prex-X.X.X
$ ./configure --target=x86-pc
$ make

Compiling Prex on FreeBSD

You have to specify the name of the GNU make on FreeBSD.
It can be done by changing Makefile.inc or using symbolic link. The compiling method is same with compling on Linux. Please refer to the above build step for Linux.

Compiling Prex on Solaris

You have to specify the name of the GNU make on FreeBSD.
It can be done by changing Makefile.inc or using symbolic link. You have to install the following GNU tools properly.
The compiling method is same with compling on Linux. Please refer to the above build step for Linux.

Configuring Prex

Configure Script

You can use help option for the configure script.
$ configure --help

Usage: configure [options]
Options:
        --help                  print this message
        --target=TARGET         use TARGET for target system
        --profile=PROFILE       use PROFILE for target profile
        --cross-prefix=PREFIX   use PREFIX for compile tools
        --cc=CC                 use CC as C compiler
        --no-debug              disable all debug features

$ _

Build Flavors

There some build switches in the Makefile file named /mk/own.mk.
Table 1. Build Flavors
Switch Description
_DEBUG_ All debugging features are enabled by default
_QUICK_ Sample applications and test tools are not compiled
_STRICT_ Compiler will check code strictly
_SILENT_ Output message is reduced during build process.

Installing Prex

The method to install an OS image depends on the target platform. It may be described in the target specific document listed in the Prex document.

Customizing OS Image

OS Image

If you compile the Prex source with "make" command, the OS boot image is created as "prexos" in the root directory. The file "prexos" must exist in root directory of the Prex disk/ROM. You can test your own Prex image by replacing the "prexos" in the OS boot image. The file "prexos" includes the following files.

Directory Organization

The structure of the Prex source directory is as follows:

 bsp/ ........ Board Support Package
 sys/ ........ Prex microkernel
 usr/ ........ User mode programs
 include/ .... Common header files
 conf/ ....... Configuration files
 mk/ ......... Common makefiles
 configure ... Configuration script
 Makefile .... Top level makefile

Configuring Build Options

You can change the various options to adjust the image for your target requirement. The configuration file is prepared for the each target platform. You can modify the options described in the following file.

#
# Make options
#
makeoptions     GCCFLAGS+= -march=i386
makeoptions     GCCFLAGS+= -mpreferred-stack-boundary=2

#
# Memory address
#
memory          LOADER_TEXT     0x00004000      # Start of boot loader
memory          KERNEL_TEXT     0x80010000      # Start of kernel
memory          BOOTIMG_BASE    0x80100000      # Location of boot image
memory          SYSPAGE_BASE    0x80000000      # Location of system page

#
# Tunable paramters
#
options         HZ=1000         # Ticks/second of the clock
options         TIME_SLICE=50   # Context switch ratio (msec)
options         OPEN_MAX=16     # Max open files per process
options         BUF_CACHE=32    # Blocks for buffer cache
options         FS_THREADS=4    # Number of file system threads
...

Changing Boot Tasks

The boot task is a special task which is loaded by kernel directly at boot time. You can specify your own boot task(s) in "TASKS" option in the following file.

#
# Boot tasks
#
TASKS+=     $(SRCDIR)/usr/server/boot/boot
TASKS+=     $(SRCDIR)/usr/server/proc/proc
TASKS+=     $(SRCDIR)/usr/server/exec/exec
TASKS+=     $(SRCDIR)/usr/server/fs/fs
...