Thursday, 8 July 2010

LAP - Toolchain, Part 1 - Binutils

As a reminder - we have just logged in as the lfs user.  Let's change into the directory we are going to use to unpack and build the source code. Remember we are using /tmp as a ramdisk:

cd /tmp

If you have less than 2G of RAM you may want to use the Amiga Key itself:

cd $LFS/sources

Note, we can now use the $LFS variable instead of typing out /media/lfs every time.

We start compilation with Binutils.  These are a selection of very basic utilities that I will never use directly, but support other programs (and therefore need to be installed first.  First of all uncompress the file:

tar -xjvf $LFS/sources/binutils-2.20.tar.bz2

Binutils needs its own working directory so we make it as follows:

mkdir -v binutils-build
cd binutils-build

And finally run the configure script with this command:

../binutils-2.20/configure --target=$LFS_TGT --prefix=/tools --disable-nls --disable-werror

First we go down one directory [..] then into the [binutils-2.20] folder where we run the script.  The [target] option uses the $LFS_TGT variable we set in the .bashrc script.  It is no less scarey now, so lets just pass over it.  The [prefix] option set the install path to the /tools directory.  As we know, because of the link we have made that actually points to /media/lfs/tools.  The [disable-nls] stops some localisation stuff from being built, which is not needed at this point.  Lastly, [disable-werror] prevents the compilation stopping if it encounters an error.

In a fucking fantastic turn of events, I got precisely NO ERRORS when I ran the script.  Amazing.

To compile the script, run:

time make $CORES_TO_USE

The time command will tell me how long this took, which is a useful test because the compilation times of all the other packages are measured in terms of this one.  It's time to get a beer, because this is going to take a while.  On my 1.6Ghz Celeron it took 9 minutes 1.6 seconds (which was reduced to 5 minutes and 13 seconds when I ran it with -j2 from the /tmp ramdisk).  On my 2.66Ghz i5 it took 2 minutes 58 seconds, or 1m 2 seconds with j4.  You then install the new programs you just compiled by running:

make install

We are now off and running!  If you look in the /tools directory now, you will see that it is starting to be populated.  Because we are installing onto a small partition we do not have space to keep the source code around, so bye bye the directories:

cd ..
rm -rvf binutils-2.20 binutils-build

This [r]e[m]oves the directories.  This [r]emoves everything in the directories, [v]erifies that it has done it, and [f]orces it to just fucking do it instead of checking with me.  Do not make mistakes with this command.  You will regret it.


No comments:

Post a Comment