This is the first of the serie of posts to introduce OOo development. It will be all about getting ready to hack, which means getting the sources, installing the dependencies and building the sources. The commands here are provided for openSUSE 11.2: you will certainly need to adapt them to your distribution.

Getting the sources

The sources are organized differently in upstream OpenOffice.org (the official version) and Go-oo. Upstream sources are stored in a mercurial repository and the development branches are called CWS (Child WorkSpace). The code integration process is pretty different from Go-oo where the sources are mainly composed of patches to apply on the upstream sources. Those patches are stored in a git repository. For the rest of the serie, I'll consider that the upstream sources are located on \~/upstream and the Go-oo sources on \~/go-oo on your machine.

The OpenOffice.org way

First install Mercurial:

sudo zypper in mercurial

Extract a clean copy of the sources in a folder that will never be touched. In fact, you will see that the created directory only contains a hidden folder and no source. I usually do this way to spare some bandwidth because downloading all the sources is quite a long operation.

cd ~/upstream
hg clone -U http://hg.services.openoffice.org/DEV300 local_DEV300

This operation takes a really long time, you can go out and do some sport (or whatever you like). After it is completed, you can see a local_DEV300 folder containing nothing but a hidden folder. This contains a copy of the sources hosted on the OpenOffice.org servers. The interest here is that you won't need to get everything when you will need to update that copy with the latest sources... and then you'll need to do less sport the next times!

In order to extract sources to build and hack, you will need to duplicate the downloaded sources in another folder. It will be \~/upstream/myhack in that tutorial. You will then be able to safely hack in that folder and keep the previous one clean for the sources updates.

hg clone local_DEV300 myhack

You are now ready to move to the build step.

The Go-oo way

First install Git:

sudo zypper in git

Extract the latest sources:

cd ~/go-oo
git clone git://anongit.freedesktop.org/git/ooo-build/ooo-build

Note that the master branch is unstable and may not build. You should ask the developers on IRC or on the mailing-list to check if the master is usable at that time. Otherwise, you may prefer to extract the sources of a stable branch. See the Go-oo wiki for more informations on how to get a particular branch. The sources are now happily sitting in a newly created ooo-build folder: you can move to the next step!

Building

In order to build you will need a lot of packages and dependencies. This step only needs to be done once for each machine you are building on. On openSUSE there is a nice trick to quickly install most of the dependencies for building OpenOffice.org or Go-oo:

# Enable the openSUSE sources package repository
sudo zypper mr -r repo-source
# Install the dependencies
sudo zypper si -d OpenOffice_org-bootstrap

Some dependencies will certainly be still missing as this install the ones to build the OOo version shipped with openSUSE and we will build a new version in most of the cases. Here is a command to install the missing dependencies (for the current versions)

sudo zypper in java-1_6_0-sun-devel junit4

As the Java JDK installation has updated some script run for each new shell you need to open a new shell to continue.

In order to speedup the build if you have a multi-core machine or several machines, you should carefully read Michael's blog post on icecream. The steps after starting the daemon aren't necessary for our cases: this needs to be adapted to OpenOffice.org build system (or won't be needed for Go-oo). Icecream will allow you to build on several cores / machines at the same time and then gain precious time. If you have a default installation of openSUSE, don't forget to change the firewall settings by either turn it off or add the rules to allow icecream through it.

The OpenOffice.org way

In order to configure the build you need to issue the following commands. Of course you can add some more parameters to the configure to spare some build time.

./configure --with-use-shell=bash --disable-build-mozilla
touch external/unowinreg/unowinreg.dll

Copy the mozilla binaries from the page http://tools.openoffice.org/moz_prebuild/OOo3.2/ into the \~/upstream/myhack/moz/zipped folder. The files to copy are depending on the architecture you are building on. Read carefully the error message of the configure to know which files to download and restart the configure command. Once the configuration is finished, you need to run the following commands:

./bootstrap
. Linux*Env.Set.sh

Note that the last command has to be issued any time you need to build some part of the OpenOffice.org sources: it sets a whole lot of environment variables used during the build. Without having run that command the build tool won't be found in the PATH. The first command generally needs to be called only at the first build.

For the ones who are going to perform a parallel build using icecream, the following commands are needed to build:

export CXX=/opt/icecream/bin/g++
export CC=/opt/icecream/bin/gcc
cd instsetoo_native
build --all -P6 -- -P6

For others simply run

make

The Go-oo way

The first thing to do is to configure the build. The arguments I'm using here are really generic: I usually don't build the KDE parts and some others to avoid installing some more dependencies. If you didn't install icecream in the previous step you can remove the corresponding options. The max jobs option specifies the maximum number of parallel jobs to run during the build.

cd ooo-build

./autogen.sh --with-distro=SUSE-11.2 --with-gcc-speedup=icecream --with-max-jobs=6

Now that the build is configured you can download the upstream sources needed to apply Go-oo patches. This step takes a while the first time and much less the next times as it uses git to download the upstream sources.

./download

Then you can actually build the sources using Gnu make. There is nothing to worry about the parallel build: the makefiles will handle it for you if you have used the proper options for the configure step.

make

After the build

Keep an eye on the build as this will take a lot of time and can break if there is something wrong in the sources or with your configuration. Now that your sources are built, you will need to learn how to hack OpenOffice.org. In the mean time you will certainly want to play with your freshly built toy. Here are some details about it.

The OpenOffice.org way

The quickest way is to follow that blog post.

export LOCALINSTALLDIR=~/upstream/myhack-install
cd ~/upstream/myhack/instsetoo_native/util
dmake openoffice_en-US PKGFORMAT=installed

To run the freshly installed OpenOffice.org:

cd ~/upstream/myhack-install/openoffice.org3/program
./soffice.bin

Note that this installation copies all the needed files from the build tree. If anything changed in the sources, you will need to copy the changed files from the build to the installation.

The Go-oo way

Go-oo provides some useful tricks to install a development instance. By running the following command you will have an OOo installed in \~/go-oo/ooo-build/build/install and the files of this install will be linked to the corresponding files in the build tree. Thus after a change and rebuild of the sources, there is nothing to do to have an updated install.

make dev-install

To run the installed OOo, you need to source the ooenv file. Here is how to do it:

cd ~/go-oo/ooo-build/build/install/program
. ooenv
./soffice.bin

Happy building until the next step!