2018-01-13 21:28:11 +00:00
|
|
|
{ stdenvNoCC, lib, buildPackages
|
2019-06-16 20:59:06 +01:00
|
|
|
, fetchurl, perl
|
2018-01-26 22:40:40 +00:00
|
|
|
, elf-header
|
2018-01-13 21:28:11 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-05-23 09:36:27 +01:00
|
|
|
makeLinuxHeaders = { src, version, patches ? [] }: stdenvNoCC.mkDerivation {
|
|
|
|
inherit src;
|
2018-01-13 21:28:11 +00:00
|
|
|
|
2019-08-31 12:41:23 +01:00
|
|
|
pname = "linux-headers";
|
|
|
|
inherit version;
|
2018-01-13 21:28:11 +00:00
|
|
|
|
2019-04-19 19:51:25 +01:00
|
|
|
ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch;
|
2018-01-13 21:28:11 +00:00
|
|
|
|
|
|
|
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
|
|
|
|
# We do this so we have a build->build, not build->host, C compiler.
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2018-10-26 01:24:32 +01:00
|
|
|
# `elf-header` is null when libc provides `elf.h`.
|
|
|
|
nativeBuildInputs = [ perl elf-header ];
|
2018-01-13 21:28:11 +00:00
|
|
|
|
2018-08-20 19:43:41 +01:00
|
|
|
extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"];
|
2018-01-13 21:28:11 +00:00
|
|
|
|
|
|
|
inherit patches;
|
|
|
|
|
2018-01-26 22:40:40 +00:00
|
|
|
hardeningDisable = lib.optional stdenvNoCC.buildPlatform.isDarwin "format";
|
|
|
|
|
|
|
|
makeFlags = [
|
2018-01-26 22:40:40 +00:00
|
|
|
"SHELL=bash"
|
|
|
|
# Avoid use of runtime build->host compilers for checks. These
|
|
|
|
# checks only cared to work around bugs in very old compilers, so
|
|
|
|
# these changes should be safe.
|
|
|
|
"cc-version:=9999"
|
|
|
|
"cc-fullversion:=999999"
|
|
|
|
# `$(..)` expanded by make alone
|
|
|
|
"HOSTCC:=$(BUILD_CC)"
|
|
|
|
"HOSTCXX:=$(BUILD_CXX)"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Skip clean on darwin, case-sensitivity issues.
|
2018-01-26 22:40:40 +00:00
|
|
|
buildPhase = lib.optionalString (!stdenvNoCC.buildPlatform.isDarwin) ''
|
2018-01-26 22:40:40 +00:00
|
|
|
make mrproper $makeFlags
|
|
|
|
''
|
|
|
|
# For some reason, doing `make install_headers` twice, first without
|
|
|
|
# INSTALL_HDR_PATH=$out then with, is neccessary to get this to work
|
|
|
|
# for darwin cross. @Ericson2314 has no idea why.
|
|
|
|
+ ''
|
|
|
|
make headers_install $makeFlags
|
|
|
|
'';
|
|
|
|
|
2018-01-26 22:40:40 +00:00
|
|
|
checkPhase = ''
|
2018-01-26 22:40:40 +00:00
|
|
|
make headers_check $makeFlags
|
2018-01-13 21:28:11 +00:00
|
|
|
'';
|
|
|
|
|
2018-01-26 22:40:40 +00:00
|
|
|
installPhase = ''
|
2018-01-26 22:40:40 +00:00
|
|
|
make headers_install INSTALL_HDR_PATH=$out $makeFlags
|
2018-10-26 01:24:32 +01:00
|
|
|
''
|
|
|
|
# Some builds (e.g. KVM) want a kernel.release.
|
|
|
|
+ '' mkdir -p $out/include/config
|
2018-01-13 21:28:11 +00:00
|
|
|
echo "${version}-default" > $out/include/config/kernel.release
|
2018-10-26 01:24:32 +01:00
|
|
|
''
|
2019-12-02 16:48:25 +00:00
|
|
|
# These oddly named file records the `SHELL` passed, which causes bootstrap
|
2018-10-26 01:24:32 +01:00
|
|
|
# tools run-time dependency.
|
|
|
|
+ ''
|
|
|
|
find "$out" -name '..install.cmd' -print0 | xargs -0 rm
|
2018-01-13 21:28:11 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Header files and scripts for Linux kernel";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2018-01-26 22:40:40 +00:00
|
|
|
};
|
2018-01-13 21:28:11 +00:00
|
|
|
in {
|
2019-05-23 09:36:27 +01:00
|
|
|
inherit makeLinuxHeaders;
|
2018-01-13 21:28:11 +00:00
|
|
|
|
2019-05-23 09:36:27 +01:00
|
|
|
linuxHeaders = let version = "4.19.16"; in
|
|
|
|
makeLinuxHeaders {
|
|
|
|
inherit version;
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
|
|
|
|
sha256 = "1pqvn6dsh0xhdpawz4ag27vkw1abvb6sn3869i4fbrz33ww8i86q";
|
|
|
|
};
|
|
|
|
patches = [
|
|
|
|
./no-relocs.patch # for building x86 kernel headers on non-ELF platforms
|
|
|
|
./no-dynamic-cc-version-check.patch # so we can use `stdenvNoCC`, see `makeFlags` above
|
|
|
|
];
|
|
|
|
};
|
2018-01-13 21:28:11 +00:00
|
|
|
}
|