3. Temptools Phase - Next Generation Build Method

[Warning] Warning -- Work In Progress!!

This is the Next Generation build method which is now the default and preferred option. The original method has been deprecated. The new method of bootstrapping a Linux system works well for all supported architectures, supports Package Management and has been ICA verified. For now, only use recent toolchain combinations with this method i.e. Glibc-2.6.x, GCC-4.2.x, Binutils-2.18 and newer. Please note - the Rationales are not yet accurate as all the text was just copied from the original method. This will be fixed progressively in due course.

3.1. Bash-3.2 Pass 1

[Important] Important

This first pass of Bash is the only package we install "by hand". Everything else after this point is expected to be automated via a build script. However, you can still drive the build manually by typing in all the commands on the interactive shell command line if you prefer. Note: Do not skip Bash Pass 1. It used to be optional but is now a requirement of the build method due to our use of CONFIG_SHELL (see below).

patch -p1 -i ${TT_PFX}/src/patches/bash-3.2-official-039-combined-1.patch &&
sh -c "unset CONFIG_SHELL; ./configure" &&
make &&
install -dv ${TT_PFX}/bin &&
cp -v bash ${TT_PFX}/bin/bash-pass1 &&
ln -sv bash-pass1 ${TT_PFX}/bin/bash &&
ln -sv bash ${TT_PFX}/bin/sh

Rationale Notes

  • Installing Bash as the very first package allows us to specify the "configure shell" to be used by all Autoconf-produced configure scripts during the Temptools phase. This is achieved via the CONFIG_SHELL environment variable mentioned earlier. It serves to enhance the robustness of the build method by reducing reliance on the host's /bin/sh thus avoiding potential breakage when bootstrapping from older distros.

  • Another reason for installing Bash first up is that we can write our build script using all the features of modern Bash without having to worry about which shell is installed as /bin/sh on the host. Simply launch your build script like this: `bash-pass1 myscript.sh'.

    [Tip] Tip

    There is additional benefit to using this technique in that it allows greater flexibility for handling the transition between the Temptools and Chroot phases. For example, you can set the interpreter path in your build script to `#!/temptools/bin/bash' which allows easy re-execution of the same script upon entering the chroot environment without having to fuss over having a `$SYSROOT/bin/sh' symlink already set up. Please refer to the author's own gsbuild scripts for a sample implementation. Naturally, this point is moot if you script in pure Bourne or handle the Temptools/Chroot phases transition using a different method.

  • For our purposes of bootstrapping a new Linux system within the Reference Build context, Bash should build fine on any sane distro made within the last 5 years.

  • The "unset CONFIG_SHELL" in the configure invocation is needed for configure to succeed because the shell pointed to by CONFIG_SHELL doesn't exist yet i.e. we are installing it here.

  • Note: some older hosts have `libtermcap' installed and Bash will prefer it over Ncurses if found by configure unless `--with-curses' is given. Bash also comes with its own Termcap. Rather than tinker with configure switches, it's actually more robust to just let configure work it out for itself. This Pass 1 of Bash is simply for running scripts during the Temptools phase so it shouldn't really matter which Termcap is used.

  • Double ampersands are used here because we're still operating in an interactive shell session at this point. We recommend that you employ a proper error trapping strategy in your build script (eg: set -e). Therefore, double ampersands are not provided in the build commands from this point onwards.

3.2. Make-3.81 Pass 1

./configure
make
cp -v make ${TT_PFX}/bin
ln -sv make ${TT_PFX}/bin/gmake

Rationale Notes

  • for bootstrapping purposes, Make should build fine on any sane distro made from 1999 onwards.

  • the Glibc build needs a version of `make' 3.79 or newer which older distros don't have. We remove all doubts by installing the current version. Why install it now rather than just prior to the Glibc build? Well, it makes sense to integrate it from the outset so that we can start using it immediately.

  • the `gmake' symlink is needed for robustness. `gmake' already exists on some hosts which will prevent Glibc's configure script from finding the `make' we install here.

