| CrosscompilingFirefox |
 |
BeBits > TableOfContents > DeveloperArea > HowTo
How to Crosscompile Mozilla or Firefox (Firebird) :
Almost like BuildingFirebird but a lot more initial work :)
Nothing at all like BuildingCairo.
Prerequisites
A proper crosscompiled Haiku (either gcc4 or gcc2)
For me as I'm on Ubuntu x64 I built a gcc4 version:
Here is my minimal description:
sudo apt-get install build-essential g++-multilib subversion autoconf automake texinfo flex bison gawk
cd [your project dir]
svn checkout svn://svn.berlios.de/haiku/haiku/trunk haiku
svn checkout svn://svn.berlios.de/haiku/buildtools/trunk buildtools
cd buildtools/jam
make
sudo ./jam0 install
(OFFTOPIC: If you are going to build to a partition you might consider adding youself to the disk group.)
cd haiku
The --use-32bit is needed if you are on x64 and not using linux32 shell.
./configure --use-32bit --build-cross-tools-gcc4 x86 ../buildtools/
-a is to build everything, -q to fail if error, also there is -j<num> if you want several parallell processes
jam -a -q
Setup host libs and tools for crosscompiling Firefox
Mozilla uses autoconf2.13, we need it for regenerating configure later on.
sudo apt-get install autoconf2.13
We need glib and libIDL on host
sudo apt-get install libidl-dev libglib2.0-dev
We need Haiku's xres and mimeset for Linux. Luckily Haiku builds those for us.
mkdir [where you want tools to be]
cd [where you want tools to be]
We only link it so we get newer versions when Haiku is rebuilt.
ln-s [Haiku-dir]/generated/objects/linux/x86/release/tools/xres xres
ln-s [Haiku-dir]/generated/objects/linux/x86/release/tools/mimeset mimeset
The linux exes depends on these libs, so set them up.
ln-s [Haiku-dir]/generated/objects/linux/lib lib
Linux also needs a lot of help to find libs so lets tell it howto.
Create two files libroot_build.conf and libbe_build.conf in /etc/ld.so.conf.d/
as a superuser. They should contain the full path for [tools]/lib
Example of libroot_build.conf:
/home/myuser/projects/tools/lib
We need to tell Linux to upate library configuration.
sudo ldconfig
xres should now be runnable and print a page or two of messages
xres
Setup Haiku libs for crosscompiling Firefox
We need glib and libIDL for Haiku. Unfortunatly glib was hard to crosscompile
so I will not discuss it here. Hopefully someone will provide proper built versions.
For gcc2 I guess you can use BeOS compiled ones. Copy them to your linux system, and edit the paths
in their bin/*-config scripts to have the correct prefix.
If you need gcc4 I (tqh) have those and can get them for you. You will need to edit prefixes just like gcc2.
Setup the crosscompiler
Firefox needs a gcc-compiler that knows all the headers and libs that Haiku has. Unfortunatly BeOS had an
environment variable called BEINCLUDES which made it possible for you to use the same headers with a lot of
different prefixes. The crosscompiler don't so we need to emulate that by putting the same headers in several directories.
To set this up, and to make sure that we always use the same compiler as the Haiku build, I created a script.
It links the relevant parts from headers, libs and the Haiku crosscompiler to make a suitable one for Firefox.
It only needs to be run once to create the compiler. It can be downloaded from here.
Edit the script so that haikuRootDir points to the Haiku directory and set compilerRootDir to where you want your compiler created.
After that you can run it (if it has the execute flag set 'chmod u+x ./setup_compiler.sh') with
./setup_compiler.sh
Notice the instructions in the end. Some tools that firefox builds for linux needs a bit of knowledge about Haiku to get built.
You need to copy [haiku]/headers/os/BeBuild.h, [haiku]/headers/os/support/Errors.h, [haiku]/headers/os/support/SupportDefs.h
to /usr/include/support/ as a superuser. Create the support dir if needed.
Edit the /usr/include/support/SupportDefs.h so that
#include
#include <Errors.h>
becomes
#include <support/BeBuild.h>
#include <support/Errors.h>
Now the crosscompiler is ready. There is just a little bit more to be done.
Updating your .mozconfig for world domina.., err crosscompiling
To make firefox build a crosscompiled version you need to have appropriate
changes in your .mozconfig.
You need lines to point to the glib-config script you edited above.
Example:
export GLIB_CONFIG=/home/frho/haiku/glib/bin/glib-config
mk_add_options GLIB_CONFIG=/home/frho/haiku/glib/bin/glib-config
The same for libIDL:
export LIBIDL_CONFIG=/home/frho/haiku/libIDL/bin/libIDL-config
mk_add_options LIBIDL_CONFIG=/home/frho/haiku/libIDL/bin/libIDL-config
These are needed even when you don't crosscompile. The new thing is that
you will also need to add libIDL for the host platform:
export HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config-2
mk_add_options HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config-2
Make sure that the path is correct. That is where it's on my system at least.
Also tell Firefox to crosscompile for Haiku by adding these lines.
export CROSS_COMPILE=1
mk_add_options CROSS_COMPILE=1
ac_add_options --target=i586-pc-haiku
#Not really sure if these are needed.
ac_add_options --without-system-nspr
ac_add_options --without-system-zlib
ac_add_options --without-system-jpeg
ac_add_options --without-system-png
ac_add_options --without-system-mng
Getting and patching the code
Check out the Firefox2 code as usual apply the patches needed to crosscompile.
For the moment a complete patch suitable for Haiku and gcc4, not gcc2 containing the whole mozilla tree can be found here.
Apply it in your mozilla dir with:
patch -p0 -i mozilla-complete.patch
After applying this patch you will need to regenerate the configure file in mozilla and nspr dir.
You do this by running:
autoconf2.13
In both directories.
Build it and they will.. Just build it
Before building you need to update your path with the path to the crosscompiler's bin dir, and to the tools dir where xres and mimeset are.
Something along this line:
export PATH=[full path to crosscompiler]/bin:[full path to tools dir]:$PATH
After that you should be able to build from mozilla dir:
make -f client.mk build
When the build is done you should be able to package it by running the following in your build dir:
make -C browser/installer MOZ_PKG_FORMAT=ZIP
You should have a zip in your [build]/dist dir that contains the firefox packaged as Mozilla does it.
Almost asleep at the keyboard,
TQH
|
|
|