nixpkgs/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
Lluís Batlle i Rossell 51f6aec764 Fixing the gcc-cross-wrapper; it failed after some changes related to breaking
dependencies with it. (I should never link ld.so with a NIX_LDFLAGS -rpath
forced)

I made vim, scummvm cross-build. I added prboom (that cross-builds).
Mplayer and elinks don't cross-build fine still, but are on the way.
The mplayer fails to build in a weird way; nix does not show either a gcc
error message or even the 'make' error message.

svn path=/nixpkgs/branches/stdenv-updates/; revision=23131
2010-08-11 20:14:25 +00:00

85 lines
2.3 KiB
Bash

NIX_CROSS_CFLAGS_COMPILE=""
NIX_CROSS_LDFLAGS=""
crossAddCVars () {
if test -d $1/include; then
export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include"
fi
if test -d $1/lib; then
export NIX_CROSS_LDFLAGS="$NIX_CROSS_LDFLAGS -L$1/lib -rpath-link $1/lib"
fi
}
crossEnvHooks=(${crossEnvHooks[@]} crossAddCVars)
crossStripDirs() {
local dirs="$1"
local stripFlags="$2"
local dirsNew=
for d in ${dirs}; do
if test -d "$prefix/$d"; then
dirsNew="${dirsNew} $prefix/$d "
fi
done
dirs=${dirsNew}
if test -n "${dirs}"; then
header "cross stripping (with flags $stripFlags) in $dirs"
# libc_nonshared.a should never be stripped, or builds will break.
find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
stopNest
fi
}
crossStrip () {
# In cross_renaming we may rename dontCrossStrip to dontStrip, and
# dontStrip to dontNativeStrip.
# TODO: strip _only_ ELF executables, and return || fail here...
if test -z "$dontCrossStrip"; then
stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin}
if test -n "$stripDebugList"; then
crossStripDirs "$stripDebugList" "${stripDebugFlags:--S}"
fi
stripAllList=${stripAllList:-}
if test -n "$stripAllList"; then
crossStripDirs "$stripAllList" "${stripAllFlags:--s}"
fi
fi
}
preDistPhases=(${preDistPhases[@]} crossStrip)
# Note: these come *after* $out in the PATH (see setup.sh).
if test -n "@gcc@"; then
PATH=$PATH:@gcc@/bin
fi
if test -n "@binutils@"; then
PATH=$PATH:@binutils@/bin
fi
if test -n "@libc@"; then
PATH=$PATH:@libc@/bin
crossAddCVars @libc@
fi
if test "$dontSetConfigureCross" != "1"; then
configureFlags="$configureFlags --build=$system --host=$crossConfig"
fi
# Disabling the tests when cross compiling, as usually the tests are meant for
# native compilations.
doCheck=""
# Add the output as an rpath.
if test "$NIX_NO_SELF_RPATH" != "1"; then
export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
fi
fi