3.3. Sed-4.1.5 Pass 1

./configure \
	ac_cv_header_stdbool_h=yes
make
cp -v sed/sed ${TT_PFX}/bin

Rationale Notes

  • for bootstrapping purposes, Sed should build fine on any sane distro made from 1999 onwards.

  • The ac_cv_header_stdbool_h=yes tweak is needed when building on older hosts. Please read this bug report for details. Note that on newer hosts the variable is set automatically by configure thus making the tweak unnecessary, but it's perfectly fine to leave it there in all circumstances.

  • Why do we install a Pass 1 of Sed here? There have been reported problems where the Glibc build chokes with older Sed versions. The author hasn't personally seen any such problem but feels it's safer to just install a current Sed from the outset. An added bonus is that we can rely on using `sed -i' during the entire Temptools phase thus simplifying scripting.

3.4. Binutils Pass 1 a.k.a. Cross Binutils (2.16.1 through 2.18)

# Red Hat 6.2 Hack
#[[ $DIY_TARGET == x86_64* ]] &&
#	sed -i.bak 's/bad_64bit_gcc=yes/bad_64bit_gcc=no/' bfd/configure

mkdir ../binutils-build
cd ../binutils-build

../binutils-$BINUTILS_VER/configure \
	--target=$DIY_TARGET \
	--with-lib-path=$TT_PFX/lib$DIR_64 \
	--disable-werror
echo "MAKEINFO = :" >> Makefile

make

[[ $DIY_TARGET == x86_64* && $BIARCH = NO ]] &&
	{ install -dv $TT_PFX/lib; ln -sv lib $TT_PFX/lib64; }

make install

Rationale Notes

  • The `echo "MAKEINFO = :" >> Makefile' tweak is used to remove dependence on `makeinfo' and therefore eliminate all associated problems. Please read the mailing list thread starting with this post for details.

  • We create a lib64 -> lib symlink in the x86_64 case because we are not building a multi-arch toolchain. Even in single-arch mode 64-bit architectures tend to hardwire references to "lib64" in many places throughout the toolchain. It's possible to force everything to "lib" but we'd rather keep all the build commands compatible with other architectures. The symlink keeps things sane and everything Just Works™.

  • After the first Binutils are installed, -B/usr/bin/ is temporarily added to the CC definition in order to force the host GCC to use the host Binutils. Without this override, the host GCC will find the newly installed Binutils in the PATH thus causing a toolchain mismatch and potential breakage. This breakage is likely to strike when using a bleeding edge distro as a host (eg: Fedora) and you're building a toolchain comprised of older versions of toolchain components than those on the host. The "if..echo..grep" statement is required on those hosts with GCC-2.95.x or earlier installed. More background on all of this can be found in the mailing list thread starting with this post (continued here).

  • Note: Unlike LFS, we don't statically link the Pass 1 of Binutils because it's simply unnecessary, and in actual fact is a potential source of failure. We therefore link dynamically for robustness reasons. If you still think static linking is a good idea then at least take note of the Glibc maintainer's views on the subject.

  • Because we're linking dynamically, there's no need to specify `make configure-host' after the initial configure. However, when building on SMP the top level Makefile will run the sub-configure scripts for Libiberty and Binutils simultaneously. This is great for speed and efficiency, but unfortunate for the build log which ends up all jumbled. If you'd like the build log to remain neat and tidy (eg: for diffing purposes), run the sub-configure scripts in serial by executing make configure-host -j1 after the initial configure.

3.5. GCC Pass 1 a.k.a. Cross GCC (3.4.6 through 4.3.3)

[[ $GCC_VER == 3.4* && $DIY_TARGET == i?86* ]] &&
	patch -p1 -i $TT_PFX/src/patches/gcc-3.4-branch-x86-inhibit_libc-1.patch

if [[ $GCC_VER > 4.2.9 ]]; then
	bunzip2 -dc $TT_PFX/src/tarballs/mpfr-2.4.1.tar.bz2 | tar xf -
	bunzip2 -dc $TT_PFX/src/tarballs/gmp-4.2.4.tar.bz2 | tar xf -
	mv -v mpfr* mpfr
	mv -v gmp* gmp
fi

mkdir ../gcc-build
cd ../gcc-build

[[ $DIY_TARGET == x86_64* && $BIARCH = NO ]] &&
	GCC_EXTRA_CONFIG="--disable-multilib"

../gcc-$GCC_VER/configure \
	--target=$DIY_TARGET \
	--enable-languages=c \
	--disable-shared \
	--disable-threads \
	--disable-libmudflap \
	--disable-libssp \
	--disable-libgomp \
	--disable-decimal-float \
	$GCC_EXTRA_CONFIG

make
make install -j1

ln -sv libgcc.a `$DIY_TARGET-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
if [ "$BIARCH" = YES ]; then
	ln -sv libgcc.a `$DIY_TARGET-gcc -m32 -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
fi

Rationale Notes

  • GCC-4.3 and above requires the MPFR and GMP libraries. Here we are taking advantage of the largely undocumented "combined tree" feature of the GNU toolchain. Integrating MPFR and GMP into the GCC build itself greatly simplifies matters and mostly removes all host issues and other complications of building these libs separately. More information in this mailing list post.

  • The switches `--disable-libmudflap', `--disable-libssp', `--disable-libgomp' and `--disable-decimal-float' first appeared in GCC-4.0, GCC-4.1, GCC-4.2 and GCC-4.3 respectively. They are used here to streamline our initial "bootstrap" GCC. The switches are all compatible within supported GCC versions ie: earlier versions simply ignore the later switches.

  • Note: Starting with GCC-4.2, the top-level bootstrap mechanism became the default. This means a plain "make" will now default to performing a 3 stage bootstrap unless `--disable-bootstrap' is given. The pre-GCC-4.2 method of "make bootstrap" behaves identically. Therefore, we can maintain compatibility with earlier versions by continuing to use "make bootstrap".

  • The libgcc_eh.a symlink is needed to satisfy the upcoming Glibc build. Please read this mailing list post for some rationale discussion.

3.6. Linux-Kernel-Headers-2.6.27

[Warning] Warning

The 2.6.18 kernel introduced the next generation method of obtaining sanitized kernel headers. For some background on the issue please see this mailing list post. When using the new technique you MUST SKIP the Linux-Libc-Headers step which follows next. In other words, choose one or the other, not both. Only use the old method when building a toolchain comprised of older components (see table of toolchain combinations listed earlier).

make mrproper
make headers_install INSTALL_HDR_PATH=temp
cp -rv temp/include $TT_PFX

Rationale Notes

  • Note: There is no need to specify `ARCH=xxx' above because as of kernel 2.6.24, the x86 headers produced for 32-bit and 64-bit arches are identical. More information in this mailing list post.

