Mobile/Build/Maemo Build Instructions
Look here: https://wiki.mozilla.org/Mobile/Build/cs2007q3
Important note
This page is referred to from [1] and should be useful at this time only for its guidelines about installing scratchbox and libIdl. The part about building the Mozilla trunk 1.9 for Fennec is obsolete (it's using the old CVS trunk). Building Fennec from mozilla-central worktree, fetched with mercurial (hg) should be preferred. Relevant instructions are to be found at : [2]
Setting Up Scratchbox
The maemo SDK is based around a tool called scratchbox. Scratchbox is a sandboxed emulator that you run on a development machine to configure, compile and run (test) the binaries that are to be installed on a target mobile device. It eliminates a lot of the difficulties associated with traditional cross compilation by essentially letting you pretend you're not cross compiling. To set it up, Nokia has written a very useful script called maemo-scratchbox-install.
These instructions are for setting up a new scratchbox installation. If you have an existing (i.e. 3.2/bora) scratchbox installation, you'll have to set an alternate path for the installation.
Debian-based Linux distributions
Scratchbox will be installed by default from Debian .deb packages to the path /scratchbox
wget http://repository.maemo.org/stable/chinook/maemo-scratchbox-install_4.0.1.sh
sudo chmod a+x ./maemo-scratchbox-install_4.0.1.sh
sudo ./maemo-scratchbox-install_4.0.1.sh
sudo /scratchbox/sbin/sbox_adduser $USER yes
Replace $USER with an explicit user name if you want to create a scratchbox login for a user other than the current user.
Other Linux distributions
On any other Linux distribution, the install will use .tar.gz files and you will have to specify the desired destination directory.
wget http://repository.maemo.org/stable/chinook/maemo-scratchbox-install_4.0.1.sh
sudo chmod a+x ./maemo-scratchbox-install_4.0.1.sh
sudo ./maemo-scratchbox-install_4.0.1.sh -s /scratchbox
sudo /scratchbox/sbin/sbox_adduser $USER yes
Again, replace $USER with an alternative user name if you like.
Setting Up the Maemo Chinook SDK
Before you proceed with installing the Maemo SDK, you need to create a new login shell so that your user is added to the sbox group that you just created when you installed scratchbox. You can do this by just logging out and logging back in again (that means log out of your machine -- creating a new terminal window will NOT work).
To set up the Maemo SDK, Nokia has provided another easy to use script. You can just accept the defaults and type "I accept" at the appropriate time, but if you want to debug your code you should select the 4th option on the "Package Selection" menu. You will also want to install "Closed Nokia Binaries".
Warning: if you are running Ubuntu Hardy Heron (8.04), read this before you proceed any further. You'll need to run both these commands to be able to install the Maemo SDK.
To install the Maemo SDK onto your host machine run:
wget http://tablets-dev.nokia.com/4.0.1/maemo-sdk-install_4.0.1.sh
chmod +x maemo-sdk-install_4.0.1.sh
bash maemo-sdk-install_4.0.1.sh
[Note: Maemo bora (3.0) is seemed incompatible because the file gtk+-unix-print-2.0.pc seems missing in Bora.]
Selecting a Scratchbox Target
A target in a Scratchbox is a separate environment that has a selected toolchain, target CPU and an own file system. See "introduction to Scratchbox" for more information about what targets are.
Once you've followed the instructions above, your Scratchbox install will have two targets: an x86 target and an ARM target. To log into Scratchbox, simply run the command:
scratchbox
Once you've logged into Scratchbox, the prompt will change to one of the following prompts depending on whether the x86 or the ARM target is selected:
[sbox-CHINOOK_X86: ~] >
or
[sbox-CHINOOK_ARMEL: ~] >
You can switch from one target to another whilst logged into Scratchbox using:
sb-conf select CHINOOK_X86
or
sb-conf select CHINOOK_ARMEL
To exit Scratchbox and get back to the host system, simply run 'exit'.
Note: if you see this:
sb-conf: You must close your other Scratchbox sessions first
but you can't find your other Scratchbox sessions, you can force close them by running the command 'sb-menu', selecting 'Killall', and then sending a 9.
Building libIDL
The maemo SDK comes with just about everything required to build mozilla. The one thing that is missing is libIDL. The simplest thing to do is to build it. Run these commands in the scratchbox prompt:
sb-conf se CHINOOK_X86
wget http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.9.tar.gz
tar -xzvf libIDL-0.8.9.tar.gz
cd libIDL-0.8.9
./configure
make
fakeroot make install
cd ..
Building the Trunk (Mozilla 1.9)
Finally, you are ready to build. Run these commands at the scratchbox prompt.
sb-conf se CHINOOK_X86
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/usr/local/lib/pkgconfig/
mkdir moz1.9
cd moz1.9/
cvs -d:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk mozilla/browser/config
cd mozilla/
cp browser/config/mozconfig .
echo "mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-dir-browser-chinook-armel" >> mozconfig
echo "ac_add_options --disable-tests" >> mozconfig
make -f client.mk checkout
make -f client.mk build
Note: with GCC 3.4 you may encounter an error compiling jemalloc. To fix this, install GCC 4. Or, as a workaround, edit memory/jemalloc/Makefile.in
in the Mozilla source, and change the MODULE_OPTIMIZE_FLAGS setting from -O2
to -Os
.
Running your Build
To run your build in scratchbox, you'll need to install xephyr from your host machine (i.e. outside scratchbox). Fortunately, if you are on a Debian based system such as Ubuntu, this couldn't be easier. Just run:
sudo apt-get install xserver-xephyr
To start the xephyr server, run the following from the host machine (outside scratchbox):
Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -extension Composite
Once the xephyr xserver is running, it will open a window that can be used to display your build. Run your build by logging into scratchbox and then running the following commands:
sb-conf select CHINOOK_X86
export DISPLAY=:2
af-sb-init.sh start
cd moz1.9/mozilla/obj-dir-browser-chinook-armel/dist/bin
GRE_HOME=. ./run-mozilla.sh ./TestGtkEmbed # this is not yet runnable
or
GRE_HOME=. ./run-mozilla.sh ./firefox
Running your build, on the device
If you built using the CHINOOK_ARMEL target, you can run the binaries on the N800/N810 device directly.
First, create a tarball from your build:
cd moz1.9/mozilla/obj-dir-browser-chinook-armel/
make package
This will create a compressed tarball under dist, name like firefox-3.0pre.en-US.linux-arm.tar.bz2
. You probably want to uncompress this now with bunzip2
, because Maemo doesn't include that utility.
Copy the file to the device, and open a command line (X Terminal) to extract the tarball and launch it:
$ tar xf firefox-3.0pre.en-US.linux-arm.tar
$ cd firefox
$ ./firefox
Convenient scripts (NOT UP TO DATE. Please use the instructions above.)
The following scripts can help speed up the process. You don't even have to start the scratch box shell if you run them with the following commands:
cat buildlibIDL.sh | scratchbox -s -p
cat buildmoz19.sh | scratchbox -s -p
VMWare Image
Alternatively, you can download this VMWare image which has already been set up to build mozilla for maemo.
Debugging UI Hints
If you are going to be hacking on the front end, here are some hints for you. First you want to set up keys on your device so that you do not have to type a password when ssh'ing into the device:
1. on the device, cd ~ 2. mkdir .ssh 3. copy your public key to ~/.ssh/authorized_keys
Now you should be able to ssh from your main machine into your device.
ssh root@<device's ip> BusyBox v1.6.1 (2007-09-27 18:08:59 EEST) Built-in shell (ash) Enter 'help' for a list of built-in commands. Nokia-N810-51-3:~#
Now, in your build tree, after you make a change, you can type this command and it will build your tree, copy over the bits, then execute fennec:
make ; scp dist/bin/chrome/browser.jar root@<device's ip>:/root/fennec/chrome ; ssh -f root@<device's ip> DISPLAY=:0 /root/fennec/fennec