2018-05-10 02:49:12 +02:00
|
|
|
{ stdenv, buildPackages
|
2018-05-10 05:20:29 +02:00
|
|
|
, fetchurl, linuxHeaders, libiconvReal
|
2018-05-10 02:49:12 +02:00
|
|
|
, extraConfig ? ""
|
|
|
|
}:
|
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
|
|
|
|
|
|
|
|
echo "parseconfig: removing $NAME"
|
|
|
|
sed -i /^$NAME=/d .config
|
|
|
|
|
2015-02-02 01:03:18 +01:00
|
|
|
#if test "$OPTION" != n; then
|
2010-08-21 18:46:23 +02:00
|
|
|
echo "parseconfig: setting $NAME=$OPTION"
|
|
|
|
echo "$NAME=$OPTION" >> .config
|
2015-02-02 01:03:18 +01:00
|
|
|
#fi
|
2010-08-21 18:46:23 +02:00
|
|
|
done
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2012-05-24 21:12:36 +02:00
|
|
|
# UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
|
2010-08-21 18:46:23 +02:00
|
|
|
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
|
2012-05-24 21:12:36 +02:00
|
|
|
UCLIBC_SUSV4_LEGACY y
|
2012-05-24 21:16:00 +02:00
|
|
|
UCLIBC_HAS_THREADS_NATIVE y
|
2010-08-21 18:46:23 +02:00
|
|
|
KERNEL_HEADERS "${linuxHeaders}/include"
|
2018-08-20 20:43:41 +02:00
|
|
|
'' + stdenv.lib.optionalString (stdenv.isAarch32 && stdenv.buildPlatform != stdenv.hostPlatform) ''
|
2015-02-02 01:03:18 +01:00
|
|
|
CONFIG_ARM_EABI y
|
|
|
|
ARCH_WANTS_BIG_ENDIAN n
|
|
|
|
ARCH_BIG_ENDIAN n
|
|
|
|
ARCH_WANTS_LITTLE_ENDIAN y
|
|
|
|
ARCH_LITTLE_ENDIAN y
|
|
|
|
UCLIBC_HAS_FPU n
|
2010-08-21 18:46:23 +02:00
|
|
|
'';
|
|
|
|
|
2020-05-27 19:40:50 +02:00
|
|
|
version = "1.0.34";
|
2009-12-04 14:35:58 +01:00
|
|
|
in
|
2014-10-29 14:55:04 +01:00
|
|
|
|
2009-11-08 01:32:12 +01:00
|
|
|
stdenv.mkDerivation {
|
2018-05-10 05:20:29 +02:00
|
|
|
name = "uclibc-ng-${version}";
|
|
|
|
inherit version;
|
2009-12-04 14:35:58 +01:00
|
|
|
|
2018-05-10 05:20:29 +02:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://downloads.uclibc-ng.org/releases/${version}/uClibc-ng-${version}.tar.bz2";
|
|
|
|
# from "${url}.sha256";
|
2020-05-27 19:40:50 +02:00
|
|
|
sha256 = "025z0072inw1ibnrlwckslp9iayl9c35ysf0h7jjrxlzslzp4yjg";
|
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 = ''
|
2018-05-10 02:49:12 +02:00
|
|
|
make defconfig
|
2010-08-21 18:46:23 +02:00
|
|
|
${configParser}
|
|
|
|
cat << EOF | parseconfig
|
|
|
|
${nixConfig}
|
|
|
|
${extraConfig}
|
2018-08-20 20:43:41 +02:00
|
|
|
${stdenv.hostPlatform.platform.uclibc.extraConfig or ""}
|
2010-08-21 18:46:23 +02:00
|
|
|
EOF
|
2017-12-10 23:28:25 +01:00
|
|
|
( set +o pipefail; yes "" | make oldconfig )
|
2009-11-08 01:32:12 +01:00
|
|
|
'';
|
|
|
|
|
2016-08-05 20:15:27 +02:00
|
|
|
hardeningDisable = [ "stackprotector" ];
|
|
|
|
|
2009-12-04 14:35:58 +01:00
|
|
|
# Cross stripping hurts.
|
2018-05-10 02:49:12 +02:00
|
|
|
dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
|
2009-12-04 14:35:58 +01:00
|
|
|
|
2018-05-10 02:49:12 +02:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2009-12-04 14:35:58 +01:00
|
|
|
|
2018-05-10 02:49:12 +02:00
|
|
|
makeFlags = [
|
2018-08-20 20:43:41 +02:00
|
|
|
"ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
|
2018-05-10 02:49:12 +02:00
|
|
|
"VERBOSE=1"
|
|
|
|
] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
|
|
|
"CROSS=${stdenv.cc.targetPrefix}"
|
|
|
|
];
|
2009-12-04 14:35:58 +01:00
|
|
|
|
2017-12-06 12:57:10 +01:00
|
|
|
# `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`:
|
|
|
|
# error: bits/sysnum.h: No such file or directory
|
|
|
|
enableParallelBuilding = false;
|
2014-10-29 14:18:00 +01:00
|
|
|
|
2009-11-08 01:32:12 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2018-05-10 02:49:12 +02:00
|
|
|
make PREFIX=$out VERBOSE=1 install
|
2010-03-09 16:48:25 +01:00
|
|
|
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
|
2012-05-24 23:44:34 +02:00
|
|
|
# libpthread.so may not exist, so I do || true
|
|
|
|
sed -i s@/lib/@$out/lib/@g $out/lib/libc.so $out/lib/libpthread.so || true
|
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.
|
2015-02-18 05:10:26 +01:00
|
|
|
libiconv = libiconvReal;
|
2010-03-09 19:05:38 +01:00
|
|
|
};
|
2014-10-29 14:18:00 +01:00
|
|
|
|
2017-12-07 11:32:21 +01:00
|
|
|
meta = with stdenv.lib; {
|
2018-05-10 05:20:29 +02:00
|
|
|
homepage = "https://uclibc-ng.org";
|
2009-11-08 01:32:12 +01:00
|
|
|
description = "A small implementation of the C library";
|
2017-12-07 11:32:21 +01:00
|
|
|
maintainers = with maintainers; [ rasendubi ];
|
|
|
|
license = licenses.lgpl2;
|
2019-11-13 15:21:28 +01:00
|
|
|
platforms = intersectLists platforms.linux platforms.x86; # fails to build on ARM
|
2009-11-08 01:32:12 +01:00
|
|
|
};
|
|
|
|
}
|