2010-08-21 18:46:23 +02:00
|
|
|
{stdenv, fetchurl, linuxHeaders, libiconv, cross ? null, gccCross ? null,
|
|
|
|
extraConfig ? ""}:
|
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-08-21 18:46:23 +02:00
|
|
|
configParser = ''
|
|
|
|
function parseconfig {
|
|
|
|
set -x
|
|
|
|
while read LINE; do
|
|
|
|
NAME=`echo "$LINE" | cut -d \ -f 1`
|
|
|
|
OPTION=`echo "$LINE" | cut -d \ -f 2`
|
|
|
|
|
|
|
|
if test -z "$NAME"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$NAME" == "CLEAR"; then
|
|
|
|
echo "parseconfig: CLEAR"
|
|
|
|
echo > .config
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "parseconfig: removing $NAME"
|
|
|
|
sed -i /^$NAME=/d .config
|
|
|
|
|
|
|
|
if test "$OPTION" != n; then
|
|
|
|
echo "parseconfig: setting $NAME=$OPTION"
|
|
|
|
echo "$NAME=$OPTION" >> .config
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
archMakeFlag = if (cross != null) then "ARCH=${cross.arch}" else "";
|
|
|
|
crossMakeFlag = if (cross != null) then "CROSS=${cross.config}-" else "";
|
|
|
|
|
|
|
|
nixConfig = ''
|
|
|
|
RUNTIME_PREFIX "/"
|
|
|
|
DEVEL_PREFIX "/"
|
|
|
|
UCLIBC_HAS_WCHAR y
|
|
|
|
UCLIBC_HAS_FTW y
|
|
|
|
UCLIBC_HAS_RPC y
|
|
|
|
DO_C99_MATH y
|
|
|
|
UCLIBC_HAS_PROGRAM_INVOCATION_NAME y
|
|
|
|
KERNEL_HEADERS "${linuxHeaders}/include"
|
|
|
|
'';
|
|
|
|
|
2009-12-04 14:35:58 +01:00
|
|
|
in
|
2009-11-08 01:32:12 +01:00
|
|
|
stdenv.mkDerivation {
|
2010-08-21 18:46:23 +02:00
|
|
|
name = "uclibc-0.9.31" + 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-08-21 18:46:23 +02:00
|
|
|
url = http://www.uclibc.org/downloads/uClibc-0.9.31.tar.bz2;
|
|
|
|
sha256 = "1yk328fnz0abgh2vm2r68y65ckfkx97rdp8hbg4xvmx5s94kblw0";
|
2009-11-08 01:32:12 +01:00
|
|
|
};
|
|
|
|
|
2010-03-09 21:36:56 +01:00
|
|
|
# 'ftw' needed to build acl, a coreutils dependency
|
2009-11-08 01:32:12 +01:00
|
|
|
configurePhase = ''
|
2009-12-04 14:35:58 +01:00
|
|
|
make defconfig ${archMakeFlag}
|
2010-08-21 18:46:23 +02:00
|
|
|
${configParser}
|
|
|
|
cat << EOF | parseconfig
|
|
|
|
${nixConfig}
|
|
|
|
${extraConfig}
|
2010-09-02 21:18:04 +02:00
|
|
|
${if cross != null then stdenv.lib.attrByPath [ "uclibc" "extraConfig" ] "" cross else ""}
|
2010-08-21 18:46:23 +02:00
|
|
|
$extraCrossConfig
|
|
|
|
EOF
|
2009-11-08 01:32:12 +01:00
|
|
|
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
|
|
|
'';
|
2010-03-09 19:05:38 +01:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
# Derivations may check for the existance of this attribute, to know what to link to.
|
|
|
|
inherit libiconv;
|
|
|
|
};
|
2009-11-08 01:32:12 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://www.uclibc.org/;
|
|
|
|
description = "A small implementation of the C library";
|
|
|
|
license = "LGPLv2";
|
|
|
|
};
|
|
|
|
}
|