3.7. Linux-Libc-Headers-2.6.12.0 (Older toolchains only)

patch -p1 -i ${TT_PFX}/src/patches/linux-libc-headers-2.6.12.0-syscalls-3.patch
cp -Rv include/asm-${DIY_ARCH} ${TT_PFX}/include/asm
cp -Rv include/linux ${TT_PFX}/include

3.8. Glibc 32-bit - *ONLY* for Bi-arch x86_64 (2.3.6 through 2.8)

[[ $GCC_VER > 4.2.9 && $GLIBC_VER == 2.7* ]] &&
	patch -p1 -i $TT_PFX/src/patches/glibc-2.7-gcc43-1.patch

mkdir ../glibc-build
cd ../glibc-build

CC="$DIY_TARGET-gcc -m32" \
CFLAGS="-O2 -march=i486 -pipe" \
../glibc-$GLIBC_VER/configure \
	--host=i686-diy-linux-gnu \
	--build=$(../glibc-$GLIBC_VER/scripts/config.guess) \
	--disable-profile \
	--enable-add-ons \
	--with-headers=$TT_PFX/include \
	libc_cv_initfini_array=yes \
	libc_cv_forced_unwind=yes \
	libc_cv_c_cleanup=yes

echo "AUTOCONF=no
MAKEINFO=:" > configparms

