mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 07:00:43 +00:00
4fa4ab3a6e
First, pass in `self' again so that overriding works properly (thanks for pointing that out, @edolstra) Second, instead of having linuxPackages*.kernel mean something different inside the set and out, add a new attribute linuxPackages*.kernelDev, which for the generic kernel is simply linuxPackages*.kernel but for the manual-config kernel is the `dev' output (which has the build tree, source tree, etc.) The second change required trivial modifications in a bunch of expressions, I verified that all of the linuxPackages* sets defined in all-packages.nix have the same drv paths before and after the change. Signed-off-by: Shea Levy <shea@shealevy.com>
75 lines
2.2 KiB
Nix
75 lines
2.2 KiB
Nix
{ stdenv, fetchurl, perl, bison, mktemp, linuxHeaders, linuxHeadersCross, kernelDev ? null }:
|
|
|
|
assert stdenv.isLinux;
|
|
|
|
let
|
|
version = "1.5.24";
|
|
baseMakeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"];
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
name = "klibc-${version}${stdenv.lib.optionalString (kernelDev != null) "-${kernelDev.version}"}";
|
|
|
|
src = fetchurl {
|
|
url = "mirror://kernel/linux/libs/klibc/1.5/klibc-${version}.tar.bz2";
|
|
sha256 = "18lm32dlj9k2ky9wwk274zmc3jndgrb41b6qm82g3lza6wlw3yki";
|
|
};
|
|
|
|
# Trick to make this build on nix. It expects to have the kernel sources
|
|
# instead of only the linux kernel headers.
|
|
# So it cannot run the 'make headers_install' it wants to run.
|
|
# We don't install the headers, so klibc will not be useful as libc, but
|
|
# usually in nixpkgs we only use the userspace tools comming with klibc.
|
|
prePatch = stdenv.lib.optionalString (kernelDev == null) ''
|
|
sed -i -e /headers_install/d scripts/Kbuild.install
|
|
'';
|
|
|
|
makeFlags = baseMakeFlags;
|
|
|
|
inherit linuxHeaders;
|
|
|
|
crossAttrs = {
|
|
makeFlags = baseMakeFlags ++ [ "CROSS_COMPILE=${stdenv.cross.config}-"
|
|
"KLIBCARCH=${stdenv.cross.arch}" ];
|
|
|
|
patchPhase = ''
|
|
sed -i 's/-fno-pic -mno-abicalls/& -mabi=32/' usr/klibc/arch/mips/MCONFIG
|
|
sed -i /KLIBCKERNELSRC/d scripts/Kbuild.install
|
|
# Wrong check for __mips64 in klibc
|
|
sed -i s/__mips64__/__mips64/ usr/include/fcntl.h
|
|
'';
|
|
|
|
linuxHeaders = linuxHeadersCross;
|
|
};
|
|
|
|
# The AEABI option concerns only arm systems, and does not affect the build for
|
|
# other systems.
|
|
preBuild = ''
|
|
sed -i /CONFIG_AEABI/d defconfig
|
|
echo "CONFIG_AEABI=y" >> defconfig
|
|
makeFlags=$(eval "echo $makeFlags")
|
|
|
|
'' + (if kernelDev == null then ''
|
|
mkdir linux
|
|
cp -prsd $linuxHeaders/include linux/
|
|
chmod -R u+w linux/include/
|
|
'' else ''
|
|
tar xvf ${kernelDev.src}
|
|
mv linux* linux
|
|
cd linux
|
|
ln -sv ${kernelDev}/config .config
|
|
make prepare
|
|
cd ..
|
|
'');
|
|
|
|
# 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/
|
|
cp usr/dash/sh $dir/
|
|
'';
|
|
|
|
nativeBuildInputs = [ perl bison mktemp ];
|
|
}
|