Portability is a desired feature when software is developed. Many strategies exist to address this problem. The one I am going to describe is the way GNU Gnulib intends to help developers to write portable programs.
Gnulib is a source repository shared by different projects, it provides a complete framework to write portable programs and help with some tedious tasks (add support for automake/autoconf, i18l, …).
The principal Gnulib goal is to provide a POSIX systems, providing workarounds where it is not completely supported, under these conditions a program can be written transparently from the underlying particular system. Gnulib components are shared at the source level, in other words, a program chooses which modules to use and those are imported in the program source tree.
To give an example, let’s say a program is using printf(3) with all its fancy format directives and some of them are not available everywhere; the program can import the `printf-posix’ module and be sure to work in the same way almost everywhere. The Gnulib include path must be used before any other path, in this way it can fix problems with functions from the standard library, something like:
gcc -c -I gnulib printf_example.c -o printf_example.o
gcc printf_example.o gnulib/libgnu.a -o printf_example
In the previous example, gnulib modules were imported in the gnulib directory and compiled in the gnulib/libgnu.a static library.
Usually programs using Gnulib provides a `bootstrap’ script which takes care to fetch the specified Gnulib modules.
I have noticed some Gnulib modules are not yet working properly on uClibc and they fail in some cases. Once these problems are fixed, many programs using Gnulib will be magically available for the OpenRISC platform.