Subject: [PATCH 21/52] gnu: gamin: Fix 'configure' script when cross-compiling.

From: Maxime Devos <[email-masked]>
Date: Wed, 25 Aug 2021 20:03:01 +0200

* gnu/packages/gnome.scm
  (gamin)[arguments]<#:phases>{set-have-abstract-sockets}: Override
  test for ‘abstract sockets’ when cross-compiling.
---
 gnu/packages/gnome.scm | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index c9ccfad6f2..3f7dcb7988 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -11088,7 +11088,31 @@ repository and commit your work.")
                             "server/gam_node.h"
                             "server/gam_subscription.c")
                (("G_CONST_RETURN") "const"))
-             #t)))))
+             #t))
+         ;; The configure script runs a test program unconditionally,
+         ;; without an option to manually set the test result.
+         ;; Override this test anyway.
+         ,@(if (%current-target-system)
+               `((add-after 'bootstrap 'set-have-abstract-sockets
+                   (lambda _
+                     (define in-abstract-sockets-test? #f)
+                     (substitute* "configure"
+                       (("^#### Abstract sockets\n$")
+                        (set! in-abstract-sockets-test? #t)
+                        "#### Abstract sockets\n")
+                       (("^have_abstract_sockets=no\n$")
+                        (set! in-abstract-sockets-test? #f)
+                        ;; ‘Abstract sockets’ appear to be Linux-only.
+                        (string-append "have_abstract_sockets="
+                                       ,(if (target-linux?)
+                                            "yes"
+                                            "no")
+                                       "\nif false; then\nif false; then :\n"))
+                       (("^(.*\n)$" line)
+                        (if in-abstract-sockets-test?
+                            "" ; delete
+                            line))))))
+               '()))))
     (inputs
      `(("glib" ,glib)))
     (native-inputs
-- 
2.33.0