= Porting Software to HelenOS = This page shall contain a brief guide for porting software (e.g. from GNU/Linux) to HelenOS. Currently, it only contains assorted links to existing resources. == Links == * [BinutilsMaintenance Maintenance instructions for binutils] * [http://vh.alisma.cz/blog/2013/01/24/towards-gcc-for-helenos Blog] [http://vh.alisma.cz/blog/2013/01/27/towards-gcc-for-helenos-2-libgmp posts] [http://vh.alisma.cz/blog/2013/02/13/towards-gcc-for-helenos-3-libmpfr about] [http://vh.alisma.cz/blog/2013/11/06/gcc-for-helenos-sitrep GCC] [http://vh.alisma.cz/blog/2013/11/07/gcc-for-helenos-todo porting] * [https://github.com/vhotspur/coastline Coastline] - scripts for porting POSIX-like software to HelenOS (and some [http://vh.alisma.cz/blog/2013/03/30/introducing-helenos-coastline blog] [http://vh.alisma.cz/blog/2013/12/08/helenos-coastline-updates-status-matrix posts]) * Python porting: [https://github.com/zhalas/helenos-build-python repository] and [http://lists.modry.cz/private/helenos-devel/2013-April/006421.html ML announcement] == POSIX emulation layer == HelenOS is not [wiki:DiffFromUnix another Unix-like OS] and thus it needs an emulation for applications that were written for Unix systems. This emulation is currently in HelenOS provided by `libposix` library that provides implementation of functions that are part of POSIX standard but were considered inappropriate for HelenOS. `libposix` provides an (incomplete) illusion that the application has access to standard POSIX headers and functions. The ported application is then linked with `libposix` which translates the calls to HelenOS specific implementations in `libc`. //Implementation detail//: some of the functions in `libc` have the same name as standard POSIX ones or they offer slightly different behaviour. To prevent naming clashes, symbols in `libc.a` are renamed to avoid the need to rename the POSIX versions (which was an older approach where renaming was done during preprocessing, however this approach has various disadvantages). == General approach == For most (reasonable) GNU/Linux programs, we can assume that they are distributed with a `./configure` script. The purpose of this script is to check the environment and prepare `Makefile`s needed for actual compilation. In order to build the application for HelenOS we "only" need to persuade the `configure` script to cross-compile it and use HelenOS specific compiler flags and link with `libposix`. Although this seems as a simple task because `configure` offers parameters/variables for exactly this, there are several obstacles. * HelenOS currently uses Linux ABI and thus the cross-compiler used gives the impression that the target is GNU/Linux system. This could lead to some false expectations. * There is a lot of compiler/linker flags that are passed. The amount itself obscures a reasonable editing of the command line. * HelenOS works mostly with static libraries. When linking with static libraries, their order is important and they typically need to come after object files for proper linking. That is not always possible to specify with plain `LDFLAGS` or `CFLAGS` settings. The above means that either patching or some build scripts is sometimes necessary or that the invocation line for `configure` is rather complex (or both). To simplify the above and, foremost, to allow repeatable builds, the so called Coastline was created. == Coastline == Currently, Coastline is hosted as a separate Git [https://github.com/vhotspur/coastline repository on GitHub]. TODO: * principles * extracting the flags * caching built libraries * harbours * usage * writing harbour files