make
make install -j1

3.9. Glibc (2.3.6 through 2.8)

[Caution] Proceed with Caution!

Glibc is possibly the most critical piece of software you will compile in a base Reference Build. There is a high probability of something going wrong. Be sure to heed the advice contained in Section B, “Glibc General Advice” before taking on this monster. Note: the Glibc compiled here in the Temptools phase is merely a "throw away bootstrap" Glibc, but please do read the aforementioned advice anyway.

[[ $GCC_VER > 4.2.9 && $GLIBC_VER == 2.7* ]] &&
	patch -p1 -i $TT_PFX/src/patches/glibc-2.7-gcc43-1.patch

mkdir ../glibc-build
cd ../glibc-build

[[ $DIY_TARGET == i?86* ]] && MARCH=-march=i486

CFLAGS="-O2 $MARCH -pipe" \
../glibc-$GLIBC_VER/configure \
	--host=$DIY_TARGET \
	--build=$(../glibc-$GLIBC_VER/scripts/config.guess) \
	--disable-profile \
	--enable-add-ons \
	--with-headers=$TT_PFX/include \
	libc_cv_initfini_array=yes \
	libc_cv_forced_unwind=yes \
	libc_cv_c_cleanup=yes

echo "AUTOCONF=no
MAKEINFO=:" > configparms

[ "$BIARCH" = YES ] &&
echo "slibdir=$TT_PFX/lib64
libdir=$TT_PFX/lib64" >> configparms

make
make install -j1

Rationale Notes

  • We need to fiddle with `-march=' in CFLAGS because as of Glibc-2.6, i486 is the minimum supported configuration on x86. More information here.

  • `--without-selinux' is a workaround needed on Fedora Core 3 hosts (those with the "libselinux-devel" package installed) to prevent build failure caused by a subtle Makefile bug. Upstream have been notified of the issue.

  • `AUTOCONF=no' is used here for robustness. It simply prevents unnecessary Autoconf invocations when the Makefiles detect a `configure' file older than its respective `configure.in'. This is usually the case when working with CVS snapshots, but it also applies to release tarballs prior to glibc-2.3.5 when the issue was finally addressed. These unnecessary Autoconf invocations have been known to cause build failures on Debian hosts. An alternative approach is to run `find . -name configure | xargs touch' in the src dir before running `configure'. Note: `--without-cvs' does not address the issue.

  • `MAKEINFO=:' is used to prevent installation failures when the host has an older `makeinfo'. Problems were first noticed with Glibc-2.7.

3.10. Adjust Toolchain

case $DIY_TARGET in
  i?86*)	DL=/lib/ld-linux.so.2 ;;
  powerpc-*)	DL=/lib/ld.so.1 ;;
  x86_64*)	DL=/lib64/ld-linux-x86-64.so.2 ;;
esac

$DIY_TARGET-gcc -dumpspecs | sed \
	-e "s,$DL,$TT_PFX&," \
	-e "/^\*cpp:$/{n;s,$, -isystem $TT_PFX/include,}" \
	> `dirname $($DIY_TARGET-gcc -print-libgcc-file-name)`/specs

echo 'main(){}' | $DIY_TARGET-gcc -B $TT_PFX/lib$DIR_64/ -x c - -lrt
readelf -l a.out | grep ": $TT_PFX"
rm -fv a.out

Rationale Notes

  • For x86_64 we need to empty the "multilib" spec to prevent GCC from searching for libs on the host. The sed simply modifies the spec to mirror how it would appear in a single-arch scenario. More information in this mailing list post.

