Cross-compiling
From Agar
Porting Agar to platforms without fully-featured operating systems requires a cross-compiling toolchain. This article describes the typical process as performed from a Unix-style environment. It is assumed that you already have installed a toolchain for the target environment.
This guide applies to Agar starting from version 1.4.1 (prior versions required some specific work-arounds, notably the byte order had to be specified manually).
Here we will use arm-unknown-linux-gnu as an example.
Configuring
First you need to create a temporary build directory where Agar will be built. It is always preferable to build outside of the source directory:
$ mkdir /tmp/w-agar-arm $ cd /tmp/w-agar-arm
From the build directory, invoke Agar's configure script, taking care to set the appropriate $CC and $CFLAGS. You may need to specify a $PATH depending on where your toolchain is installed. /path/to/src is the path to the Agar source directory, and /path/to/inst is the path to the target installation directory.
$ env PATH="/path/to/my/toolchain:$PATH" CC=arm=unknown-linux-gnu-gcc CFLAGS="-O2 -g" \ /path/to/src/configure \ --srcdir=/path/to/src \ --host=arm-unknown-linux-gnu \ --prefix=/path/to/inst \ --disable-threads --without-{sdl,freetype,gl}.
If pthreads, SDL, FreeType and OpenGL support were required, these libraries would need to be compiled for the target environment as well. You would normally have these installed either under /path/to/my/toolchain (so that ./configure will pick up the appropriate "foo-config" scripts), or you can specify their installation prefix explicitely. In this example, we'll build a stand-alone Agar, assuming you'll be implementing a driver (see AG_Driver(3)) for your target platform (as opposed to using an existing driver such as sdlfb or sdlgl).
Building the library
Execute make to build the library and make install to install in --prefix. Make sure to set $CC explicitely as well (the $CC passed to ./configure will not be remembered):
$ env PATH="/path/to/my/toolchain:$PATH" make
You can now compile your application and link it against the version of Agar compiled for your target platform:
$ unknown-linux-gnu-gcc `/path/to/inst/bin/agar-config --cflags` -o foo foo.c `/path/to/inst/bin/agar-config --libs`

