Build (and use) a cross-toolchain using Dan Kegel's crosstool 0.38
Compiling programs on the LinkStation (native compiling) can take a very, very long time. A much faster method is to cross-compile programs using a cross-toolchain. A cross-toolchain allows you to compile code for the LinkStation on a faster computer with a different architecture, usually an i386/i686 desktop.
Building a Cross-Toolchain
We will build the cross-toolchain using the GPL source code provided by Buffalo Technology, a custom kernel .config, custom build scripts, and [| Dan Kegel's crosstool scripts]. You can download all of these from the [downloads area].
- You will need several gigabytes of free hard drive space to build the cross-toolchain. Also, you must be logged in as a user other than root. Start by unpacking the crosstool archive:
tar -pzxvf crosstool-0.38.tar.gz
- Place the appropriate custom kernel .config and custom build scripts in the crosstool directory. In this example, we will be building a gcc-3.3.5-glibc-2.3.2 toolchain for the powerpc-hdhlan LinkStation:[[<<]]%red%@@mv powerpc-hdhlan.config /usr/tmp/crosstool-0.38@@%%[[<<]]%red%@@mv powerpc-hdhlan.dat /usr/tmp/crosstool-0.38@@%%[[<<]]%red%@@mv powerpc-hdhlan.sh /usr/tmp/crosstool-0.38@@%%[[<<]]%red%@@mv gcc-3.3.5-glibc-2.3.2.dat /usr/tmp/crosstool-0.38@@%%
- Open powerpc-hdhlan.sh in a text editor and adjust the configuration variables if needed. For our example:[[<<]]%red%@@TARBALLS_DIR=/usr/tmp/downloads@@%% [=#=]@@where it will save source tarballs@@[[<<]]%red%@@RESULT_TOP=/usr/local/linkstation@@%% [=#=]@@where it will install the toolchain@@[[<<]]%red%@@GCC_LANGUAGES="c,c++"@@%% [=#=]@@which languages it will make compilers for@@
- Uncomment the toolchain you want to build. To build a gcc-3.3.5-glibc-2.3.2 toolchain:[[<<]]%red%@@eval `cat powerpc-hdhlan.dat gcc-3.3.5-glibc-2.3.2.dat` sh all.sh --notest@@%%
- Make sure you have the necessary permissions and ownership for the download and installation directories. Open gcc-3.3.5-glibc-2.3.2.dat in a text editor and adjust the configuration variables. For our example:[[<<]]%red%@@BINUTILS_DIR=binutils-2.15@@%% [=#=]@@which version of binutils to build@@[[<<]]%red%@@GCC_DIR=gcc-3.3.5@@%% [=#=]@@which version of gcc to build@@[[<<]]%red%@@GLIBC_DIR=glibc-2.3.2@@%% [=#=]@@which version of glibc to build@@[[<<]]%red%@@GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2@@%% [=#=]@@which version of glibc-linuxthreads to build (same as glibc version)@@[[<<]]%red%@@LINUX_DIR=linux-2.4.17_mvl21-sandpoint@@%% [=#=]@@which kernel source to use@@
- Extract the kernel source code from the GPL source code archive and place it in the downloads directory previously defined. Our example calls for linux-2.4.17_mvl21-sandpoint.tar.gz. Then unpack the kernel source:[[<<]]%red%@@cd /usr/tmp/downloads@@%%[[<<]]%red%@@tar -pzxvf linux-2.4.17_mvl21-sandpoint.tar.gz@@%%
- Download and apply any available patches. The 2.4.17_mvl21-sandpoint kernel needs 2 patches:[[<<]]%red%@@patch -p1 < netfilter.patch@@%%[[<<]]%red%@@patch -p1 < usbvideo.patch@@%%
- Remove the old kernel source archive and package the patched kernel source:[[<<]]%red%@@rm linux-2.4.17_mvl21-sandpoint.tar.gz@@%%[[<<]]%red%@@tar -pczvf linux-2.4.17_mvl21-sandpoint.tar.gz linux-2.4.17_mvl21-sandpoint@@%%
- See the following notes for Mac OS X and Cygwin before proceeding. To build the toolchain, all you must do is run the build script; crosstool will automate the entire process![[<<]]%red%@@cd /usr/tmp/crosstool-0.38@@%%[[<<]]%red%@@./powerpc-hdhlan.sh@@%%
- The build process may take several hours. You also may see some warnings during the build process - do not worry, this is fairly typical.
!!!Using a Cross-Toolchain
- Add the cross-toolchain to your $PATH (you can do this in .bashrc):[[<<]]%red%@@export PATH=$PATH:/usr/local/linkstation/gcc-3.3.5-glibc-2.3.2/powerpc-hdhlan-linux/bin@@%%
- Then declare the host and/or target type when running a program's ./configure script (this varies from program to program):[[<<]]%red%@@./configure --host=powerpc-hdhlan-linux --target=powerpc-hdhlan-linux@@%%
- Or specify the cross-toolchain's development programs when using make:[[<<]]%red%@@make AR=powerpc-hdhlan-linux-ar CC=powerpc-hdhlan-linux-gcc LD=powerpc-hdhlan-linux-ld NM=powerpc-hdhlan-linux-nm OBJDUMP=powerpc-hdhlan-linux-objdump@@%%
!!!Notes !!!!Mac OS X #osx
- Use a UFS volume on OS X. Do not use an HFS volume as there will be confusion and overwriting of files due to case insensitivity. Create an alias to your mounted UFS partition, remembering not to use spaces in the path:[[<<]]%red%@@ln -s /Volumes/MyUFSVolume/lsdev /opt@@%%
- OS X 10.4 only - Despite there being a patch for build issues of glibc on OS X, there are still issues with version checking on things like ld and as which will break the install. Download the glibc configure file patch from the downloads area and put it in crosstool-0.38/patches/glibc-2.3.5/. If you are a Linux user and thinking about doing this, please don't, the version checks are there for a reason!
- OS X 10.4 only - You will need the Apple developer tools. You can obtain them by registering at [| Apple Developer Connection] and downloading the latest XCode installer.
- OS X 10.4 only - If you are compiling a toolchain using glibc 2.3.2, select gcc 3.3 or it will fail the version check during configure. Use gcc 4.0 for newer compilers and glibc versions or else they might break. I had to compile a gcc-3.4.4-glibc 2.3.5 toolchain with gcc 4.0 (your experience may vary). To select the gcc version you wish to use:[[<<]]%red%@@sudo gcc_select 4.0@@%%
- OS X 10.4 only - Install wget, GNU sed and gawk. Make sure you install them in /usr/local and ensure that /usr/local/bin appears at the beginning of your PATH in /etc/profile. Then run:[[<<]]%red%@@source /etc/profile@@%%
- Due to Windows' file case insensitivity, toolchains built under Cygwin will encounter issues with certain files, e.g., ipt_tos.h and ipt_TOS.h. This will prevent Cygwin users from building the ip_tables kernel modules.
- Due to Windows' administrator design, Cygwin lacks a "root" user. You may encounter various file ownership issues.