3.11. Binutils Pass 2 (2.16.1 through 2.18)

[[ $DIY_TARGET == x86_64* && $(uname -m) == i?86 ]] &&
	{ echo 'build a 64-bit kernel and reboot into it!'; exit 1; }

mkdir ../binutils-build
cd ../binutils-build

CC="$DIY_TARGET-gcc -B $TT_PFX/lib$DIR_64/" \
AR=$DIY_TARGET-ar RANLIB=$DIY_TARGET-ranlib \
../binutils-$BINUTILS_VER/configure \
	--with-lib-path=$TT_PFX/lib$DIR_64
echo "MAKEINFO = :" >> Makefile

make
make install

make -C ld clean
make -C ld LIB_PATH=/lib$DIR_64:/usr/lib$DIR_64
cp -v ld/ld-new $TT_PFX/bin

3.12. GCC Pass 2 (3.4.6 through 4.3.3)

case $DIY_TARGET in
  i?86*)	DL=/lib/ld-linux.so.2;		DL_HEADER=i386/linux.h ;;
  powerpc-*)	DL=/lib/ld.so.1;		DL_HEADER=rs6000/sysv4.h ;;
  x86_64*)	DL=/lib64/ld-linux-x86-64.so.2; DL_HEADER=i386/linux64.h
		if [ "$BIARCH" = NO ]; then
			GCC_EXTRA_CONFIG=--disable-multilib
		else
			DL32=/lib/ld-linux.so.2
		fi ;;
esac

if [[ $GCC_VER > 4.2.9 ]]; then
	bunzip2 -dc $TT_PFX/src/tarballs/mpfr-2.4.1.tar.bz2 | tar xf -
	bunzip2 -dc $TT_PFX/src/tarballs/gmp-4.2.4.tar.bz2 | tar xf -
	mv -v mpfr* mpfr
	mv -v gmp* gmp
	patch -p1 -i $TT_PFX/src/patches/gcc-4.3-branch-startfiles-1.patch
fi

if [[ $BINUTILS_VER > 2.17.9 && $GCC_VER > 4.1.9 && $GLIBC_VER > 2.5.9 ]]; then
	patch -p1 -i $TT_PFX/src/patches/gcc-4.2-branch-hash-style-gnu-2.patch
	sed -i.bak '/^#define LINK_SPEC/s/i386} \\/i386} --hash-style=gnu \\/' \
		gcc/config/i386/linux64.h
fi

sed -i.bak "s@$DL@$TT_PFX&@" gcc/config/$DL_HEADER
[ "$BIARCH" = YES ] &&
	sed -i.bak2 "s@$DL32@$TT_PFX&@" gcc/config/$DL_HEADER

echo '
/* Remove /usr/include from include search path.  */
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR 0

/* Remove /lib and /usr/lib from startfiles search path.  */
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""' >> gcc/config/$DL_HEADER

sed -i.bak \
	's,\./fixinc\.sh,-c true,' gcc/Makefile.in

[[ $GCC_VER == 4.* && $DIY_TARGET == i?86* ]] &&
	sed -i.bak2 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in

mkdir ../gcc-build
cd ../gcc-build

CC="$DIY_TARGET-gcc -B $TT_PFX/lib$DIR_64/" \
AR=$DIY_TARGET-ar RANLIB=$DIY_TARGET-ranlib \
../gcc-$GCC_VER/configure \
	--with-local-prefix=$TT_PFX \
	--enable-shared \
	--disable-bootstrap \
	--enable-languages=c,c++ \
	--enable-clocale=gnu \
	--enable-threads=posix \
	--enable-__cxa_atexit \
	--disable-libstdcxx-pch \
	$GCC_EXTRA_CONFIG

make
make install -j1
ln -sv gcc $TT_PFX/bin/cc

