2004-03-08 17:02:46 +01:00
|
|
|
set -e
|
|
|
|
|
2004-03-09 18:16:02 +01:00
|
|
|
test -z $NIX_GCC && NIX_GCC=@gcc@
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
# Set up the initial path.
|
2004-03-08 17:02:46 +01:00
|
|
|
PATH=
|
2004-03-09 18:16:02 +01:00
|
|
|
for i in $NIX_GCC @initialPath@; do
|
2004-03-08 17:02:46 +01:00
|
|
|
PATH=$PATH${PATH:+:}$i/bin
|
2003-11-02 18:42:19 +01:00
|
|
|
done
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
if test "$NIX_DEBUG" = "1"; then
|
|
|
|
echo "Initial path: $PATH"
|
|
|
|
fi
|
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
|
|
|
|
# Execute the pre-hook.
|
2004-03-08 17:02:46 +01:00
|
|
|
param1=@param1@
|
|
|
|
param2=@param2@
|
|
|
|
param3=@param3@
|
|
|
|
param4=@param4@
|
|
|
|
param5=@param5@
|
2004-03-09 18:16:02 +01:00
|
|
|
if test -n "@preHook@"; then
|
|
|
|
. @preHook@
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check that the pre-hook initialised SHELL.
|
|
|
|
if test -z "$SHELL"; then echo "SHELL not set"; exit 1; fi
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
|
2004-03-09 11:27:42 +01:00
|
|
|
# Hack: run gcc's setup hook.
|
2004-03-11 18:26:14 +01:00
|
|
|
envHooks=()
|
2004-03-09 18:16:02 +01:00
|
|
|
if test -f $NIX_GCC/nix-support/setup-hook; then
|
|
|
|
. $NIX_GCC/nix-support/setup-hook
|
2004-03-08 19:29:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
# Recursively find all build inputs.
|
|
|
|
findInputs()
|
2003-11-02 18:42:19 +01:00
|
|
|
{
|
2004-03-08 17:02:46 +01:00
|
|
|
local pkg=$1
|
|
|
|
pkgs=(${pkgs[@]} $pkg)
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
if test -f $pkg/nix-support/setup-hook; then
|
|
|
|
. $pkg/nix-support/setup-hook
|
2003-11-02 18:42:19 +01:00
|
|
|
fi
|
2004-03-08 17:02:46 +01:00
|
|
|
|
|
|
|
if test -f $pkg/nix-support/propagated-build-inputs; then
|
|
|
|
for i in $(cat $pkg/nix-support/propagated-build-inputs); do
|
2004-03-11 18:26:14 +01:00
|
|
|
findInputs $i
|
2004-03-08 17:02:46 +01:00
|
|
|
done
|
2003-11-02 18:42:19 +01:00
|
|
|
fi
|
2004-03-08 17:02:46 +01:00
|
|
|
}
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
pkgs=()
|
|
|
|
for i in $buildinputs; do
|
|
|
|
findInputs $i
|
|
|
|
done
|
2003-11-02 18:42:19 +01:00
|
|
|
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
# Set the relevant environment variables to point to the build inputs
|
|
|
|
# found above.
|
|
|
|
addToEnv()
|
|
|
|
{
|
|
|
|
local pkg=$1
|
|
|
|
|
|
|
|
if test -d $1/bin; then
|
|
|
|
export _PATH=$_PATH:$1/bin
|
2003-11-02 18:42:19 +01:00
|
|
|
fi
|
|
|
|
|
2004-03-11 18:26:14 +01:00
|
|
|
echo "${envHooks[@]}"
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
for i in "${envHooks[@]}"; do
|
|
|
|
$i $pkg
|
|
|
|
done
|
|
|
|
}
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
for i in "${pkgs[@]}"; do
|
|
|
|
addToEnv $i
|
2003-11-02 18:42:19 +01:00
|
|
|
done
|
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
# Add the output as an rpath.
|
2003-11-02 23:25:26 +01:00
|
|
|
if test "$NIX_NO_SELF_RPATH" != "1"; then
|
|
|
|
export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
|
|
|
|
fi
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
# Strip debug information by default.
|
|
|
|
export NIX_STRIP_DEBUG=1
|
2004-03-08 17:02:46 +01:00
|
|
|
export NIX_CFLAGS_STRIP="-g0 -Wl,-s"
|
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-08 19:29:08 +01:00
|
|
|
# Where is the store? This is required for purity checking.
|
|
|
|
export NIX_STORE=$(dirname $out)/ # !!! hack
|
|
|
|
|
|
|
|
|
2004-03-09 11:27:42 +01:00
|
|
|
# Set the TZ (timezone) environment variable, otherwise commands like
|
|
|
|
# `date' will complain (e.g., `Tue Mar 9 10:01:47 Local time zone must
|
|
|
|
# be set--see zic manual page 2004').
|
|
|
|
export TZ=UTC
|
|
|
|
|
|
|
|
|
2003-11-02 18:42:19 +01:00
|
|
|
# Execute the post-hook.
|
2004-03-09 18:16:02 +01:00
|
|
|
if test -n "@postHook@"; then
|
|
|
|
. @postHook@
|
|
|
|
fi
|
2003-11-02 18:42:19 +01:00
|
|
|
|
2004-03-09 11:27:42 +01:00
|
|
|
PATH=$_PATH${_PATH:+:}$PATH
|
2004-03-08 17:02:46 +01:00
|
|
|
if test "$NIX_DEBUG" = "1"; then
|
|
|
|
echo "Final path: $PATH"
|
2003-11-02 18:42:19 +01:00
|
|
|
fi
|