* Started on working towards the fully Nixified build environment, i.e., one

where we don't use any tools from outside the Nix environment.  For this we
  need the basic POSIX utilities (e.g., GNU coreutils), a shell, GCC, and the
  binutils.

  Normal packages just need to include stdenv/stdenv.fix, which on Linux will
  use the Nixified environment.  However, for the tools in the build
  environment itself we have a bootstrapping problem.  Therefore, these depend
  on the external environment (and include stdenv-linux/stdenv-nativetools).

  The package `baseenv' provides some generic setup and GCC wrappers used by
  both fully Nixified and native environments.

svn path=/nixpkgs/trunk/; revision=305
This commit is contained in:
Eelco Dolstra 2003-08-18 15:32:13 +00:00
parent 53fa95e3ad
commit 40bc2cc9b6
11 changed files with 135 additions and 32 deletions

28
pkgs/baseenv/baseenv-build.sh Executable file
View file

@ -0,0 +1,28 @@
#! /bin/sh
export PATH=/bin:/usr/bin
mkdir $out || exit 1
mkdir $out/bin || exit 1
sed \
-e s^@OUT\@^$out^g \
< $setup > $out/setup || exit 1
gcc=/usr/bin/gcc
sed \
-e s^@GCC\@^$gcc^g \
< $gccwrapper > $out/bin/gcc || exit 1
chmod +x $out/bin/gcc || exit 1
ln -s gcc $out/bin/cc
gplusplus=/usr/bin/g++
sed \
-e s^@GCC\@^$gplusplus^g \
< $gccwrapper > $out/bin/g++ || exit 1
chmod +x $out/bin/g++ || exit 1
ln -s g++ $out/bin/c++

8
pkgs/baseenv/baseenv.fix Normal file
View file

@ -0,0 +1,8 @@
Package(
[ ("name", "stdenv-native")
, ("build", Relative("baseenv/baseenv-build.sh"))
, ("setup", Relative("baseenv/setup.sh"))
, ("gccwrapper", Relative("baseenv/gcc-wrapper.sh"))
]
)

View file

@ -21,12 +21,15 @@ IFS=" "
extra=($NIX_CFLAGS)
if test "$justcompile" != "1"; then
extra=(${extra[@]} $NIX_LDFLAGS)
if test "$NIX_STRIP_DEBUG" == "1"; then
extra=(${extra[@]} -Wl,-s)
fi
fi
if test "$NIX_DEBUG" == "1"; then
echo "extra gcc flags:"
echo "extra gcc flags:" >&2
for i in ${extra[@]}; do
echo " $i"
echo " $i" >&2
done
fi

39
pkgs/baseenv/setup.sh Normal file
View file

@ -0,0 +1,39 @@
# Add the directory containing the GCC wrappers to the PATH.
export PATH=@OUT@/bin
# Recursively add all envpkgs to the relevant environment variables.
addtoenv()
{
envpkgs="$envpkgs $1"
if test -d $1/bin; then
export PATH=$1/bin:$PATH
fi
if test -d $1/lib; then
export NIX_LDFLAGS="-L $1/lib -Wl,-rpath,$1/lib $NIX_LDFLAGS"
fi
if test -d $1/lib/pkgconfig; then
export PKG_CONFIG_PATH=$1/lib/pkgconfig:$PKG_CONFIG_PATH
fi
if test -f $1/envpkgs; then
for i in $(cat $1/envpkgs); do
addtoenv $i
done
fi
}
oldenvpkgs=$envpkgs
envpkgs=
for i in $oldenvpkgs; do
addtoenv $i
done
# Add the output as an rpath.
export NIX_LDFLAGS="-Wl,-rpath,$out/lib $NIX_LDFLAGS"
# Strip debug information by default.
export NIX_STRIP_DEBUG=1

View file

@ -0,0 +1,9 @@
#! /bin/sh
. $stdenv/setup || exit 1
tar xvfj $src || exit 1
cd coreutils-* || exit 1
./configure --prefix=$out || exit 1
make || exit 1
make install || exit 1

View file

@ -0,0 +1,13 @@
Package(
[ ("name", "coreutils-5.0")
, ("build", Relative("coreutils/coreutils-build.sh"))
, ("src", Call(IncludeFix("fetchurl/fetchurl.fix"),
[ ("url", "ftp://ftp.nluug.nl/pub/gnu/coreutils/coreutils-5.0.tar.bz2")
, ("md5", "94e5558ee2a65723d4840bfde2d323f0")
]))
, ("stdenv", IncludeFix("stdenv-linux/stdenv-nativetools.fix"))
]
)

View file

@ -0,0 +1,10 @@
. @BASEENV@/setup
export NIX_CFLAGS="-isystem @GLIBC@/include $NIX_CFLAGS"
export NIX_LDFLAGS="-L @GLIBC@/lib -Wl,-dynamic-linker,@GLIBC@/lib/ld-linux.so.2,-rpath,@GLIBC@/lib $NIX_LDFLAGS"
if test "@NATIVETOOLS@"; then
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin
else
export PATH=@COREUTILS@/bin:$PATH
fi

View file

@ -3,26 +3,10 @@
export PATH=/bin:/usr/bin
mkdir $out || exit 1
mkdir $out/bin || exit 1
echo "export PATH=$out/bin:/bin:/usr/bin" >> $out/setup || exit 1
echo "export NIX_CFLAGS=\"-isystem $glibc/include \$NIX_CFLAGS\"" >> $out/setup || exit 1
echo "export NIX_LDFLAGS=\"-L $glibc/lib -Wl,-dynamic-linker,$glibc/lib/ld-linux.so.2,-rpath,$glibc/lib \$NIX_LDFLAGS\"" >> $out/setup || exit 1
gcc=/usr/bin/gcc
sed \
-e s^@GCC\@^$gcc^g \
< $gccwrapper > $out/bin/gcc || exit 1
chmod +x $out/bin/gcc || exit 1
ln -s gcc $out/bin/cc
gplusplus=/usr/bin/g++
sed \
-e s^@GCC\@^$gplusplus^g \
< $gccwrapper > $out/bin/g++ || exit 1
chmod +x $out/bin/g++ || exit 1
ln -s g++ $out/bin/c++
-e s^@GLIBC\@^$glibc^g \
-e s^@BASEENV\@^$baseenv^g \
-e s^@NATIVETOOLS\@^$nativeTools^g \
-e s^@COREUTILS\@^$coreutils^g \
< $setup > $out/setup || exit 1

View file

@ -0,0 +1,16 @@
Function(["nativeTools"],
Package(
[ ("name", "stdenv-linux")
, ("build", Relative("stdenv-linux/stdenv-build.sh"))
, ("nativeTools", Var("nativeTools"))
, ("setup", Relative("stdenv-linux/setup.sh"))
, ("baseenv", IncludeFix("baseenv/baseenv.fix"))
, ("glibc", IncludeFix("glibc/glibc.fix"))
, ("coreutils", If(Var("nativeTools"), "", IncludeFix("coreutils/coreutils.fix")))
]
)
)

View file

@ -0,0 +1 @@
Call(IncludeFix("stdenv-linux/stdenv-generic.fix"), [("nativeTools", True)])

View file

@ -1,9 +1 @@
Package(
[ ("name", "stdenv-linux")
, ("build", Relative("stdenv-linux/stdenv-build.sh"))
, ("gccwrapper", Relative("stdenv-linux/gcc-wrapper.sh"))
, ("glibc", IncludeFix("glibc/glibc.fix"))
]
)
Call(IncludeFix("stdenv-linux/stdenv-generic.fix"), [("nativeTools", False)])