2010-03-09 16:48:25 +01:00
|
|
|
{stdenv, fetchurl, linuxHeaders, cross ? null, gccCross ? null}:
|
2009-11-08 01:32:12 +01:00
|
|
|
|
|
|
|
assert stdenv.isLinux;
|
2010-03-09 16:48:25 +01:00
|
|
|
assert cross != null -> gccCross != null;
|
2009-11-08 01:32:12 +01:00
|
|
|
|
2009-12-04 14:35:58 +01:00
|
|
|
let
|
2010-03-09 16:48:25 +01:00
|
|
|
enableArmEABI = (cross == null && stdenv.platform.kernelArch == "arm")
|
|
|
|
|| (cross != null && cross.arch == "arm");
|
2009-12-04 14:35:58 +01:00
|
|
|
|
|
|
|
configArmEABI = if enableArmEABI then
|
|
|
|
''-e 's/.*CONFIG_ARM_OABI.*//' \
|
|
|
|
-e 's/.*CONFIG_ARM_EABI.*/CONFIG_ARM_EABI=y/' '' else "";
|
|
|
|
|
2010-03-09 16:48:25 +01:00
|
|
|
enableBigEndian = (cross != null && cross.bigEndian);
|
2009-12-04 14:35:58 +01:00
|
|
|
|
|
|
|
configBigEndian = if enableBigEndian then ""
|
|
|
|
else
|
|
|
|
''-e 's/.*ARCH_BIG_ENDIAN.*/#ARCH_BIG_ENDIAN=y/' \
|
|
|
|
-e 's/.*ARCH_WANTS_BIG_ENDIAN.*/#ARCH_WANTS_BIG_ENDIAN=y/' \
|
|
|
|
-e 's/.*ARCH_WANTS_LITTLE_ENDIAN.*/ARCH_WANTS_LITTLE_ENDIAN=y/' '';
|
|
|
|
|
2010-03-09 16:48:25 +01:00
|
|
|
archMakeFlag = if (cross != null) then "ARCH=${cross.arch}" else "";
|
|
|
|
crossMakeFlag = if (cross != null) then "CROSS=${cross.config}-" else "";
|
2009-12-04 14:35:58 +01:00
|
|
|
in
|
2009-11-08 01:32:12 +01:00
|
|
|
stdenv.mkDerivation {
|
2010-03-09 16:51:45 +01:00
|
|
|
name = "uclibc-0.9.30.2" + stdenv.lib.optionalString (cross != null)
|
2010-03-09 16:48:25 +01:00
|
|
|
("-" + cross.config);
|
2009-12-04 14:35:58 +01:00
|
|
|
|
2009-11-08 01:32:12 +01:00
|
|
|
src = fetchurl {
|
2010-03-09 16:51:45 +01:00
|
|
|
url = http://www.uclibc.org/downloads/uClibc-0.9.30.2.tar.bz2;
|
|
|
|
sha256 = "0wr4hlybssiyswdc73wdcxr31xfbss3lnqiv5lcav3rg3v4r4vmb";
|
2009-11-08 01:32:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
configurePhase = ''
|
2009-12-04 14:35:58 +01:00
|
|
|
make defconfig ${archMakeFlag}
|
2009-12-21 15:04:45 +01:00
|
|
|
sed -e s@/usr/include@${linuxHeaders}/include@ \
|
2009-11-08 01:32:12 +01:00
|
|
|
-e 's@^RUNTIME_PREFIX.*@RUNTIME_PREFIX="/"@' \
|
|
|
|
-e 's@^DEVEL_PREFIX.*@DEVEL_PREFIX="/"@' \
|
2009-12-04 14:35:58 +01:00
|
|
|
-e 's@.*UCLIBC_HAS_WCHAR.*@UCLIBC_HAS_WCHAR=y@' \
|
|
|
|
-e 's@.*DO_C99_MATH.*@DO_C99_MATH=y@' \
|
2009-12-09 14:33:23 +01:00
|
|
|
-e 's@.*UCLIBC_HAS_PROGRAM_INVOCATION_NAME.*@UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y@' \
|
2009-12-04 14:35:58 +01:00
|
|
|
${configArmEABI} \
|
|
|
|
${configBigEndian} \
|
2009-11-08 01:32:12 +01:00
|
|
|
-i .config
|
|
|
|
make oldconfig
|
|
|
|
'';
|
|
|
|
|
2009-12-04 14:35:58 +01:00
|
|
|
# Cross stripping hurts.
|
2010-03-09 16:48:25 +01:00
|
|
|
dontStrip = if (cross != null) then true else false;
|
2009-12-04 14:35:58 +01:00
|
|
|
|
|
|
|
makeFlags = [ crossMakeFlag "VERBOSE=1" ];
|
|
|
|
|
|
|
|
buildInputs = stdenv.lib.optional (gccCross != null) gccCross;
|
|
|
|
|
2009-11-08 01:32:12 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2009-12-04 14:35:58 +01:00
|
|
|
make PREFIX=$out VERBOSE=1 install ${crossMakeFlag}
|
2010-03-09 16:48:25 +01:00
|
|
|
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
|
2009-12-04 14:35:58 +01:00
|
|
|
sed -i s@/lib/@$out/lib/@g $out/lib/libc.so
|
2009-11-08 01:32:12 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://www.uclibc.org/;
|
|
|
|
description = "A small implementation of the C library";
|
|
|
|
license = "LGPLv2";
|
|
|
|
};
|
|
|
|
}
|