2015-08-19 17:34:29 +01:00
|
|
|
{stdenv, fetchzip, linuxHeaders, libiconvReal, cross ? null, gccCross ? null,
|
2010-08-21 17:46:23 +01:00
|
|
|
extraConfig ? ""}:
|
2009-11-08 00:32:12 +00:00
|
|
|
|
|
|
|
assert stdenv.isLinux;
|
2010-03-09 15:48:25 +00:00
|
|
|
assert cross != null -> gccCross != null;
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
let
|
2010-08-21 17:46:23 +01: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 17:46:23 +01:00
|
|
|
echo "parseconfig: setting $NAME=$OPTION"
|
|
|
|
echo "$NAME=$OPTION" >> .config
|
2015-02-02 00:03:18 +00:00
|
|
|
#fi
|
2010-08-21 17:46:23 +01:00
|
|
|
done
|
|
|
|
set +x
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2012-12-28 18:54:15 +00:00
|
|
|
archMakeFlag = if cross != null then "ARCH=${cross.arch}" else "";
|
|
|
|
crossMakeFlag = if cross != null then "CROSS=${cross.config}-" else "";
|
2010-08-21 17:46:23 +01:00
|
|
|
|
2012-05-24 20:12:36 +01:00
|
|
|
# UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
|
2010-08-21 17:46:23 +01: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 20:12:36 +01:00
|
|
|
UCLIBC_SUSV4_LEGACY y
|
2012-05-24 20:16:00 +01:00
|
|
|
UCLIBC_HAS_THREADS_NATIVE y
|
2010-08-21 17:46:23 +01:00
|
|
|
KERNEL_HEADERS "${linuxHeaders}/include"
|
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 02:41:06 +00:00
|
|
|
'' + stdenv.lib.optionalString (stdenv.isAarch32 && cross == null) ''
|
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 17:46:23 +01:00
|
|
|
'';
|
|
|
|
|
2015-08-19 17:34:29 +01:00
|
|
|
name = "uclibc-0.9.34-pre-20150131";
|
|
|
|
rev = "343f6b8f1f754e397632b0552e4afe586c8b392b";
|
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
in
|
2014-10-29 13:55:04 +00:00
|
|
|
|
2009-11-08 00:32:12 +00:00
|
|
|
stdenv.mkDerivation {
|
2015-08-19 17:34:29 +01:00
|
|
|
name = name + stdenv.lib.optionalString (cross != null) ("-" + cross.config);
|
2009-12-04 13:35:58 +00:00
|
|
|
|
2015-08-19 17:34:29 +01:00
|
|
|
src = fetchzip {
|
|
|
|
name = name + "-source";
|
|
|
|
url = "http://git.uclibc.org/uClibc/snapshot/uClibc-${rev}.tar.bz2";
|
|
|
|
sha256 = "1kgylzpid7da5i7wz7slh5q9rnq1m8bv5h9ilm76g0xwc2iwlhbw";
|
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 = ''
|
2009-12-04 13:35:58 +00:00
|
|
|
make defconfig ${archMakeFlag}
|
2010-08-21 17:46:23 +01:00
|
|
|
${configParser}
|
|
|
|
cat << EOF | parseconfig
|
|
|
|
${nixConfig}
|
|
|
|
${extraConfig}
|
2010-09-02 20:18:04 +01:00
|
|
|
${if cross != null then stdenv.lib.attrByPath [ "uclibc" "extraConfig" ] "" cross else ""}
|
2010-08-21 17:46:23 +01:00
|
|
|
$extraCrossConfig
|
|
|
|
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 19:15:27 +01:00
|
|
|
hardeningDisable = [ "stackprotector" ];
|
|
|
|
|
2009-12-04 13:35:58 +00:00
|
|
|
# Cross stripping hurts.
|
2012-12-28 18:57:47 +00:00
|
|
|
dontStrip = cross != null;
|
2009-12-04 13:35:58 +00:00
|
|
|
|
|
|
|
makeFlags = [ crossMakeFlag "VERBOSE=1" ];
|
|
|
|
|
|
|
|
buildInputs = stdenv.lib.optional (gccCross != null) gccCross;
|
|
|
|
|
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 = ''
|
|
|
|
mkdir -p $out
|
2009-12-04 13:35:58 +00:00
|
|
|
make PREFIX=$out VERBOSE=1 install ${crossMakeFlag}
|
2010-03-09 15:48:25 +00:00
|
|
|
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
|
2012-05-24 22:44:34 +01: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 00:32:12 +00:00
|
|
|
'';
|
2010-03-09 18:05:38 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
# Derivations may check for the existance of this attribute, to know what to link to.
|
2015-02-18 04:10:26 +00:00
|
|
|
libiconv = libiconvReal;
|
2010-03-09 18:05:38 +00:00
|
|
|
};
|
2014-10-29 13:18:00 +00:00
|
|
|
|
2017-12-07 10:32:21 +00:00
|
|
|
meta = with stdenv.lib; {
|
2009-11-08 00:32:12 +00:00
|
|
|
homepage = http://www.uclibc.org/;
|
|
|
|
description = "A small implementation of the C library";
|
2017-12-07 10:32:21 +00:00
|
|
|
maintainers = with maintainers; [ rasendubi ];
|
|
|
|
license = licenses.lgpl2;
|
|
|
|
platforms = subtractLists ["aarch64-linux"] platforms.linux;
|
2009-11-08 00:32:12 +00:00
|
|
|
};
|
|
|
|
}
|