From f4a5540680856aa63653c72eb32c8ec9aa39b4b4 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Sun, 19 Jan 2025 12:21:41 +0100 Subject: [PATCH] motif: fix and enable strictDeps, fix cross build --- pkgs/by-name/mo/motif/package.nix | 40 ++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/mo/motif/package.nix b/pkgs/by-name/mo/motif/package.nix index 569438b7f468..76ff28777862 100644 --- a/pkgs/by-name/mo/motif/package.nix +++ b/pkgs/by-name/mo/motif/package.nix @@ -3,6 +3,7 @@ stdenv, fetchurl, fetchpatch, + buildPackages, pkg-config, libtool, xbitmaps, @@ -32,6 +33,7 @@ stdenv.mkDerivation rec { }; buildInputs = [ + flex libtool xbitmaps libXext @@ -55,9 +57,35 @@ stdenv.mkDerivation rec { libXau ]; - postPatch = lib.optionalString (!demoSupport) '' - sed 's/\//' -i Makefile.{am,in} - ''; + strictDeps = true; + + postPatch = + '' + # File existence fails when cross-compiling - useless for Nix anyhow + substituteInPlace ./configure --replace-fail \ + 'as_fn_error $? "cannot check for file existence' '#' \ + --replace-fail 'pkg-config' '${stdenv.cc.targetPrefix}pkg-config' + '' + + lib.optionalString (!demoSupport) '' + sed 's/\//' -i Makefile.{am,in} + '' + # for cross builds, we must copy several build tools from a native build + # (and we must ensure they are not removed and recreated by make) + + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + cp "${buildPackages.motif}/lib/internals/makestrs" config/util/makestrs + substituteInPlace config/util/Makefile.in \ + --replace-fail '@rm -f makestrs$(EXEEXT)' "" \ + --replace-fail '$(AM_V_CCLD)$(LINK) $(makestrs_OBJECTS) $(makestrs_LDADD) $(LIBS)' "" + + cp "${buildPackages.motif}"/lib/internals/{wml,wmluiltok,wmldbcreate} tools/wml/ + substituteInPlace tools/wml/Makefile.in \ + --replace-fail '@rm -f wmldbcreate$(EXEEXT)' "" \ + --replace-fail '$(AM_V_CCLD)$(LINK) $(wmldbcreate_OBJECTS) $(wmldbcreate_LDADD) $(LIBS)' "" \ + --replace-fail '@rm -f wmluiltok$(EXEEXT)' "" \ + --replace-fail '$(AM_V_CCLD)$(LINK) $(wmluiltok_OBJECTS) $(wmluiltok_LDADD) $(LIBS)' "" \ + --replace-fail '@rm -f wml$(EXEEXT)' "" \ + --replace-fail '$(AM_V_CCLD)$(LINK) $(wml_OBJECTS) $(wml_LDADD) $(LIBS)' "" + ''; patches = [ ./Remove-unsupported-weak-refs-on-darwin.patch @@ -104,6 +132,12 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; + # copy tools for cross builds + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + mkdir -p "$out/lib/internals" + cp config/util/makestrs tools/wml/{wml,wmluiltok,.libs/wmldbcreate} "$out/lib/internals" + ''; + meta = with lib; { homepage = "https://motif.ics.com"; description = "Unix standard widget-toolkit and window-manager";