# Sanity check - ensure host not being searched for libs
echo 'main(){}' | cc -x c -lbogus -v -Wl,--verbose - &> foo || :
if grep "^attempt to open /usr" foo; then
	echo Oops; exit 1
fi

Rationale Notes

  • The tweak to STANDARD_STARTFILE_PREFIX_{1,2} ensures there is zero chance of any libs and startfiles being found on the host. More information in this mailing list post. Some older information related to the same issue can be found here.

  • As mentioned earlier, we need to pass `--disable-bootstrap' here to prevent GCC-4.2 and above from performing a 3 stage bootstrap. The switch is ignored by earlier versions and is therefore compatible.

  • The notes about `make configure-host' from Binutils Pass 1 and GCC Pass 1 also apply here. However, it gets a little more complicated because we're also building Libstdc++. To achieve the same outcome (ie: run sub-configures in serial for neat build logs under SMP), the sequence needs to be like this:

    make configure-host -j1
    make all-host
    make configure-target -j1
    make all-target
  • When building with GCC-4.x we use a sed to add `-fomit-frame-pointer' to the GCC Makefile to address a correctness issue. Please read this mailing list post for some rationale discussion.

3.13. Gawk-3.1.6

./configure \
	ac_cv_func_working_mktime=yes
make
cp -v gawk ${TT_PFX}/bin
ln -sv gawk ${TT_PFX}/bin/awk

Rationale Notes

3.14. Coreutils-6.12

patch -p1 -i $TT_PFX/src/patches/coreutils-6.12-utimensat-1.patch
./configure \
	--enable-install-program=hostname,su
make
make install
cp -v src/su ${TT_PFX}/bin

Rationale Notes

  • For some background on the `--enable-install-program=hostname,su' configure switch, please read this mailing list post.

  • Because we are operating as a non-privileged user, Coreutils will suppress installation of the `su' program. This is signified by a message shown during `make install': "WARNING: insufficient access; not installing su NOTE: to install su, run 'make install-root' as root". The reason for this is `su' needs to be installed setuid root in order to be fully functional. We manually install it here because even without the setuid bit, we can still use it when inside the Chroot environment to (a) run various testsuites as a non-privileged user and (b) employ Package Management techniques that require building sources as a non-privileged user.

[Important] Important

From this point onwards if you need to become root you must call the host's `su' explicitly by running /bin/su. Just running su will call the first `su' in the $PATH which is the one we just installed (it will fail because of the missing setuid bit). This is especially important when we go to enter the Chroot environment at the beginning of the next phase.

3.15. Bzip2-1.0.5

make PREFIX=${TT_PFX} LDFLAGS=${LDFLAGS} install

3.16. Gzip-1.3.12

[[ $GLIBC_VER > 2.5.9 ]] &&
	sed -i.bak 's/futimens/gl_&/' gzip.c lib/utimens.{c,h}

./configure
make
cp -v gunzip gzip ${TT_PFX}/bin

3.17. Diffutils-2.8.1

./configure
make
cp -v src/{cmp,diff} ${TT_PFX}/bin

3.18. Findutils-4.4.0

./configure
make
cp -v find/find xargs/xargs ${TT_PFX}/bin

3.19. Make-3.81 Pass 2

./configure
make
cp -v make ${TT_PFX}/bin

3.20. Grep-2.5.4

./configure \
	--without-included-regex \
	--disable-perl-regexp
make
cp -v src/{,e,f}grep ${TT_PFX}/bin

Rationale Notes

  • The `MISSING=true' tweak is needed to work around a bug in the current release whereby the build will fail if `makeinfo' is unavailable. See here and here for examples.

3.21. Sed-4.1.5 Pass 2

./configure
make
cp -v sed/sed ${TT_PFX}/bin

3.22. Gettext-0.17

cd gettext-tools
./configure \
	--disable-shared
make -C gnulib-lib
make -C src msgfmt
cp -v src/msgfmt ${TT_PFX}/bin

3.23. Ncurses-5.7

