EnvironmentSetup/HaikuOS

Full build process last tested with OOo4Kids r1522 and Haiku gcc2hybrid hrev44528 in August 2012.

Prerequisites

 * A recent Haiku nightly build from http://haiku-files.org/ (release >= r39101 should be ok). A gcc2hybrid is better as it is the official flavor. It is also what i use. Unfortunately, Haiku alpha 2 ( http://www.haiku-os.org/get-haiku) has bugs that prevent a full build of OOo4kids.
 * About 15 Go of free disk space on the Haiku partition
 * Lots of computer time : the full build process will take many hours (depending on your hardware)
 * Other tools :
 * haikuporter system for some more tools (see http://ports.haiku-files.org/wiki)
 * Archive-Zip-1.30
 * gperf
 * pkg-config-0.23-haiku-2.zip
 * freetype-2.3.10-r1a1-x86-gcc2-2009-10-09.zip
 * fontconfig-2.6.0-gcc2-2008-12-19.zip
 * ccache-2.4
 * gengetopt-2.22.4
 * getopt

Warning
This process assume a clean default Haiku partition (one that has just been installed).

This process use some hacks and workaround that change the system (especially in the following directories) :

* /boot/common/bin * /boot/common/include/unicode * /boot/common/include/layout * /boot/home/config/bin

This might break others applications on existing partitions...

Commented script

 * 1) Preparing the source tree


 * 1) run this from a /boot/src directory (for example)

mkdir ooo4kids

cd ooo4kids

installoptionalpackage subversion
 * 1) install svn


 * 1) get the source tree

svn co svn://svn.adullact.net/svnroot/ooo4kids1/trunk.


 * 1) could take more than one hour... Be patient

cd ..


 * 1) install Haikuporter

wget http://ports.haiku-files.org/svn/haikuporter/trunk/installhaikuporter.sh chmod 755 installhaikuporter.sh ./installhaikuporter.sh


 * 1) get dependencies

ooo4kids/solenv/inc/startup/HAIKU/scripts/getHaikuDependencies.sh


 * 1) two crash while compiling ICU... Need more investigation...
 * 2) just enter the debugger and write "continue" in it
 * 3) We only need those binaries :
 * 4)  - genbrk
 * 5)  - genccode
 * 6)  - gencmn

cd ooo4kids


 * 1) configure OOo4Kids

./configure --with-use-shell-bash --disable-odk --disable-mozilla --disable-binfilter --with-OOo4Kids \ --with-java=no --disable-gtk --disable-randr-link --disable-gconf --disable-gnome-vfs \ --with-system-libxml --with-system-icu --with-system-openssl --with-system-python \ --with-system-curl --with-system-neon

cp /boot/common/data/automake-1.11/config.guess dmake cp /boot/common/data/automake-1.11/config.sub dmake
 * 1) We need to compile dmake ourself to pass right commands and support Haiku.

cd dmake

./autogen.sh ./configure --prefix=/boot/common make install cd ..

./bootstrap

ln -s $PWD/solenv/bin/mkout.pl /boot/home/config/bin ln -s $PWD/solenv/bin/zipdep.pl /boot/home/config/bin ln -s $PWD/solenv/bin/build.pl /boot/home/config/bin ln -s $PWD/solenv/bin/deliver.pl /boot/home/config/bin ln -s $PWD/solenv/bin/modules /boot/home/config/bin

ln -s /boot/common/bin/dmake $PWD/solenv/bin
 * 1) needed because i have hardcoded the path in solenv/bin/build.pl to run commands

