= Porting Tips = == Documentation == Some documentation: * A short but very helpful [http://revolf.free.fr/beos/BeGeistert-13/Porting%20Apps%20to%20BeOS.pdf slideset] on porting applications to BeOS by François Revol (mmu_man). * A comprehensive [http://www-src.lip6.fr/homepages/Alexandre.Duret-Lutz/autotools.html tutorial] on the GNU Autotools * Autotools - A Guide to autoconf, automake and libtool [http://www.freesoftwaremagazine.com/books/autotools_a_guide_to_autoconf_automake_libtool ebook] The CommonProblems page lists a number of common problems encountered when porting applications to BeOS. == Getting started on Haiku OS == === gcc 2.x (default) === When building your own Haiku image, you can add {{{ AddOptionalHaikuImagePackages Development ; }}} to your {{{build/jam/UserBuildConfig}}} file. This sets up a development environment and unzips a small tree of ready-to-use binary tools onto your image, including a Haiku-specific gcc2, [wiki:dev-lang/perl Perl] and autotools. Other helpful packages are {{{OpenSSL}}} and the {{{Pe}}} text editor (which allows you to jump to the line of an error message) and {{{Firefox}}} (which allows you to copy-and-paste console output to our Wiki pages). Most software cannot handle {{{i586-pc-haiku}}} yet, so it is usually necessary to {{{ cp /boot/common/share/libtool/config/config.* . }}} Where . is the package root folder, or the folder in which the package has outdated config.guess and/or config.sub files. If trying to build static and shared libraries, you may also need to run (try using {{{./autogen.sh}}} first if it exists, it usually runs all the autotools as needed): {{{ libtoolize --force --copy --install aclocal automake autoconf }}} Which "should" force the Haiku cases into your configure file. You might have to use other options to get aclocal/automake/autoconf to do this successfully. === gcc 4.x === Haiku now has a [http://www.haiku-os.org/news/2009-01-31/haiku_finally_gets_a_native_gcc4_full_story_inside native GCC4]. === gcc 2.x and 4.x hybrid === The following [http://www.haiku-os.org/node/2549 article] explains how to build a Haiku image that runs and is able to build both gcc 2.x and 4.x executables. == Porting considerations == To automatically patch software with the HaikuPorter tool, source tarballs should be diff'ed (cf. CreatePatch). Most projects however use SCM/VCS software, including [wiki:dev-util/cvs CVS], [wiki:dev-util/subversion Subversion], [wiki:dev-util/git Git], [wiki:dev-util/mercurial Mercurial] and [wiki:dev-util/bzr Bazaar], and accept patches only against their latest (HEAD/trunk/master) development version. A possible strategy is: 1. Download and try the latest released source tarball. If it works, no further steps are necessary. 1. Otherwise, check if the project maintains a publicly accessible (anonymous) source code repository. You might be able to choose between a branch corresponding to the version number of the source tarball, or trunk/master. (Terminology varies between the VCS tools.) Doing so, you can easily track or revert your own changes, and this is the preferred format for submitting patches to the respective projects. Note that it is not easily automatable for HaikuPorter though, but once accepted, future source tarballs promise to compile without patching. Also note that doing so may, depending on the project, result in more dependencies but might be easier to handle, for instance when modifying {{{configure.in}}} or {{{Makefile.am}}} instead of an Autoconf-generated {{{configure}}} or Automake-generated {{{Makefile}}}. == Preparing an archive for distribution == There are two methods for creating an archive for distribution, using DESTDIR and using diff_zip. [[BR]] [[BR]] For both situations, please use the following nomeclature as the : [[BR]] '''----.zip''' [[BR]] {{{ = is the name of the software. = the revision number of the actual software. = [ gcc2 | gcc4 ] = [ haiku | zeta | bone ] YYYY-MM-DD format and can be extracted by running `date +%Y-%m-%d` }}} [[BR]] DESTDIR is the preferred method : [[BR]] {{{ mkdir /boot/foo make install DESTDIR=/boot/foo cd /boot/foo/boot zip -r9y .zip * }}} [[BR]] diff_zip is an alternate method : [[BR]] Some software packages do not support the use of DESTDIR. For these cases, diff_zip is your friend. It was added to Haiku's source tree in [http://lists.berlios.de/pipermail/haiku-commits/2008-April/007561.html revision 24849]. Once the newly compiled software is ready to install, diff_zip is run in a second Terminal session. diff_zip will patiently wait for you to install the software. After installation, return to the second Terminal session to inform diff_zip to archive the newly added files. {{{ [terminal 1] make [terminal 2] cd ~/upload [terminal 2] diff_zip -r9y -- [terminal 1] make install [terminal 2] #press enter to activate diff_zip }}} == Providing Archive Distributions == If the package does not have any of the C++ runtime symbols, then a single package can be created. However if the package is gcc/ABI sensitive, then it should be released as two archives. Ideally one compiled with gcc2 and the other compiled with gcc4. For packages that are only compiled with one gcc, eg gcc4-only software, then a second archive should be created for use with gcc2hybrids. * packaging a gcc4-only item for a gcc2 hybrid 1. libraries go into */lib/gcc4 1. add-ons go into */add-ons//gcc4 -- eg, add-ons/Translators/gcc4 * packaging a gcc2-only item for a gcc4 hybrid 1. libraries go into */lib/gcc2 1. add-ons go into */add-ons//gcc2 -- eg, add-ons/Translators/gcc2 == Using CMake == If you find a CMakeLists.txt file in a package you are porting chances are it's using CMake. If you don't already have CMake installed go ahead and grab the [http://www.fileden.com/files/2008/8/23/2062382/packages/cmake-2.6.3-gcc2-haiku-2009-02-25.zip binary] and install it. Then try running cmake CMakeLists.txt or for the interactive ncurses version try ccmake CMakeLists.txt. Once the configuring is done, you use the normal make, make install, type commands, note the output may look different than you are used to. One thing you might notice with CMake is that configuring, fixing and configuring may go faster since it keeps track of where in the configure process it left of at. Feel free to update these notes as we will be seeing CMake more and more. [http://www.cmake.org/cmake/help/documentation.html CMake documentation] == Directories == As of Haiku R29880 several directories have been relocated. For details see the Haiku Developer's mailing list archive: http://www.freelists.org/post/haiku-development/Directory-renaming Feel free to update this entry with more details on possible fixes and details on how and where to use find_directory()