./configure \
	--without-debug \
	--without-ada \
	--enable-overwrite
make
make install

3.24. Patch-2.5.4

./configure
make
cp -v patch ${TT_PFX}/bin

3.25. Tar-1.22

./configure
make
cp -v src/tar ${TT_PFX}/bin

3.26. Texinfo-4.13a

./configure
make
make install

3.27. Bash-3.2 Pass 2

patch -p1 -i ${TT_PFX}/src/patches/bash-3.2-official-039-combined-1.patch
./configure \
	--without-bash-malloc \
	ac_cv_func_working_mktime=yes
make
install -v bash ${TT_PFX}/bin

Rationale Notes

3.28. M4-1.4.13

[Tip] Tip

It's worth noting the next 3 packages (M4, Bison and Flex) are not strictly necessary in the Temptools phase when using an official FSF Binutils release. However, they are mandatory if using a release from HJL. The reason is that FSF releases are made with a "make dist" style procedure whereby the generated files (from Bison and Flex) are already included in the tarball thus removing the requirement for Bison and Flex at Binutils build time (in the Chroot phase). Our recommendation is to always build M4, Bison and Flex here to ensure the build recipe remains compatible with both FSF and HJL Binutils releases. There is another issue: if you skip M4, Bison and Flex here it's likely you'll run into ICA trouble which will require an additional hack when building Bison in the Chroot phase.

./configure
make V=1
cp -v src/m4 ${TT_PFX}/bin

3.29. Bison-2.4.1

./configure
make
make install

3.30. Flex-2.5.35

./configure
make
cp -v flex ${TT_PFX}/bin

3.31. E2fsprogs-1.41.4

mkdir build
cd build
../configure
make libs -j1
make install-libs

Rationale Notes

  • We install the E2fsprogs libraries here to satisfy the build of `mount' from Util-Linux-ng in the next step. If you choose not to build `mount' then these libraries are naturally not required.

3.32. Util-Linux-ng-2.14.2

./configure
make -C mount
make -C getopt
cp -v mount/{,u}mount getopt/getopt ${TT_PFX}/bin

