Hi,

eine Nachricht von Marco van de Voort zum Thema Build von OpenXP
unter Linux als FreeBSD-Version:

To: Markus Kaemmerer <mk@happyarts.de>
Subject: Re: FreeBSD/NetBSD
From: marcov@stack.nl (Marco van de Voort)
Date: Tue, 14 Jan 2003 23:42:44 +0100 (CET)

[...]

I tried to compile the IDE on Linux for FreeBSD (as a model for openxp, it
uses the same libraries). and took notes.


PP=ppcrel is the compiler to be used. My global FPC is 1.1, hence.

to make the rtl

cd fpc/rtl

make OS_TARGET=freebsd PP=ppcrel -n'

make freevision (or other packages)

make OS_TARGET=freebsd PP=ppcrel OPT='-Fu../rtl/freebsd -n'

If you package depends on more packages, add more -Fu's

Building the IDE, note that I suddenly use absolute paths (though relative to ~). This is because sometimes
packages can descend deeper into directories, and the relative paths don't match anymore then,

make OS_TARGET=freebsd PP=ppcrel OPT='-Fu~/cvs/fixes/fpc/rtl/freebsd -Fu~/cvs/fixes/fpc/fvnew -va -n' 

This bombs out with:

fp.pas(551) Warning: Object cprt21.o not found, Linking may fail !
Using util /usr/bin/ld
/usr/bin/ld  -dynamic-linker=/lib/ld-linux.so.2   -L. -o ./fp ./link.res
fp.pas(551) Error: Error while linking
Closing script ./ppas.sh
make[1]: Leaving directory /home/marcov/cvs/fixes/fpc/ide'

(which is not bad. linking error at this point is not bad)

I've copied some freebsd libraries .a and .o files to ~/crossy.
(I put these on http://www.stack.nl/~marcov/freebsdstatic.tar.bz2 400k)

editing link.res:

- remove all SEARCH_DIR's that point to Linux dirs (/lib /usr/*)
- add a SEARCH_DIR to ~/crossy
- change cprt21.o to cprt0.o in the input section
- in the input section, change all references to .o files in /usr/* etc to ~/crossy/
- in the second input section (the one with -lncurses and -lc), change it to this:
   (gcc added, and paths qualified, .a suffix, lib prefix). This is because -l searches
    in default locations. This will make it look like this:

INPUT(
/home/marcov/crossy/libgcc.a
/home/marcov/crossy/libncurses.a
/home/marcov/crossy/libc.a
)

edit ppas.sh:

- added -static to the ld commandline
- remove the ld-linux-so parameter.


(so it will look like this:

/usr/bin/ld  -static  -L. -o ./fp ./link.res

)

run 

./ppas.sh

a binary fp will be generated

On FreeBSD, do 

brandelf -t FreeBSD fp

This is necessary because we use a plain linux linker (not a FreeBSD crosslinker) if you have
a FreeBSD crosslinker, one could probably omit this step.

---
Afterwards I was talking to Peter V. on IRC, and he said that globally (so in fpc/)
running "make all OS_TARGET=freebsd" would create a full cross- rtl and packages etc.

But because FreeBSD currently has a small problem in the 1.0.x FCL this bombs now, but I hope
to fix that one of these days.



