2005-12-05 14:11:09 +00:00
|
|
|
source $stdenv/setup
|
2004-03-08 16:02:46 +00:00
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
|
2006-12-27 18:14:57 +00:00
|
|
|
ensureDir $out/bin
|
|
|
|
ensureDir $out/nix-support
|
2004-03-09 17:08:41 +00:00
|
|
|
|
2006-10-24 19:26:23 +01:00
|
|
|
|
|
|
|
if test -z "$nativeLibc"; then
|
|
|
|
dynamicLinker="$libc/lib/$dynamicLinker"
|
|
|
|
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
|
|
|
|
|
|
|
# The "-B$libc/lib/" flag is a quick hack to force gcc to link
|
2004-03-09 17:08:41 +00:00
|
|
|
# against the crt1.o from our own glibc, rather than the one in
|
2006-10-24 19:26:23 +01:00
|
|
|
# /usr/lib. (This is only an issue when using an `impure'
|
|
|
|
# compiler/linker, i.e., one that searches /usr/lib and so on.)
|
|
|
|
echo "-B$libc/lib/ -isystem $libc/include" > $out/nix-support/libc-cflags
|
|
|
|
|
|
|
|
echo "-L$libc/lib" > $out/nix-support/libc-ldflags
|
|
|
|
|
2004-11-22 16:36:27 +00:00
|
|
|
# The dynamic linker is passed in `ldflagsBefore' to allow
|
|
|
|
# explicit overrides of the dynamic linker by callers to gcc/ld
|
|
|
|
# (the *last* value counts, so ours should come first).
|
2006-10-24 19:26:23 +01:00
|
|
|
echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
|
2004-03-09 17:08:41 +00:00
|
|
|
fi
|
|
|
|
|
2004-03-11 17:26:14 +00:00
|
|
|
if test -n "$nativeTools"; then
|
2004-03-09 17:08:41 +00:00
|
|
|
gccPath="$nativePrefix/bin"
|
|
|
|
ldPath="$nativePrefix/bin"
|
2004-03-08 16:02:46 +00:00
|
|
|
else
|
2006-10-24 14:50:21 +01:00
|
|
|
if test -e "$gcc/lib64"; then
|
2006-10-24 19:26:23 +01:00
|
|
|
gccLDFlags="$gccLDFlags -L$gcc/lib64"
|
2006-10-24 14:50:21 +01:00
|
|
|
fi
|
2006-10-24 19:26:23 +01:00
|
|
|
gccLDFlags="$gccLDFlags -L$gcc/lib"
|
|
|
|
echo "$gccLDFlags" > $out/nix-support/gcc-ldflags
|
2006-10-25 17:32:13 +01:00
|
|
|
|
|
|
|
# GCC shows $gcc/lib in `gcc -print-search-dirs', but not
|
|
|
|
# $gcc/lib64 (even though it does actually search there...)..
|
|
|
|
# This confuses libtool. So add it to the compiler tool search
|
|
|
|
# path explicitly.
|
|
|
|
if test -e "$gcc/lib64"; then
|
|
|
|
gccCFlags="$gccCFlags -B$gcc/lib64"
|
|
|
|
fi
|
|
|
|
echo "$gccCFlags" > $out/nix-support/gcc-cflags
|
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
gccPath="$gcc/bin"
|
|
|
|
ldPath="$binutils/bin"
|
2004-03-08 16:02:46 +00:00
|
|
|
fi
|
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
|
2005-02-22 14:32:56 +00:00
|
|
|
doSubstitute() {
|
|
|
|
local src=$1
|
|
|
|
local dst=$2
|
2008-02-13 14:23:09 +00:00
|
|
|
# Can't use substitute() here, because replace may not have been
|
|
|
|
# built yet (in the bootstrap).
|
|
|
|
sed \
|
|
|
|
-e "s^@out@^$out^" \
|
|
|
|
-e "s^@shell@^$shell^" \
|
|
|
|
-e "s^@gcc@^$gcc^" \
|
|
|
|
-e "s^@gccProg@^$gccProg^" \
|
|
|
|
-e "s^@binutils@^$binutils^" \
|
|
|
|
-e "s^@libc@^$libc^" \
|
|
|
|
-e "s^@ld@^$ldPath/ld^" \
|
|
|
|
< "$src" > "$dst"
|
2005-02-22 14:32:56 +00:00
|
|
|
}
|
2004-03-08 16:02:46 +00:00
|
|
|
|
|
|
|
|
2005-02-22 14:32:56 +00:00
|
|
|
# Make wrapper scripts around gcc, g++, and g77. Also make symlinks
|
|
|
|
# cc, c++, and f77.
|
|
|
|
mkGccWrapper() {
|
2004-03-08 16:02:46 +00:00
|
|
|
local dst=$1
|
|
|
|
local src=$2
|
|
|
|
|
|
|
|
if ! test -f "$src"; then
|
|
|
|
echo "$src does not exist (skipping)"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2005-02-22 14:32:56 +00:00
|
|
|
gccProg="$src"
|
|
|
|
doSubstitute "$gccWrapper" "$dst"
|
|
|
|
chmod +x "$dst"
|
2004-03-08 16:02:46 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
mkGccWrapper $out/bin/gcc $gccPath/gcc
|
2004-03-08 16:02:46 +00:00
|
|
|
ln -s gcc $out/bin/cc
|
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
mkGccWrapper $out/bin/g++ $gccPath/g++
|
2004-03-08 16:02:46 +00:00
|
|
|
ln -s g++ $out/bin/c++
|
|
|
|
|
2004-03-09 17:08:41 +00:00
|
|
|
mkGccWrapper $out/bin/g77 $gccPath/g77
|
2004-03-08 16:02:46 +00:00
|
|
|
ln -s g77 $out/bin/f77
|
|
|
|
|
|
|
|
|
2006-10-26 21:25:31 +01:00
|
|
|
# Create a symlink to as (the assembler). This is useful when a
|
|
|
|
# gcc-wrapper is installed in a user environment, as it ensures that
|
|
|
|
# the right assembler is called.
|
2006-10-27 13:07:03 +01:00
|
|
|
ln -s $ldPath/as $out/bin/as
|
2006-10-26 21:25:31 +01:00
|
|
|
|
|
|
|
|
2005-02-22 14:32:56 +00:00
|
|
|
# Make a wrapper around the linker.
|
|
|
|
doSubstitute "$ldWrapper" "$out/bin/ld"
|
|
|
|
chmod +x "$out/bin/ld"
|
2004-03-08 16:02:46 +00:00
|
|
|
|
|
|
|
|
2005-02-22 14:32:56 +00:00
|
|
|
# Emit a setup hook. Also store the path to the original GCC and
|
|
|
|
# Glibc.
|
2004-03-12 11:12:18 +00:00
|
|
|
test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc
|
2006-10-24 19:26:23 +01:00
|
|
|
test -n "$libc" && echo $libc > $out/nix-support/orig-libc
|
2004-03-09 17:08:41 +00:00
|
|
|
|
2006-10-24 19:26:23 +01:00
|
|
|
doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
|
2005-02-22 14:32:56 +00:00
|
|
|
|
|
|
|
doSubstitute "$setupHook" "$out/nix-support/setup-hook"
|
2004-03-12 11:12:18 +00:00
|
|
|
|
2006-10-24 19:26:23 +01:00
|
|
|
cp -p $utils $out/nix-support/utils.sh
|