This instructional guide is based upon
this page. Yes, I changed some things. Trust me on all this, I know what I am doing, even if you don't think so.
First, you need to check out the FreeBASIC Subversion repository. This is something beyond the scope of this document, and if you're reading this page, you've probably already done this anyways. But some people feel they know everything, but don't, so, if you haven't done so already, then do these steps here:
- First, set the FBC_SRC variable in your shell (DO THIS EVEN IF YOU ALREADY CHECKED OUT THE SOURCE) like so: FBC_SRC=~/src/fbc/fbc-svn
- Next, check out the source: svn co https://fbc.svn.sourceforge.net/svnroot/fbc/trunk/FreeBASIC ${FBC_SRC}/FreeBASIC
- NOTE: If you copy and paste the command in line two (above) as-is, you'll get a "#" mark in the paste. Delete it, it'll muck everything up if you don't.
IMPORTANT NOTE: DON'T EXIT YOUR SHELL! FBC_SRC is only set for your current shell session and does not exist in any process except your current shell, and any (sub)processes that you start from that shell.
Also, for graphics, you need to have X11 installed. To keep shit simple, the
x11/xorg meta-port provides the entire X.org distribution (by declaring all of X.org as dependencies).
If you're on a clean FreeBSD install (which you're probably not), you can install X like so (as root):
cd /usr/ports/x11/xorg
make install distclean
Note that this process will take an hour or more, even on a fast quad-core machine, but like I already said, you probably already have X11 and don't need to do any of this.
Finally, since the compiler is written in FreeBASIC itself, you'll need to install a prebuilt copy of FreeBASIC - I (segin) have provided a build and you can find it
in this forum post.
If you've done everything right, you'll find the FreeBASIC runtime library source at
~/src/fbc/fbc-svn/FreeBASIC/src/rtlib unless you did something wrong, and the source is elsewhere (or not checked out at all). If these instructions are too confusing, well, it's a wiki page and someone else can make it less confusing.
Next, you're gonna need to symlink some C runtime objects into the FreeBASIC build tree, as well as create the directories for FreeBSD libraries:
cd ${FBC_SRC}/FreeBASIC/lib
mkdir freebsd
cd freebsd
ln -s /usr/lib/crt1.o
ln -s /usr/lib/crti.o
ln -s /usr/lib/crtbegin.o
ln -s /usr/lib/crtend.o
ln -s /usr/lib/crtn.o
cd ../../bin/freebsd
ln -s /usr/bin/as
ln -s /usr/bin/ar
ln -s /usr/bin/ld
If
mkdir fails and says the
freebsd directory already exists, pretend it worked anyways and continue as normal.
At this point, you need to have the libbfd library from GNU binutils 2.17 - note that the version must be
exactly 2.17, not 2.16, or 2.17.23.23. or 2.18, or anything but 2.17. FreeBASIC currently only has headers for version 2.17, and the library interface changes between versions, so use exactly that version, not newer or older ones.
For the moment, issue a blank
cd statement without specifying a directory - this will take you back to
~ - your home directory.
Now, download binutils 2.17 like so:
fetch http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2
tar jxf binutils-2.17.tar.bz2
cd binutils-2.17
And then build the relevant libraries:
cd intl && ./configure && make && cp libintl.a ${FBC_SRC}/FreeBASIC/lib/freebsd/ && cd ..
cd bfd && ./configure && make && cp libbfd.a ${FBC_SRC}/FreeBASIC/lib/freebsd/ && cd ..
cd libiberty && ./configure && make && cp libiberty.a ${FBC_SRC}/FreeBASIC/lib/freebsd/
At this point, you should have all the things done that you need to do before tackling the part of building FreeBASIC itself. Now, you compile the Runtime Library.
All you should have to do is this:
cd ${FBC_SRC}/FreeBASIC/src/rtlib/obj/freebsd
../../configure
gmake
gmake MULTITHREADED=1
gmake install
And now gfxlib2.
Again, just like with the runtime, do:
cd ${FBC_SRC}/FreeBASIC/src/gfxlib2/obj/freebsd
../../configure
gmake
gmake install
If the build fails complaining about not being able to find X11/extensions/X<whatever>.h, it's because the X.org guys restructured what packages some headers are in, removing library interface headers from the protocol headers packages and putting them in the package of the actual library they describe the interface of. Example: XInput.h was in inputproto but was removed from there and instead put in libXi. You have upgraded your xorg packages partially and have version mismatches - do
portupgrade -R xorg to fix it.
The compiler is straightforward, do:
cd ${FBC_SRC}/FreeBASIC/src/compiler/obj/freebsd
../../configure
gmake
And that's it! You should have a "fbc_new", cut from the latest subversion source! If you're looking to package a distribution, you can use the install.sh from my prebuilt copy.