diff mbox series

[bug#60849,core-updates,1/4] gnu: libtommath: Update to 1.2.0-0.03de03d.

Message ID 20230116051339.27113-2-maxim.cournoyer@gmail.com
State New
Headers show
Series Enable cross-Compilation for python-pycryptodome | expand

Commit Message

Maxim Cournoyer Jan. 16, 2023, 5:13 a.m. UTC
This change makes it possible to cross-compile libtommath.

* gnu/packages/multiprecision.scm (libtommath): Update to 1.2.0-0.03de03d.
[outputs]: Delete field.
[source]: Fetch from git.
[build-system]: Switch to cmake-build-system.
[arguments]: Delete prepare-build, remove-static-library, check and
install-static-library phases.  Delete #:test-target and #:make-flags
arguments.  Add #:configure-flags argument.
[native-inputs]: Delete field.
---

 gnu/packages/multiprecision.scm | 73 +++++++++++----------------------
 1 file changed, 25 insertions(+), 48 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
index b96efed843..c8b4639ed7 100644
--- a/gnu/packages/multiprecision.scm
+++ b/gnu/packages/multiprecision.scm
@@ -8,7 +8,7 @@ 
 ;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,6 +39,7 @@  (define-module (gnu packages multiprecision)
   #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu))
 
 (define-public gmp
@@ -439,56 +440,32 @@  (define-public libtomcrypt
     (license unlicense)))
 
 (define-public libtommath
-  (package
-    (name "libtommath")
-    (version "1.2.0")
-    (outputs '("out" "static"))
-    (source
-      (origin
-        (method url-fetch)
-        (uri (string-append "https://github.com/libtom/libtommath/releases/"
-                            "download/v" version "/ltm-" version ".tar.xz"))
-        (sha256
-         (base32
-          "1c8q1qy88cjhdjlk3g24mra94h34c1ldvkjz0n2988c0yvn5xixp"))))
-    (build-system gnu-build-system)
-    (arguments
-     '(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure) ; no configure
-         (add-after 'unpack 'prepare-build
-           (lambda _
-             ;; We want the shared library by default so force it to be the
-             ;; default makefile target.
-             (delete-file "makefile")
-             (symlink "makefile.shared" "makefile")
-             #t))
-         (add-after 'install 'remove-static-library
-           (lambda* (#:key outputs #:allow-other-keys)
-             (delete-file (string-append (assoc-ref outputs "out")
-                                         "/lib/libtommath.a"))
-             #t))
-         (replace 'check
-           (lambda* (#:key test-target make-flags #:allow-other-keys)
-             (apply invoke "make" test-target make-flags)
-             (invoke "sh" "test")))
-         (add-after 'install 'install-static-library
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "make" "-f" "makefile.unix" "install"
-                     (string-append "PREFIX=" (assoc-ref outputs "static"))
-                     (string-append "CC=" (which "gcc"))))))
-       #:test-target "test"
-       #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
-                          "CC=gcc")))
-    (native-inputs
-     (list libtool))
-    (home-page "https://www.libtom.net/LibTomMath/")
-    (synopsis "Portable number theoretic multiple-precision integer library")
-    (description "LibTomMath is a portable number theoretic multiple-precision
+  ;; Use the latest commit, as it contains a new CMake build system capable of
+  ;; cross-compilation.
+  (let ((revision "0")
+        (commit "03de03dee753442d4b23166982514639c4ccbc39"))
+    (package
+      (name "libtommath")
+      (version (git-version "1.2.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/libtom/libtommath")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0maqzpc3f4l9b3bps8dj49b3schj3dfzvf2xcpilg8q3p1sxgrbl"))))
+      (build-system cmake-build-system)
+      (arguments (list #:configure-flags #~(list "-DBUILD_TESTING=ON"
+                                                 "-DBUILD_SHARED_LIBS=ON")))
+      (home-page "https://www.libtom.net/LibTomMath/")
+      (synopsis "Portable number theoretic multiple-precision integer library")
+      (description "LibTomMath is a portable number theoretic multiple-precision
 integer library written entirely in C.  It's designed to provide an API that is
 simple to work with that provides fairly efficient routines that build out of
 the box without configuration.")
-    (license unlicense)))
+      (license unlicense))))
 
 (define-public libtommath-1.1
   (package