2020-10-21 05:07:51 +00:00
|
|
|
{ lib, stdenv, fetchurl, buildPackages, linuxHeaders, perl }:
|
2005-08-27 20:48:05 +00:00
|
|
|
|
2010-04-04 18:10:42 +00:00
|
|
|
let
|
2014-01-05 01:57:21 +00:00
|
|
|
commonMakeFlags = [
|
|
|
|
"prefix=$(out)"
|
|
|
|
"SHLIBDIR=$(out)/lib"
|
|
|
|
];
|
2010-04-04 18:10:42 +00:00
|
|
|
in
|
2009-01-29 15:44:37 +00:00
|
|
|
|
2016-04-18 15:05:40 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "klibc";
|
2022-01-02 20:52:02 +00:00
|
|
|
version = "2.0.10";
|
2009-01-29 15:44:37 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2014-01-05 01:57:21 +00:00
|
|
|
url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz";
|
2022-01-02 20:52:02 +00:00
|
|
|
sha256 = "sha256-ZidT2oiJ50TfwNtutAIcM3fufvjtZtfVd2X4yeJZOc0=";
|
2009-01-29 15:44:37 +00:00
|
|
|
};
|
2010-09-05 06:00:14 +00:00
|
|
|
|
2014-01-05 01:57:21 +00:00
|
|
|
patches = [ ./no-reinstall-kernel-headers.patch ];
|
2010-04-04 18:10:42 +00:00
|
|
|
|
2020-10-21 05:07:51 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2014-01-05 01:57:21 +00:00
|
|
|
nativeBuildInputs = [ perl ];
|
2021-01-17 15:30:57 +00:00
|
|
|
strictDeps = true;
|
2010-04-04 18:10:42 +00:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "format" "stackprotector" ];
|
2016-02-12 02:58:58 +00:00
|
|
|
|
2014-01-05 01:57:21 +00:00
|
|
|
makeFlags = commonMakeFlags ++ [
|
2021-01-23 01:33:55 +00:00
|
|
|
"KLIBCARCH=${stdenv.hostPlatform.linuxArch}"
|
2016-04-18 15:05:40 +00:00
|
|
|
"KLIBCKERNELSRC=${linuxHeaders}"
|
2017-06-28 20:38:33 +00:00
|
|
|
] # TODO(@Ericson2314): We now can get the ABI from
|
2018-08-20 18:43:41 +00:00
|
|
|
# `stdenv.hostPlatform.parsed.abi`, is this still a good idea?
|
2021-01-23 01:33:55 +00:00
|
|
|
++ lib.optional (stdenv.hostPlatform.linuxArch == "arm") "CONFIG_AEABI=y"
|
2021-01-15 14:45:37 +00:00
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "CROSS_COMPILE=${stdenv.cc.targetPrefix}";
|
2008-11-02 15:53:55 +00:00
|
|
|
|
2009-01-29 15:44:37 +00:00
|
|
|
# Install static binaries as well.
|
|
|
|
postInstall = ''
|
|
|
|
dir=$out/lib/klibc/bin.static
|
|
|
|
mkdir $dir
|
|
|
|
cp $(find $(find . -name static) -type f ! -name "*.g" -a ! -name ".*") $dir/
|
2014-01-05 01:57:21 +00:00
|
|
|
|
2016-04-18 15:05:40 +00:00
|
|
|
for file in ${linuxHeaders}/include/*; do
|
2014-01-05 01:57:21 +00:00
|
|
|
ln -sv $file $out/lib/klibc/include
|
|
|
|
done
|
2009-01-29 15:44:37 +00:00
|
|
|
'';
|
2016-08-02 16:06:29 +00:00
|
|
|
|
|
|
|
meta = {
|
2020-02-08 13:30:51 +00:00
|
|
|
description = "Minimalistic libc subset for initramfs usage";
|
|
|
|
homepage = "https://kernel.org/pub/linux/libs/klibc/";
|
|
|
|
maintainers = with lib.maintainers; [ fpletz ];
|
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
platforms = lib.platforms.linux;
|
2016-08-02 16:06:29 +00:00
|
|
|
};
|
2005-08-27 20:48:05 +00:00
|
|
|
}
|