Rationale Notes

  • We install `mount' here so we can mount the virtual file systems from within the chroot environment. Please read this mailing list post for some rationale discussion.

  • We install `getopt' here because it's needed by the optional Fakeroot package (see below). If you're not installing Fakeroot then you don't need to install `getopt' here.

3.33. Perl-5.10.0

chmod -v u+w hints/linux.sh

cat >> hints/linux.sh << "EOF"
libc=${prefix}/lib/`ls -l ${prefix}/lib/libc.so.6 | awk '{print $NF}'`
locincpth=""
loclibpth=""
usrinc="${prefix}/include"
glibpth="${prefix}/lib"
EOF

./configure.gnu \
	--prefix=${TT_PFX} \
	-Dstatic_ext='IO Fcntl Data/Dumper POSIX'

make perl utilities ext/Errno/pm_to_blib
cp -v perl pod/pod2man ${TT_PFX}/bin
mkdir -pv ${TT_PFX}/lib/perl5/5.10.0
cp -Rv lib/* ${TT_PFX}/lib/perl5/5.10.0

Rationale Notes

  • For some background on the commands containing "static_ext" and "ext/Errno/pm_to_blib" please read the mailing list thread starting with this post.

3.34. Tcl-8.4.19

cd unix
./configure
make
make install
make install-private-headers
ln -sv tclsh8.4 ${TT_PFX}/bin/tclsh

3.35. Expect-5.43.0

patch -p1 -i ${TT_PFX}/src/patches/expect-5.43-spawn-1.patch
sed -i.bak '/echo.*STTY_BIN/i STTY_BIN=stty' configure
./configure \
	--with-tcl=${TT_PFX}/lib \
	--with-tclinclude=${TT_PFX}/include \
	--with-x=no
make
make SCRIPTS="" install -j1

Rationale Notes

  • The sed to `configure' forces Expect to call a plain `stty' instead of `/bin/stty' or even worse, `/usr/local/bin/stty'. In this way the first `stty' in the PATH will always be used. It also avoids the need to create a `/bin/stty' symlink in Section 4.5, “Create Symlinks”.

3.36. DejaGnu-1.4.4

./configure
make install -j1

3.37. Fakeroot-1.11 (Optional)

./configure
make
sed -i.bak \
	's,^PATHS=,&/lib$DIR_64:/usr/lib$DIR_64:,' \
	scripts/fakeroot
make install

Rationale Notes

  • As mentioned in the Introduction, if you're employing Package Management by building and creating archives as a non-privileged user, files in the resultant archives can sometimes end up with wrong file ownerships and permissions. Fakeroot can provide a solution to this problem. It acts as a wrapper around various library functions and a typical invocation is like this: fakeroot commands-you-want-run-under-a-fake-root-environment. Generally, you only want to be performing the commands associated with installation under Fakeroot. Running commands associated with configuring and building usually work, but the Fakeroot documentation recommends against it. Never run the testsuites for Glibc, Coreutils and Perl under Fakeroot because you will experience failures. The Bash testsuite can also be problematic. Consider this package optional if you're a) not employing Package Management b) building as root or c) using a Package Manager that doesn't require assistance from Fakeroot.

  • The sed is needed to force Fakeroot to load the correct Glibc when inside the Chroot environment. Without it, Fakeroot will load the Temptools Glibc.

  • Another package with similar functionality but having a slightly different feature set is Pretendroot. Details on this package can be found here. Note: we haven't tested Pretendroot in the context of a Reference Build so your mileage may vary.

3.38. Zlib-1.2.3 (Optional)

[Note] Note -- Optional Package Management with Pacman

Only install the next 3 packages (Zlib, Libtar and Pacman) if you intend implementing Pacman based package management. Pacman is a simple tar.gz-based package manager for Linux originally written for the Arch Linux distro. Please refer to the gsbuild scripts for a sample Pacman implementation. It's worth noting the author personally uses Pacman which means it receives regular testing within the Reference Build context.

./configure --prefix=${TT_PFX}
make
make install

3.39. Libtar-1.2.11 (Optional)

patch -p1 -i ${TT_PFX}/src/patches/libtar-1.2.11-2.patch
./configure
make
make install

3.40. Pacman-2.9.8 (Optional)

patch -p1 -i ${TT_PFX}/src/patches/pacman-2.9.8-custom-mods-2.patch
patch -p1 -i ${TT_PFX}/src/patches/pacman-2.9.6-temptools-1.patch
patch -p1 -i ${TT_PFX}/src/patches/pacman-2.9.8-sep_install-1.patch
./configure
make
cp -v pacman scripts/makepkg ${TT_PFX}/bin
cp -v etc/{makepkg,pacman}.conf ${TT_PFX}/etc

3.41. Ogdlutils-20041124 (Optional)

[Note] Note -- Optional Package Management with BPM

Only install the next 3 packages (Ogdlutils, Cpio and BPM) if you intend implementing BPM based package management. BPM is an extremely compact package manager with the simplest spec file format imaginable. It comes from the Bent Linux distro. Please refer to the gsbuild scripts for a sample BPM implementation. BPM only receives occasional testing within the Reference Build context and is included here mainly as a proof of concept. (Note: the gsbuild BPM implementation currently gets some file permissions wrong - FIXME).

make -C c libogdl gpath -j1
cp -v c/gpath ${TT_PFX}/bin

3.42. Cpio-2.9 (Optional)

./configure
make
cp -v src/cpio ${TT_PFX}/bin

3.43. BPM-1.7 (Optional)

cp -v bpm{build,install,pkgfix} ${TT_PFX}/bin

3.44. Remove Cruft

rm -rfv ${TT_PFX}/{,share/}{info,man}