solenv/inc/startup/HAIKU/scripts/full_build.sh


 * 1) Outputstream problems
 * 2) see http://lists.freedesktop.org/archives/libreoffice-commits/2011-January/005750.html


 * 1) Proposed patch (don't forget to remove "#") :


 * 1) Index: comphelper/inc/comphelper/oslfile2streamwrap.hxx
 * 2) --- comphelper/inc/comphelper/oslfile2streamwrap.hxx	(revision 1517)
 * 3) +++ comphelper/inc/comphelper/oslfile2streamwrap.hxx	(working copy)
 * 4) @@ -91,8 +91,6 @@
 * 5) 	OSLOutputStreamWrapper(::osl::File& _rFile) :rFile(_rFile) { }
 * 6) // UNO Anbindung
 * 7) -	virtual void			SAL_CALL acquire throw
 * 8) -		{ OutputStreamWrapper_Base::acquire; }
 * 9) 	virtual void			SAL_CALL release throw
 * 10) 		{ OutputStreamWrapper_Base::release; }
 * 11) 	virtual ::com::sun::star::uno::Any	SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException)
 * 12) Index: unotools/inc/unotools/streamwrap.hxx
 * 13) --- unotools/inc/unotools/streamwrap.hxx	(revision 1517)
 * 14) +++ unotools/inc/unotools/streamwrap.hxx	(working copy)
 * 15) @@ -124,9 +124,6 @@
 * 16) public:
 * 17) 	OOutputStreamWrapper(SvStream& _rStream) :rStream(_rStream) { }
 * 18) -// UNO Anbindung
 * 19) -	DECLARE_UNO3_AGG_DEFAULTS(OOutputStreamWrapper, OutputStreamWrapper_Base);
 * 20) // stario::XOutputStream
 * 21) 	virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
 * 22) 	virtual void SAL_CALL flush throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
 * 1) -	DECLARE_UNO3_AGG_DEFAULTS(OOutputStreamWrapper, OutputStreamWrapper_Base);
 * 2) // stario::XOutputStream
 * 3) 	virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
 * 4) 	virtual void SAL_CALL flush throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
 * 1) 	virtual void SAL_CALL flush throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);


 * 1) All compiled (except this problem in package system)


 * 1) ERROR: Saved logfile: /boot/src/ooo4kids/instsetoo_native/haiku.pro/OOo4Kids/installed/logging/en-US/log_O4K131_en-US.log
 * 2) Thu Aug 16 11:03:57 2012 (17:14 min.)
 * 3) dmake: Error code 255, while making 'openoffice_en-US.installed'
 * 1) dmake: Error code 255, while making 'openoffice_en-US.installed'


 * 1) ERROR: Error 65280 occurred while making /boot/src/ooo4kids/instsetoo_native/util
 * 2) rmdir /tmp/fvSzzs0Cne

Getting subversion
As Haiku has switched to git for his own use, subversion is no more included by default on a fresh setup.

You can install it using this command :

installoptionalpackage subversion

Getting sources
svn co svn://svn.adullact.net/svnroot/ooo4kids1/trunk OOo4Kids

Please do not checkout a revision between 1217 and 1250 (included), because the build was broken in meantime in sysui, hunspell, and lingucomponent (ask ericb2 on IRC for further information)

Setup prerequisites (by hands)
Don't forget to set gcc 4 as the default compiler using this command

