linux/kernel/manual-config: Build in a separate directory and move the build and source trees into $out

This commit is contained in:
Shea Levy 2012-07-29 03:49:52 -04:00
parent e42a6c5f46
commit 48b5e8eee7

View File

@ -41,6 +41,9 @@ let
features = readFeatures config; features = readFeatures config;
commonMakeFlags = [
"O=../build"
];
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
@ -54,8 +57,8 @@ stdenv.mkDerivation ({
inherit patches src; inherit patches src;
postPatch = '' prePatch = ''
for mf in $(find -name Makefile); do for mf in $(find -name Makefile -o -name Makefile.include); do
echo "stripping FHS paths in \`$mf'..." echo "stripping FHS paths in \`$mf'..."
sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g' sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g'
done done
@ -63,9 +66,11 @@ stdenv.mkDerivation ({
configurePhase = '' configurePhase = ''
runHook preConfigure runHook preConfigure
ln -sv ${config} .config mkdir ../build
make oldconfig make $makeFlags "''${makeFlagsArray[@]}" mrproper
rm .config.old ln -sv ${config} ../build/.config
make $makeFlags "''${makeFlagsArray[@]}" oldconfig
rm ../build/.config.old
runHook postConfigure runHook postConfigure
''; '';
@ -76,14 +81,18 @@ stdenv.mkDerivation ({
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir $out mkdir $out
mv -v System.map $out mv -v ../build/System.map $out
# !!! Assumes x86 # !!! Assumes x86
mv -v arch/x86/boot/bzImage $out mv -v ../build/arch/x86/boot/bzImage $out
mv -v vmlinux $out mv -v ../build/vmlinux $out
runHook postInstall runHook postInstall
''; '';
makeFlags = commonMakeFlags;
} // optionalAttrs features.modular { } // optionalAttrs features.modular {
makeFlags = [ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" ]; makeFlags = commonMakeFlags ++ [
"MODLIB=\"$(out)/lib/modules/${modDirVersion}\""
];
INSTALL_MOD_STRIP = "1"; INSTALL_MOD_STRIP = "1";
@ -92,7 +101,7 @@ stdenv.mkDerivation ({
$installFlags "''${installFlagsArray[@]}" $installFlags "''${installFlagsArray[@]}"
rm -f $out/lib/modules/${modDirVersion}/{build,source} rm -f $out/lib/modules/${modDirVersion}/{build,source}
cd .. cd ..
mv $sourceRoot $out/lib/modules/${modDirVersion}/build mv $sourceRoot $out/lib/modules/${modDirVersion}/source
ln -sv $out/lib/modules/${modDirVersion}/{build,source} mv build $out/lib/modules/${modDirVersion}/build
''; '';
}) })