CeGCC cross compiler for PocketPC

This document describes how to build CeGCC. One chapter deals with building the software on Linux, another focuses on Cygwin (Windows + the Cygnus layer).

1. Building on Linux

There are two different sets of build scripts for Linux. The scripts in src/*.sh are being maintained (by Pedro), they can be used unchanged both on Linux and Cygwin. The scripts in scripts/linux are maintained to build an RPM file, they are Linux-only.

1.1. Background information

1.1.1 Things to modify

Theoretically you should be able to use the scripts and have to modify only the settings.sh script. That script contains exported shell variables for
SCRIPTDIRshould automatically point to the scripts/linux directory
TOP_SRCDIRshould automatically point to the top directory containing CeGCC
BUILD_DIRthis points to a temporary directory in which all of the build happens
PREFIXBy default, this is /usr/ppc. You should set it to suit your needs, this is where the tools get installed. (GNU default would be /usr/local).
MY_HOST_ARCHThis is the architecture on which we're building
TARGET_ARCHThis is the target architecture, for our project there are two such targets : arm-wince-cegcc and arm-wince-mingw32ce.

The scripts also includes $PREFIX/bin in the path to make sure that the newly built executables can be used by the other scripts in the build process.

1.1.2 Script concepts

All scripts reside in $SCRIPTDIR, that's scripts/linux in your distribution. The build.sh script is the master build script.

Beware: build.sh will initially clean up the complete $BUILD_DIR but also the contents of most of the $PREFIX. There's a small protection : it'll only clean up in $PREFIX if that's equal to /usr/ppc .

The tools need to be built in a sequence because they rely on each other. The text below is an overview to make you understand the issues involved, the real script (scripts/linux/build.sh) is the most (the only?) reliable source of information on this topic.

In this sequence, we always (configure and) build the tools, then immediately install them in $PREFIX. This is uncommon, but is the easiest way for us to deal with this sequence. Sadly, this conflicts with the concept of e.g. rpm so it is not possible to create a source RPM for this project in a simple way.

1.1.3 Hacks to work around problems

1.1.3.1 C++ compiler won't build

For some reason, the build process for the C++ compiler chokes. The only explanation - and workaround - that we know of is the one found in this old message saying

Configure creates a softlink in gcc object directory to the new
version of the cross assembler. Problem is that the native compiler
get confused and use the cross assembler instead of the native one.

We adapted the build-gpp.sh script for this : it'll configure, and then build everything. But the build is expected to fail (so the script won't terminate on this occasion), then $BUILD_DIR/gpp/gcc/as is removed (that's the file bothering us), then the build is restarted.

1.2 Building CeGCC for private use

This part is very simple : move to the scripts/linux directory and run build.sh . The software will turn up in /usr/ppc (add /usr/ppc/bin to your PATH) after a while.

1.3 Building a CeGCC RPM

To build an RPM for distribution, you'll need to do two things :

You should run scripts/linux/rpm-create-source.sh (from the scripts/linux directory). This will create a file called /usr/src/RPM/SOURCES/cegcc-src-0.11.tar.gz, in which the 0.11 part depends on variables sets in settings.sh.

For this to work, you'll need write permission in /usr/src/RPM/*, but the next steps also require this.

To build the RPM, you must run rpmbuild -ba cegcc.spec which is another file in the scripts/linux directory.

You'll need two prerequisites for this to work : write permissions in /usr/src/RPM, and you'll have to make sure that the version numbers in scripts/linux/settings.sh and scripts/linux/cegcc.spec match.

2. The portable build - Building on Cygwin and Linux

Pedro will probably write documentation on this.

3. Requirements

There is nothing out of the ordinary in the tools you need to build cegcc, most free software packages require the same :

You don't need automake, autoconf or such tools : the cegcc sources, even the ones in SVN, already contain the files generated by these tools. Note that we need to do this as some of the software that is part of cegcc requires different revisions of the auto tools than other parts of cegcc.

4. A tour of the directory structure

how to download

scripts
scripts/linux The directory containing the linux build scripts
src The master source directory
src/newlib
src/cegcc/cegccdll
src/cegcc/importlibs/defs Definition files to create libraries to match WinCE DLL's
src/cegcc/importlibs
src/cegcc/cegccthrd
src/cegcc/libstdc++
src/cegcc/fixincludes
src/cegcc
src/gcc The gcc sources
src/gdb The gdb sources
src/binutils The binutils sources (gas, ld, ..) 
src/w32api/include The target system include files
src/w32api/lib an unused part of w32api
src/w32api
build This directory is created from the source tree
build/i686-pc-linux-gnu/arm-wince-cegcc/gdb/gdb/testsuite/gdb.trace
build/i686-pc-linux-gnu/arm-wince-cegcc/gdb/gdb/testsuite
build/i686-pc-linux-gnu/arm-wince-cegcc/gdb/gdb
build/i686-pc-linux-gnu/arm-wince-cegcc/gdb
build/i686-pc-linux-gnu/arm-wince-cegcc
build/i686-pc-linux-gnu
website Our website contents are also managed via the source repository
website/images
docs The CeGCC project's documentation