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