2022-06-16 20:29:09 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPackages
|
|
|
|
, fetchurl
|
|
|
|
, linuxHeaders
|
|
|
|
, libiconvReal
|
2018-05-10 00:49:12 +00:00
|
|
|
, extraConfig ? ""
|
|
|
|
}:
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
let
|
2022-06-16 20:29:09 +00:00
|
|
|
isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
|
2010-08-21 16:46:23 +00: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 00:03:18 +00:00
|
|
|
#if test "$OPTION" != n; then
|
2010-08-21 16:46:23 +00:00
|
|
|
echo "parseconfig: setting $NAME=$OPTION"
|
|
|
|
echo "$NAME=$OPTION" >> .config
|
2015-02-02 00:03:18 +00:00
|
|
|
#fi
|
2010-08-21 16:46:23 +00:00
|
|
|
done
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2012-05-24 19:12:36 +00:00
|
|
|
# UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
|
2010-08-21 16:46:23 +00: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
|
2022-06-16 20:29:09 +00:00
|
|
|
UCLIBC_HAS_RESOLVER_SUPPORT y
|
2012-05-24 19:12:36 +00:00
|
|
|
UCLIBC_SUSV4_LEGACY y
|
2012-05-24 19:16:00 +00:00
|
|
|
UCLIBC_HAS_THREADS_NATIVE y
|
2010-08-21 16:46:23 +00:00
|
|
|
KERNEL_HEADERS "${linuxHeaders}/include"
|
2021-12-10 01:12:42 +00:00
|
|
|
'' + lib.optionalString (stdenv.hostPlatform.gcc.float or "" == "soft") ''
|
|
|
|
UCLIBC_HAS_FPU n
|
2022-06-16 20:29:09 +00:00
|
|
|
'' + lib.optionalString (stdenv.isAarch32 && isCross) ''
|
2015-02-02 00:03:18 +00: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 16:46:23 +00:00
|
|
|
'';
|
2009-12-04 13:35:58 +00:00
|
|
|
in
|
2022-06-16 20:29:09 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-01-10 22:30:11 +00:00
|
|
|
pname = "uclibc-ng";
|
2023-01-09 23:28:30 +00:00
|
|
|
version = "1.0.42";
|
2009-12-04 13:35:58 +00:00
|
|
|
|
2018-05-10 03:20:29 +00:00
|
|
|
src = fetchurl {
|
2022-06-16 20:29:09 +00:00
|
|
|
url = "https://downloads.uclibc-ng.org/releases/${version}/uClibc-ng-${version}.tar.xz";
|
2023-01-09 23:28:30 +00:00
|
|
|
sha256 = "sha256-7G2uRM6GVYiF5WvDvva9TQgjlxFObh/BV5X3HoBNcBY=";
|
2009-11-08 00:32:12 +00:00
|
|
|
};
|
|
|
|
|
2010-03-09 20:36:56 +00:00
|
|
|
# 'ftw' needed to build acl, a coreutils dependency
|
2009-11-08 00:32:12 +00:00
|
|
|
configurePhase = ''
|
2018-05-10 00:49:12 +00:00
|
|
|
make defconfig
|
2010-08-21 16:46:23 +00:00
|
|
|
${configParser}
|
|
|
|
cat << EOF | parseconfig
|
|
|
|
${nixConfig}
|
|
|
|
${extraConfig}
|
2021-01-23 01:33:55 +00:00
|
|
|
${stdenv.hostPlatform.uclibc.extraConfig or ""}
|
2010-08-21 16:46:23 +00:00
|
|
|
EOF
|
2017-12-10 22:28:25 +00:00
|
|
|
( set +o pipefail; yes "" | make oldconfig )
|
2009-11-08 00:32:12 +00:00
|
|
|
'';
|
|
|
|
|
2016-08-05 18:15:27 +00:00
|
|
|
hardeningDisable = [ "stackprotector" ];
|
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
# Cross stripping hurts.
|
2022-06-16 20:29:09 +00:00
|
|
|
dontStrip = isCross;
|
2009-12-04 13:35:58 +00:00
|
|
|
|
2018-05-10 00:49:12 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2009-12-04 13:35:58 +00:00
|
|
|
|
2018-05-10 00:49:12 +00:00
|
|
|
makeFlags = [
|
2021-12-10 01:12:42 +00:00
|
|
|
"ARCH=${stdenv.hostPlatform.linuxArch}"
|
|
|
|
"TARGET_ARCH=${stdenv.hostPlatform.linuxArch}"
|
2018-05-10 00:49:12 +00:00
|
|
|
"VERBOSE=1"
|
2022-06-16 20:29:09 +00:00
|
|
|
] ++ lib.optionals (isCross) [
|
2018-05-10 00:49:12 +00:00
|
|
|
"CROSS=${stdenv.cc.targetPrefix}"
|
|
|
|
];
|
2009-12-04 13:35:58 +00:00
|
|
|
|
2017-12-06 11:57:10 +00:00
|
|
|
# `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`:
|
|
|
|
# error: bits/sysnum.h: No such file or directory
|
|
|
|
enableParallelBuilding = false;
|
2014-10-29 13:18:00 +00:00
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
installPhase = ''
|
2022-06-16 20:29:09 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
mkdir -p $out
|
2021-12-10 01:12:42 +00:00
|
|
|
make $makeFlags PREFIX=$out VERBOSE=1 install
|
2010-03-09 15:48:25 +00:00
|
|
|
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
|
2012-05-24 21:44:34 +00: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
|
2010-03-09 18:05:38 +00:00
|
|
|
|
2022-06-16 20:29:09 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2014-10-29 13:18:00 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-05-10 03:20:29 +00:00
|
|
|
homepage = "https://uclibc-ng.org";
|
2022-06-16 20:29:09 +00:00
|
|
|
description = "Embedded C library";
|
|
|
|
longDescription = ''
|
|
|
|
uClibc-ng is a small C library for developing embedded Linux systems. It
|
|
|
|
is much smaller than the GNU C Library, but nearly all applications
|
|
|
|
supported by glibc also work perfectly with uClibc-ng.
|
|
|
|
|
|
|
|
Porting applications from glibc to uClibc-ng typically involves just
|
|
|
|
recompiling the source code. uClibc-ng supports shared libraries and
|
|
|
|
threading. It currently runs on standard Linux and MMU-less (also known as
|
|
|
|
uClinux) systems with support for Aarch64, Alpha, ARC, ARM, AVR32,
|
|
|
|
Blackfin, CRIS, C-Sky, C6X, FR-V, H8/300, HPPA, i386, IA64, KVX, LM32,
|
|
|
|
M68K/Coldfire, Metag, Microblaze, MIPS, MIPS64, NDS32, NIOS2, OpenRISC,
|
|
|
|
PowerPC, RISCV64, Sparc, Sparc64, SuperH, Tile, X86_64 and XTENSA
|
|
|
|
processors. Alpha, FR-V, HPPA, IA64, LM32, NIOS2, Tile and Sparc64 are
|
|
|
|
experimental and need more testing.
|
|
|
|
'';
|
|
|
|
license = licenses.lgpl2Plus;
|
|
|
|
maintainers = with maintainers; [ rasendubi AndersonTorres ];
|
2021-12-10 01:12:42 +00:00
|
|
|
platforms = platforms.linux;
|
2022-06-16 20:29:09 +00:00
|
|
|
badPlatforms = platforms.aarch64;
|
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
# Derivations may check for the existance of this attribute, to know what to
|
|
|
|
# link to.
|
|
|
|
libiconv = libiconvReal;
|
2009-11-08 00:32:12 +00:00
|
|
|
};
|
2022-06-16 20:29:09 +00:00
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
}
|