grub2_efi: fix cross-compilation

wip/yesman
Pierre Bourdon 3 years ago committed by Samuel Dionne-Riel
parent 4f8cfd1c2e
commit 4df002c432
  1. 20
      pkgs/tools/misc/grub/2.0x.nix

@ -1,6 +1,6 @@
{ lib, stdenv, fetchgit, flex, bison, python3, autoconf, automake, gnulib, libtool
, gettext, ncurses, libusb-compat-0_1, freetype, qemu, lvm2, unifont, pkg-config
, pkgsBuildBuild
, buildPackages
, nixosTests
, fuse # only needed for grub-mount
, runtimeShell
@ -64,7 +64,8 @@ stdenv.mkDerivation rec {
echo 'echo "Compile grub2 with { kbdcompSupport = true; } to enable support for this command."' >> util/grub-kbdcomp.in
'';
nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bison flex python3 pkg-config autoconf automake gettext freetype ];
buildInputs = [ ncurses libusb-compat-0_1 freetype lvm2 fuse libtool ]
++ optional doCheck qemu
++ optional zfsSupport zfs;
@ -105,9 +106,18 @@ stdenv.mkDerivation rec {
configureFlags = [
"--enable-grub-mount" # dep of os-prober
"BUILD_CC=${pkgsBuildBuild.stdenv.cc}/bin/cc"
]
++ optional zfsSupport "--enable-libzfs"
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# grub doesn't do cross-compilation as usual and tries to use unprefixed
# tools to target the host. Provide toolchain information explicitly for
# cross builds.
#
# Ref: # https://github.com/buildroot/buildroot/blob/master/boot/grub2/grub2.mk#L108
"TARGET_CC=${stdenv.cc.targetPrefix}cc"
"TARGET_NM=${stdenv.cc.targetPrefix}nm"
"TARGET_OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
"TARGET_RANLIB=${stdenv.cc.targetPrefix}ranlib"
"TARGET_STRIP=${stdenv.cc.targetPrefix}strip"
] ++ optional zfsSupport "--enable-libzfs"
++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}" "--program-prefix=" ]
++ optionals xenSupport [ "--with-platform=xen" "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"];

Loading…
Cancel
Save