setgcc gcc4


 * Archive-Zip-1.30 :
 * Get the archive : http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/Archive-Zip-1.30.tar.gz
 * Uncompress the archive somewhere
 * then run "perl Makefile.PL" at the root directory of the source tree
 * run "make" twice (one for updating the build script, one to build the tool)
 * run "make install"


 * gperf :
 * run "installoptionalpackage -a gperf" from a Terminal. It will install the latest version compiled from http://haiku-files.org/


 * pkg-config :
 * Download a recent build from http://ports-space.haiku-files.org/dev-util/
 * Unzip it to /boot/


 * freetype :
 * Download a recent build from http://ports-space.haiku-files.org/media-libs/
 * Unzip it to /boot/


 * fontconfig :
 * Download sources at http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.9.0.tar.gz
 * Uncompress the archive
 * run "make"
 * run "make install"


 * libcurl :
 * run "installoptionalpackage curl" on a Terminal
 * you should add a symlink to "/boot/common/lib/curl.so" in "/boot/develop/abi/x86/gcc4/lib". It allow linking at compile time.


 * libxml : available by default


 * libxslt :
 * run "installoptionalpackage libxslt" on a Terminal


 * getopt : build it with haikuporter (see http://ports.haiku-files.org/ for details)
 * run "haikuporter getopt -i"


 * gettext :
 * run "installoptionalpackage gettext" on a Terminal (needed to compile hunspell)


 * libneon :
 * run "installoptionalpackage neon" on a Terminal


 * icu : Haiku contains icu built-in, but development tools and headers are not included. We will use haikuporter to get and build a complete version. But, you should not use the install option as the built version might be different from the system one. I will investigate this later. In the meantime, it is safer to install the necessary tools and headers "by hand" :
 * copy genbrk, genccode and gencmn from /boot/develop/haikuports/dev-libs/icu/work/icu/source/bin to /boot/common/bin
 * copy /boot/common/develop/haikuports/dev-libs/icu/work/icu/source/common/unicode to /boot/common/include/
 * copy /boot/common/develop/haikuports/dev-libs/icu/work/icu/source/i18n/unicode to /boot/common/include
 * create a layout directory in /boot/common/include
 * copy LayoutEngine.h, LEFontInstance.h, LEScripts.h, LETypes.h from /boot/common/develop/haikuports/dev-libs/icu/work/icu/source/layout/ in /boot/common/include/layout
 * link libicudata.so, libicuuc.so, libicui18n.so, libicule.so from /boot/system/lib/gcc4/ in /boot/develop/abi/x86/gcc4/lib


 * file : Install the file command. Latest sources at http://www.darwinsys.com/file/ should compile out of the box using the usual commands :
 * ./configure --prefix=/boot/common
 * make
 * make install


 * python
 * link libpython2.6.so in /boot/common/lib/ in /boot/develop/abi/x86/gcc4/lib to enable linking with this library using gcc 4.

With the above dependencies installed, you should be able to run the configure script

Setup prerequisites (with a script)
A script can do all steps above in one shot. This script is now located in the source tree (https://adullact.net/scm/viewvc.php/trunk/solenv/inc/startup/HAIKU/scripts/?root=ooo4kids1).

This script need an installed Haikuporter system. You can get the needed files using those commands :

wget http://ports.haiku-files.org/svn/haikuporter/trunk/installhaikuporter.sh chmod 755 installhaikuporter.sh ./installhaikuporter.sh

See http://ports.haiku-files.org/wiki for details.

You can now get and setup all dependencies using this command from the parent directory of root directory of the source tree (to avoid messing it) : ooo4kids/solenv/inc/startup/HAIKU/scripts/getHaikuDependencies.sh

Configure the build system
It may be necessary to run autoconf at the root of the source repository until the next configure rebuild.

./configure --with-use-shell-bash --disable-odk --disable-mozilla --disable-binfilter --with-OOo4Kids --with-java=no \ --disable-gtk --disable-randr-link --disable-gconf --disable-gnome-vfs --with-system-libxml \ --with-system-icu --with-system-openssl --with-system-python --with-system-curl \ --with-system-neon

(in one line !)

Bootstrapping

 * Update config.guess and config.sub in the dmake subdirectory with ones from Haiku (/boot/common/share/automake-1.11/).
 * Run "./autogen.sh" in the dmake subdirectory to update configure script.
 * Run "./configure --prefix=/boot/common"
 * Run "make install"
 * Run "./bootstrap" from the root directory of the source tree.

Workaround
I suppose there is a bug (or at least a different behavior under Haiku) regarding alias handling in the system call (see http://dev.haiku-os.org/ticket/7922).

It prevent build.pl to run some aliased commands out of the box.

First, i prefix $job_to_do with the complete path to the solenv/bin directory.

Index: bin/build.pl =================================================================== --- bin/build.pl	(revision 1239) +++ bin/build.pl	(working copy) @@ -1768,7 +1768,8 @@             system("cat $log_file"); };     } else { -       $error_code = system ("$job_to_do"); +   	# Haiku workaround +       $error_code = system ("/boot/src/OOo4Kids/OOo4Kids/solenv/bin/$job_to_do"); };     return $error_code; };

Then, i create a symlink to solenv/bin/mkout.pl, solenv/bin/zipdel.pl, solenv/bin/build.pl and solenv/bin/deliver.pl in /boot/home/config/bin/. A link to solenv/bin/modules is also needed to run build.pl and zipdel.pl (please, FIX ME !).

Due to the hardcoded path, you will have to add dmake in solenv/bin so build.pl could launch it.

Building OOo4Kids
/boot/src/OOo4Kids/OOo4Kids/cppu/haiku.pro/lib:/boot/src/OOo4Kids/OOo4Kids/sax/haiku.pro/lib" to fix linking with some libraries during the build (Haiku use some non standard places by default)
 * run "source HaikuX86Env.Set.sh" to setup the build environment at the root of OOo4Kids source tree
 * run "export LIBRARY_PATH=$LIBRARY_PATH:/boot/src/OOo4Kids/OOo4Kids/solver/1.30/haiku.pro/lib:\
 * run "make"

The build should start and stop on the next error to fix

To be continued...

VCL Development
Fortunately, it is not necessary to do a full build after each improvement in the Haiku part of the VCL. In fact, the turnaround time is quite fast. The VCL come with some demo applications that expose enough features to test the port.

The most complete one is in svtools/workben. A build script for Haiku is available in solenv/inc/startup/HAIKU/scripts. This script is called build_workben.sh.

The application need access to VCL libraries. The easiest way to do this under Haiku at the moment is to symlink solver/1.31/haiku.pro/lib in a lib directory in svtools/haiku.pro/bin/

To run the application, go to the svtools/haiku.pro/bin directory and then run ./svdem.

It might be necessary to copy some VCL files in this directory from vcl/haiku.pro/bin :


 * vclen-US.res. It might be necessary to rename it to vclen.res depending on your Haiku version (i need to fully understand the reason to fix this).