2009-12-04 13:35:58 +00:00
|
|
|
{stdenv, fetchurl, kernelHeaders, gccCross ? null}:
|
2009-11-08 00:32:12 +00:00
|
|
|
|
|
|
|
assert stdenv.isLinux;
|
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
let
|
|
|
|
target = if (gccCross != null) then gccCross.target else null;
|
|
|
|
enableArmEABI = (target == null && stdenv.system "armv5tel-linux")
|
|
|
|
|| (target != null && target.arch == "arm");
|
|
|
|
|
|
|
|
configArmEABI = if enableArmEABI then
|
|
|
|
''-e 's/.*CONFIG_ARM_OABI.*//' \
|
|
|
|
-e 's/.*CONFIG_ARM_EABI.*/CONFIG_ARM_EABI=y/' '' else "";
|
|
|
|
|
|
|
|
enableBigEndian = (target != null && target.bigEndian);
|
|
|
|
|
|
|
|
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/' '';
|
|
|
|
|
|
|
|
archMakeFlag = if (target != null) then "ARCH=${target.arch}" else "";
|
|
|
|
crossMakeFlag = if (target != null) then "CROSS=${target.config}-" else "";
|
|
|
|
in
|
2009-11-08 00:32:12 +00:00
|
|
|
stdenv.mkDerivation {
|
2009-12-04 13:35:58 +00:00
|
|
|
name = "uclibc-0.9.30.1" + stdenv.lib.optionalString (target != null)
|
|
|
|
("-" + target.config);
|
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = http://www.uclibc.org/downloads/uClibc-0.9.30.1.tar.bz2;
|
|
|
|
sha256 = "132cf27hkgi0q4qlwbiyj4ffj76sja0jcxm0aqzzgks65jh6k5rd";
|
|
|
|
};
|
|
|
|
|
|
|
|
configurePhase = ''
|
2009-12-04 13:35:58 +00:00
|
|
|
make defconfig ${archMakeFlag}
|
|
|
|
sed -e s@/usr/include@${kernelHeaders}/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@' \
|
|
|
|
${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.
|
|
|
|
dontStrip = if (target != null) then true else false;
|
|
|
|
|
|
|
|
makeFlags = [ crossMakeFlag "VERBOSE=1" ];
|
|
|
|
|
|
|
|
buildInputs = stdenv.lib.optional (gccCross != null) gccCross;
|
|
|
|
|
2009-12-01 20:52:13 +00:00
|
|
|
patches = [ ./unifdef-getline.patch ];
|
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
# This will allow the usual gcc-cross-wrapper strip phase work as usual
|
|
|
|
crossConfig = if (target != null) then target.config else null;
|
|
|
|
|
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}
|
2009-11-08 00:32:12 +00:00
|
|
|
(cd $out/include && ln -s ${kernelHeaders}/include/* .) || exit 1
|
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
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://www.uclibc.org/;
|
|
|
|
description = "A small implementation of the C library";
|
|
|
|
license = "LGPLv2";
|
|
|
|
};
|
|
|
|
}
|