Game Development Reference
In-Depth Information
As you can see, the toolchain mirrors the GNU GCC toolchain. In fact, the only noticeable difference
is that all the commands start with the prefix arm-none-linux-gnueabi .
With the toolchain in place, the last piece is a set of custom scripts to invoke the preceding
commands.
Writing Custom Compilation Scripts
Why do you need a set of custom compilation scripts? Because they will make the original Linux
compilation process as painless and transparent as possible when moving from the x86 to the ARM
platform. Ideally, you shouldn't need to change anything in the original Makefile to compile code for
ARM. However, as you'll see, this step can be incredibly painful, even for the seasoned C/C++ Linux
developer.
This section presents two custom compilation scripts:
agcc : This is a bash script meant to replace the GNU GCC compiler and wrap all
dependencies for an Android device.
ald : This is a bash script used in the linking process to create a final executable.
These scripts are critical and must be fully understood. But before we look at them, let's take a look
at the x86 compilation process and how it differs for an ARM device.
The Traditional Linux Compilation Process
In the traditional x86 Linux compilation process, a developer has a set of C/C++ programs and a
Makefile to build a final executable. The basic skeleton of a Makefile looks like this:
# Makefile Skeleton
# Object files
OBJS = file1.o file2.o....
# Header files
INC = -Ifolder1 -Ifolder2 ...
# Libraries and paths (used when linking)
LIB = -lc -lm -Lpath1 -Lpath2 ...
# Main target
all: $(OBJS)
@echo Linking..
gcc -o myapp $(OBJ) $(LIB)
# Compile C files
%o:%.c
@echo Compiling $<...
gcc -c $< $(INC)
The values OBJS , INC , and LIB (for objects, includes/headers, and libraries, respectively) are called
variables . The all and %o entries are called targets . Variables have a value separated by an equal sign ( = ).
Search WWH ::




Custom Search