Subject: [bug#68337] [PATCH 1/2] gnu: Add ajam.

From: [email-masked]
Date: Mon, 8 Jan 2024 22:35:43 -0600

From: Ulf Herrman <[email-masked]>

* gnu/packages/build-tools.scm (ajam): New variable.
* gnu/packages/patches/ajam-add-unistd-include.patch: New patch.
* gnu/local.mk (dist_patch_DATA): register it.

Change-Id: I6f093b3c215199d3a19bab66d77af3d2e79b3749
---
 gnu/local.mk                                  |  1 +
 gnu/packages/build-tools.scm                  | 30 +++++++++++++++
 .../patches/ajam-add-unistd-include.patch     | 37 +++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 gnu/packages/patches/ajam-add-unistd-include.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 533b32a00b..436308c241 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -907,6 +907,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/agda-stdlib-use-runhaskell.patch	\
   %D%/packages/patches/agg-am_c_prototype.patch			\
   %D%/packages/patches/agg-2.5-gcc8.patch			\
+  %D%/packages/patches/ajam-add-unistd-include.patch		\
   %D%/packages/patches/akonadi-paths.patch		\
   %D%/packages/patches/akonadi-not-relocatable.patch		\
   %D%/packages/patches/akonadi-timestamps.patch		\
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 9e6ed6eec6..89fe9d903e 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -290,6 +290,36 @@ (define-public gn
       ;; X11 license.
       (license (list license:bsd-3 license:x11)))))
 
+(define-public ajam
+  (package
+    (name "ajam")
+    (version "2.5.2-1.3.3")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://www.argyllcms.com/jam-" version ".tgz"))
+              (sha256
+               (base32
+                "09nadmqidbci0p0mlf7aw199yhc93n6028xq01vajklmsy5pdhsp"))
+              (patches
+               (search-patches "ajam-add-unistd-include.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'patch-/bin/sh
+            (lambda _
+              (substitute* "execunix.c"
+                (("\"/bin/sh\"")
+                 (string-append "\"" (which "sh") "\"")))))
+          (add-before 'configure 'set-CC
+            (lambda _
+              (setenv "CC" "gcc"))))))
+    (home-page "https://www.argyllcms.com/doc/Compiling.html")
+    (synopsis "Jam build tool prepatched for use in Argyllcms")
+    (description "Jam build tool prepatched for use in Argyllcms")
+    (license (license:non-copyleft "file://README.ORG"))))
+
 (define-public meson
   (package
     (name "meson")
diff --git a/gnu/packages/patches/ajam-add-unistd-include.patch b/gnu/packages/patches/ajam-add-unistd-include.patch
new file mode 100644
index 0000000000..8c66f77b94
--- /dev/null
+++ b/gnu/packages/patches/ajam-add-unistd-include.patch
@@ -0,0 +1,37 @@
+diff --git a/execunix.c b/execunix.c
+index 3ae4c76..469f8d7 100755
+--- a/execunix.c
++++ b/execunix.c
+@@ -38,6 +38,8 @@
+  * 12/27/02 (seiwald) - grist .bat file with pid for system uniqueness
+  */
+ 
++#include <unistd.h>
++#include <sys/wait.h>
+ # include "jam.h"
+ # include "lists.h"
+ # include "execcmd.h"
+diff --git a/fileunix.c b/fileunix.c
+index 4c9a5a6..871b752 100755
+--- a/fileunix.c
++++ b/fileunix.c
+@@ -33,6 +33,7 @@
+  * 12/30/02 (seiwald) - skip solaris' empty archive member names (/, //xxx)
+  */
+ 
++# include <unistd.h>
+ # include "jam.h"
+ # include "filesys.h"
+ # include "pathsys.h"
+diff --git a/make1.c b/make1.c
+index 3f7f14a..66e61d1 100755
+--- a/make1.c
++++ b/make1.c
+@@ -49,6 +49,7 @@
+  * 12/03/02 (seiwald) - fix odd includes support by grafting them onto depends
+  */
+ 
++# include <unistd.h>
+ # include "jam.h"
+ 
+ # include "lists.h"
-- 
2.41.0