3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/os-specific/linux/uclibc/default.nix

116 lines
3.1 KiB
Nix
Raw Normal View History

2018-05-10 01:49:12 +01:00
{ stdenv, buildPackages
2018-05-10 04:20:29 +01:00
, fetchurl, linuxHeaders, libiconvReal
2018-05-10 01:49:12 +01:00
, buildPlatform, hostPlatform
, extraConfig ? ""
}:
let
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
#if test "$OPTION" != n; then
echo "parseconfig: setting $NAME=$OPTION"
echo "$NAME=$OPTION" >> .config
#fi
done
set +x
}
'';
# UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
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
UCLIBC_SUSV4_LEGACY y
UCLIBC_HAS_THREADS_NATIVE y
KERNEL_HEADERS "${linuxHeaders}/include"
2018-05-10 01:49:12 +01:00
'' + stdenv.lib.optionalString (stdenv.isAarch32 && buildPlatform != hostPlatform) ''
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
'';
2018-05-10 04:20:29 +01:00
version = "1.0.30";
in
stdenv.mkDerivation {
2018-05-10 04:20:29 +01:00
name = "uclibc-ng-${version}";
inherit version;
2018-05-10 04:20:29 +01:00
src = fetchurl {
url = "https://downloads.uclibc-ng.org/releases/${version}/uClibc-ng-${version}.tar.bz2";
# from "${url}.sha256";
sha256 = "3e0f057f24882823d697126015aa4d7d48fa2542be3939985cb3c26dcbcab5a8";
};
# 'ftw' needed to build acl, a coreutils dependency
configurePhase = ''
2018-05-10 01:49:12 +01:00
make defconfig
${configParser}
cat << EOF | parseconfig
${nixConfig}
${extraConfig}
2018-05-10 01:49:12 +01:00
${hostPlatform.platform.uclibc.extraConfig or ""}
EOF
( set +o pipefail; yes "" | make oldconfig )
'';
hardeningDisable = [ "stackprotector" ];
# Cross stripping hurts.
2018-05-10 01:49:12 +01:00
dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;
2018-05-10 01:49:12 +01:00
depsBuildBuild = [ buildPackages.stdenv.cc ];
2018-05-10 01:49:12 +01:00
makeFlags = [
"ARCH=${hostPlatform.parsed.cpu.name}"
"VERBOSE=1"
] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"CROSS=${stdenv.cc.targetPrefix}"
];
# `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`:
# error: bits/sysnum.h: No such file or directory
enableParallelBuilding = false;
installPhase = ''
mkdir -p $out
2018-05-10 01:49:12 +01:00
make PREFIX=$out VERBOSE=1 install
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
# 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
'';
passthru = {
# Derivations may check for the existance of this attribute, to know what to link to.
libiconv = libiconvReal;
};
2017-12-07 10:32:21 +00:00
meta = with stdenv.lib; {
2018-05-10 04:20:29 +01:00
homepage = "https://uclibc-ng.org";
description = "A small implementation of the C library";
2017-12-07 10:32:21 +00:00
maintainers = with maintainers; [ rasendubi ];
license = licenses.lgpl2;
2018-05-10 01:49:12 +01:00
platforms = platforms.linux;
};
}