Skip to content

Getting Started

Álvaro Jurado edited this page Feb 18, 2016 · 33 revisions

What is this

This is an implementation and a certain redesign of old Plan 9 ANSI/POSIX Environment (APE). Now APEX runs in amd64, implements C99 and POSIX.1-2008/IEEE Std 1003.1, and is built with GCC(and soon, I hope, Clang).

This file is a quick list of instructions to get you started quickly.

Prerequisites

To build APEX and play with it, you need to have git, GCC, binutils and (GNU)make installed. And of course, a running Harvey OS to use it. On a Debian, Ubuntu or other .deb system, you should be able to get going with

sudo aptitude install git build-essential

GERRIT

Before at all, you can clone the repo wherever you want, now APEX for Harvey is tree independent. So you needn't use $HARVEY/sys/src/ape and its related bin/lib/include directories anymore.

We use gerrithub.io for code-review. If you want to submit changes, go to

https://review.gerrithub.io/#/admin/projects/Harvey-OS/apex

and check out the repository from gerrithub rather than github. The clone command will probably look something like this:

git clone ssh://[email protected]:29418/Harvey-OS/apex

you'll need to run a few commands inside the top-level directory to get set up for code-review:

cd apex
curl -Lo .git/hooks/commit-msg http://review.gerrithub.io/tools/hooks/commit-msg
chmod u+x .git/hooks/commit-msg
git config remote.origin.push HEAD:refs/for/master

You're now all set, you can build the whole thing just by running

make

which should take maybe less than a minute. It will build libap.a and libbsd.a only. That is all that you need to compile ANSI/POSIX C programs for Harvey.

You can build libs separately typing make inside every directory lib or even inside lib/ap, typing make in every directory of sources included (amd64, gen, math, plan9, posix, stdio, stdlib, mutibyte...).

Once building is complete, you can test in Harvey (see its wiki).

Rules and tricks to patch commits or fix code with gerrithub repo are the same as in Harvey's repo. (One more time see Harvey's wiki). More information on using Gerrit can be found on the gerrithub.io website.

Running your programs

You can use the ninep server to serving your APEX programs (see Harvey's wiki). In fact, you can put your APEX binaries wherever you want, into Harvey's tree or not. That includes other file servers, imported directories, binded or mounted directories, etc... Just ensure that you have in your Harvey's path the destination directory to your Harvey's APEX programs. Putting inside of one of the standard directories for binaries or using bind or mount.

Example:

ajc@ajc-machine:~/source/c$ gcc -c -I /home/ajc/source/apex/amd64/include -I /home/ajc/source/apex/include -I . -mcmodel=small -O0 -fplan9-extensions -mno-red-zone -ffreestanding -fno-builtin -nostdlib -trigraphs -Wall -Wno-missing-braces -Wno-parentheses -Wno-unknown-pragmas -Wuninitialized -Wmaybe-uninitialized -g hello-posix.c

ajc@ajc-Vostro-3560:~/source/c$ ld -o hello-posix -static hello-posix.o -L /home/ajc/source/apex/amd64/lib -L /home/ajc/source/harvey/amd64/lib -e_main -lap -lc

ajc@ajc-Vostro-3560:~/source/c$ cat hello-posix.c 

#include <stdio.h>

int
main (void)
{
	printf("Hello world from ANSI!\n");
	return 0;
}

harvey@cpu% /apex/amd64/bin/hello-posix
Hello world from ANSI!

As you can see, I have APEX repo in my home, under source/apex. Note that we used -L pointing to where I have Harvey's runtime libs in order to link against libc.a (-lc). That's all you need from Harvey to compile ANSI programs to Harvey. After that I setup ninep and mounted my APEX repo in /apex, to test my hello world.

Clone this wiki locally