Commit 93d523cb authored by David McFarland's avatar David McFarland
Browse files

file: fix cross build for windows platforms

This should be a more general fix than the original windows one.  This
is needed because upstream uses `EXEEXT` for build stuff:

    # FIXME: Build file natively as well so that it can be used to compile
    # the target's magic file; for now we bail if the local version does not
    match
    if IS_CROSS_COMPILE
    FILE_COMPILE = file${EXEEXT}
    FILE_COMPILE_DEP =
    else
    FILE_COMPILE = $(top_builddir)/src/file${EXEEXT}
    FILE_COMPILE_DEP = $(FILE_COMPILE)
    endif
parent be8c8ea7
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
  lib,
  stdenv,
  fetchurl,
  file,
  buildPackages,
  zlib,
  libgnurx,
  updateAutotoolsGnuConfigScriptsHook,
@@ -51,14 +51,16 @@ stdenv.mkDerivation (finalAttrs: {

  nativeBuildInputs = [
    updateAutotoolsGnuConfigScriptsHook
  ]
  ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
  ];
  buildInputs = [ zlib ] ++ lib.optional stdenv.hostPlatform.isMinGW libgnurx;

  # https://bugs.astron.com/view.php?id=382
  doCheck = !stdenv.buildPlatform.isMusl;

  makeFlags = lib.optional stdenv.hostPlatform.isWindows "FILE_COMPILE=file";
  # In native builds, it will use the newly-compiled file instead.
  makeFlags = lib.optional (
    !lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform
  ) "FILE_COMPILE=${lib.getExe buildPackages.file}";

  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;