gnu: Add ajam. wip-argyll
authorJack Hill <jackhill@jackhill.us>
Sun, 25 Apr 2021 05:37:33 +0000 (01:37 -0400)
committerJack Hill <jackhill@jackhill.us>
Sun, 25 Apr 2021 22:15:19 +0000 (18:15 -0400)
* gnu/packages/build-tools.scm (ajam): New variable.

gnu/packages/build-tools.scm

index 87f393c..3ebebee 100644 (file)
@@ -14,6 +14,7 @@
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Jack Hill <jackhill@jackhill.us>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -41,6 +42,7 @@
   #:use-module (gnu packages adns)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cpp)
@@ -264,6 +266,71 @@ files and generates build instructions for the Ninja build system.")
       ;; 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 "http://www.argyllcms.com/ajam-" version ".tgz"))
+              (sha256
+               (base32
+                "09nadmqidbci0p0mlf7aw199yhc93n6028xq01vajklmsy5pdhsp"))
+              ;; Remove pre-built files
+              (snippet
+               '(for-each delete-file
+                          '("jamgram.c" "jamgram.h" "jamgram.y"
+                            "jamgramtab.h" "Makefile")))))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-broken-link
+           (lambda _
+             (let ((files (find-files "." "\\.html"))
+                   (substitute
+                    (lambda (file)
+                      (substitute* file
+                        (("http://public\\.perforce\\.com/public/index.html")
+                         "https://www.perforce.com/documentation/jam-documentation")))))
+               (for-each substitute files))))
+         ;; Jam is a build tool whose recipes are written in Jam. It is able
+         ;; to bootstrap itself with make. Once the bootstrap is done, the
+         ;; Makefile builds Jam again using the bootstrapped executable and
+         ;; the Jam recipes. These recipes don't work, but we don't need them,
+         ;; and can install the bootstrapped executable.
+         ;; https://www.freelists.org/post/argyllcms/Help-building-ajam,5
+         (add-before 'configure 'disable-self-rebuild
+           (lambda _
+             (substitute* "builds/unix/Makefile.in"
+               (("[[:blank:]]chmod a\\+w jambase\\.c") "")
+               (("[[:blank:]]\\./jam0") "")
+               (("\\$\\(BUILD_DIR\\)/\\$\\(JAMEXE\\)") "jam0"))))
+         (add-before 'configure 'set-environment
+           (lambda _
+             (setenv "JAM_NEW_GNU_AR_OPTIONS" "true")))
+         (add-before 'build 'generate-parser
+           (lambda _
+             (invoke "./yyacc" "jamgram.y" "jamgramtab.h" "jamgram.yy")
+             (invoke "yacc" "-d" "-o" "jamgram.c" "jamgram.y")))
+         (add-after 'install 'install-doc
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (doc (string-append out "/share/doc/ajam"))
+                    (files (find-files "." "\\.html"))
+                    (install (lambda (file)
+                               (chmod file #o444)
+                               (install-file file doc))))
+               (for-each install files)))))))
+    (native-inputs
+     `(("bison" ,bison)))
+    (home-page "http://www.argyllcms.com/doc/Compiling.html")
+    (synopsis "Build tool with automatic dependency detection")
+    (description "Jam is a build tool with automatic dependency detection for
+C and C++.  This package is a fork of Jam originally released by Perforce
+tailored to building Argyll.")
+    (license license:perforce-jam)))
+
 (define-public meson
   (package
     (name "meson")