Compiling the tools

Stage 1. Building mk

Before we can proceed to building our very own port of Inferno, we should build all the needed tools.

We are using this repository as a base: https://snegovick@bitbucket.org/snegovick/inferno-os-lpc2468 It is a fork of original inferno-os repository at revision 6bf1648be3ad864151c35b585cef9c169313f5a9 .

hg clone https://snegovick@bitbucket.org/snegovick/inferno-os-lpc2468

Lets assume that devs took care of us and configured everything conveniently, so lets go inside and try to build:

inferno-os-lpc2468$ bash ./makemk.sh 
./mkconfig: line 32: /usr/inferno/mkfiles/mkhost-Plan9: No such file or directory
./mkconfig: line 33: /usr/inferno/mkfiles/mkfile-Plan9-: No such file or directory
removing old libraries and binaries
mkdir: cannot create directory ‘/usr/inferno’: Permission denied
mkdir: cannot create directory ‘/usr/inferno’: Permission denied
./makemk.sh: line 50: cd: /usr/inferno/utils/libregexp: No such file or directory
cannot find libregexp directory

Ok, we are not at /usr as this log states, lets check the config:

#
#       Set the following 4 variables.  The host system is the system where
#       the software will be built; the target system is where it will run.
#       They are almost always the same.

#       On Nt systems, the ROOT path MUST be of the form `drive:/path'
ROOT=/usr/inferno

#
#       Specify the flavour of Tk (std for standard builds)
#
TKSTYLE=std

#
#       Except for building kernels, SYSTARG must always be the same as SYSHOST
#
SYSHOST=Plan9           # build system OS type (Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
SYSTARG=$SYSHOST                # target system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)

#
#       specify the architecture of the target system - Plan 9 imports it from the
#       environment; for other systems it is usually just hard-coded
#
#OBJTYPE=386                    # target system object type (eg, 386, arm, mips, power, s800, sparc)
OBJTYPE=$objtype

#
#       no changes required beyond this point
#
OBJDIR=$SYSTARG/$OBJTYPE

<$ROOT/mkfiles/mkhost-$SYSHOST                  # variables appropriate for host system
<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE # variables used to build target object type

Eh, lets correct this. My build environment lies in /home/snegovick/dev/inferno/inferno-os-lpc2468 (important: relative paths do not work on later build stages, so you have to type the absolute one), Im building on Linux 64 bit machine. So I guess that my config should look like this:

#
#       Set the following 4 variables.  The host system is the system where
#       the software will be built; the target system is where it will run.
#       They are almost always the same.

#       On Nt systems, the ROOT path MUST be of the form `drive:/path'
ROOT=/home/snegovick/dev/inferno/inferno-os-lpc2468

#
#       Specify the flavour of Tk (std for standard builds)
#
TKSTYLE=std

#
#       Except for building kernels, SYSTARG must always be the same as SYSHOST
#
SYSHOST=Linux           # build system OS type (Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
SYSTARG=$SYSHOST                # target system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)

#
#       specify the architecture of the target system - Plan 9 imports it from the
#       environment; for other systems it is usually just hard-coded
#
OBJTYPE=386                     # target system object type (eg, 386, arm, mips, power, s800, sparc)
#OBJTYPE=$objtype

#
#       no changes required beyond this point
#
OBJDIR=$SYSTARG/$OBJTYPE

<$ROOT/mkfiles/mkhost-$SYSHOST                  # variables appropriate for host system
<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE # variables used to build target object type

Diff for your convenience:

< ROOT=/usr/inferno
---
> ROOT=/home/snegovick/dev/inferno/inferno-os-lpc2468
17c17
< SYSHOST=Plan9     # build system OS type (Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
---
> SYSHOST=Linux     # build system OS type (Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
24,25c24,25
< #OBJTYPE=386          # target system object type (eg, 386, arm, mips, power, s800, sparc)
< OBJTYPE=$objtype
---
> OBJTYPE=386           # target system object type (eg, 386, arm, mips, power, s800, sparc)
> #OBJTYPE=$objtype

That gives some output ending with:

Posix.o: In function `maketmp':
Posix.c:(.text+0x8a2): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
mk binary built successfully!

Lets assume again that it is ok though and celebrate the first successfull thung about Inferno! We've built mk!

mk is Inferno's own kind of make, we will deal with it later.

Stage 2. Building all the other tools

To build the other tools we will have to call mk which is situated in Linux/386/bin. It is not really convenient to use this path every time, so i propose to add a file called env.sh:

export PATH=$PATH:~/dev/inferno/inferno-os-lpc2468/Linux/386/bin

Now just do:

source ./env.sh

to add this to your PATH.

Ok, lets build everything!

inferno-os-lpc2468-2$ mk install

This takes some time on my machine. After it finishes with no obvious failure except few warnings, we are set to go further. You can examine all your shiny new tools in Linux/386/bin directory:

inferno-os-lpc2468$ ls Linux/386/bin/
5a     5cv  8c    c2l     emu  idea   ka  kprof   limbo   mkext       ms2    qc   srclist   vc
5c     5l   8l    data2c  ftl  inm    kc  ksize   md5sum  mkppcimage  ndate  ql   styxtest  vl
5coff  8a   acid  data2s  iar  iyacc  kl  kstrip  mk      mk.save     qa     sqz  va

You can even run emu and wm

inferno-os-lpc2468$ ./Linux/386/bin/emu -g1024x768
; wm/wm

wm/wm: