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