[bug#34615] gnu: Add libtommath.

Message ID 20190222122014.21600-1-efraim@flashner.co.il
State Accepted
Headers show
Series [bug#34615] gnu: Add libtommath. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Efraim Flashner Feb. 22, 2019, 12:20 p.m. UTC
* gnu/packages/algebra.scm (libtommath): New variable.
---
 gnu/packages/algebra.scm | 47 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

Comments

Tobias Geerinckx-Rice Feb. 22, 2019, 6:57 p.m. UTC | #1
Efraim,

Thanks!

Efraim Flashner wrote:
> * gnu/packages/algebra.scm (libtommath): New variable.

> + (add-after 'unpack 'prepare-build
> +   (lambda _
> +     ;; Don't pull in coreutils.
> +     (substitute* "makefile_include.mk"
> +       (("arch") "uname -m"))

I'd add an empty line here or separate this into two fases just to 
be very clear, since…

> +     (delete-file "makefile")
> +     (symlink "makefile.shared" "makefile")
> +     #t))

…I got a bit lost between all these makefiles.  Could you explain 
exactly what's going on?

Is this to avoid repeating ‘-f makefile.shared’ elsewhere?

> + (add-after 'check 'make-static

More accurate: 'install-static-library.

While libtommath.a is ‘only’ 332K, that's almost half of the 
entire output size.  Is it worth moving to a separate :static 
output?

> + (synopsis "portable number theoretic multiple-precision 
> integer library")

s/p/P/

multiprecision.scm is a better fit and already has sister package 
tomsfastmath to keep this one company.

> +integer library written entirely in C.  The library is designed 
> to provide a

s/The library is/It's/ IMO.

> +simple to work with API

‘simple-to-work-with API’, unfortunately.

Kind regards,

T G-R
swedebugia Feb. 23, 2019, 9:06 a.m. UTC | #2
Tobias Geerinckx-Rice <somebody@not-sent-or-endorsed-by.tobias.gr> skrev: (22 februari 2019 19:57:25 CET)
>Efraim,
>
>Thanks!
>
>Efraim Flashner wrote:

>
>> +integer library written entirely in C.  The library is designed 
>> to provide a
>
>s/The library is/It's/ IMO.
>
>> +simple to work with API
>
>‘simple-to-work-with API’, unfortunately.

I suggest:. ..an API that is simple to work with.
Efraim Flashner Feb. 24, 2019, 7:47 a.m. UTC | #3
On Sat, Feb 23, 2019 at 10:06:07AM +0100, swedebugia wrote:
> Tobias Geerinckx-Rice <somebody@not-sent-or-endorsed-by.tobias.gr> skrev: (22 februari 2019 19:57:25 CET)
> >Efraim,
> >
> >Thanks!
> >
> >Efraim Flashner wrote:
> 
> >
> >> +integer library written entirely in C.  The library is designed 
> >> to provide a
> >
> >s/The library is/It's/ IMO.
> >
> >> +simple to work with API
> >
> >‘simple-to-work-with API’, unfortunately.
> 
> I suggest:. ..an API that is simple to work with.
> 

This sounds good. I checked Debian's description¹ and it's much longer,
although they do manage to skip discussing the API.

¹ https://sources.debian.org/src/libtommath/1.1.0-3/debian/control/
Efraim Flashner Feb. 24, 2019, 7:50 a.m. UTC | #4
On Fri, Feb 22, 2019 at 07:57:25PM +0100, Tobias Geerinckx-Rice wrote:
> Efraim,
> 
> Thanks!
> 
> Efraim Flashner wrote:
> > * gnu/packages/algebra.scm (libtommath): New variable.
> 
> > + (add-after 'unpack 'prepare-build
> > +   (lambda _
> > +     ;; Don't pull in coreutils.
> > +     (substitute* "makefile_include.mk"
> > +       (("arch") "uname -m"))
> 
> I'd add an empty line here or separate this into two fases just to be very
> clear, since…
> 

Sounds good. I didn't want to toss in a couple of one-liner phases, so
I'll make it clearer.

> > +     (delete-file "makefile")
> > +     (symlink "makefile.shared" "makefile")
> > +     #t))
> 
> …I got a bit lost between all these makefiles.  Could you explain exactly
> what's going on?
> 
> Is this to avoid repeating ‘-f makefile.shared’ elsewhere?

Yeah, basically. Pkgsrc has a keyword to use makefile.shared and Debian
passes '-f makefile.shared' in all its phases, this seemed much eaiser.

> 
> > + (add-after 'check 'make-static
> 
> More accurate: 'install-static-library.

Sounds good

> 
> While libtommath.a is ‘only’ 332K, that's almost half of the entire output
> size.  Is it worth moving to a separate :static output?
> 

As far as size goes I decided against it since it is so small, but by
putting libtommath.a in a separate output it does prevent other packages
from picking up the wrong one. Sounds good.

> > + (synopsis "portable number theoretic multiple-precision integer
> > library")
> 
> s/p/P/
> 
> multiprecision.scm is a better fit and already has sister package
> tomsfastmath to keep this one company.

I didn't see that one. I'll stick it next to that one.

> 
> > +integer library written entirely in C.  The library is designed to
> > provide a
> 
> s/The library is/It's/ IMO.
> 
> > +simple to work with API
> 
> ‘simple-to-work-with API’, unfortunately.
> 
> Kind regards,
> 
> T G-R

Thanks

Patch

diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm
index f9ae22b3f3..98dc414ac5 100644
--- a/gnu/packages/algebra.scm
+++ b/gnu/packages/algebra.scm
@@ -4,7 +4,7 @@ 
 ;;; Copyright © 2016, 2017, 2018, 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2014, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2017, 2019 Eric Bavier <bavier@member.fsf.org>
@@ -1000,3 +1000,48 @@  objects.")
     ;; means that the gpl2+ licence of GAP itself applies, but to be on the
     ;; safe side, we drop them for now.
     (license license:gpl2+)))
+
+(define-public libtommath
+  (package
+    (name "libtommath")
+    (version "1.1.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append "https://github.com/libtom/libtommath/releases/"
+                            "download/v" version "/ltm-" version ".tar.xz"))
+        (sha256
+         (base32
+          "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
+        (patches (search-patches "libtommath-fix-linkage.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         (delete 'configure) ; no configure
+         (add-after 'unpack 'prepare-build
+           (lambda _
+             ;; Don't pull in coreutils.
+             (substitute* "makefile_include.mk"
+               (("arch") "uname -m"))
+             (delete-file "makefile")
+             (symlink "makefile.shared" "makefile")
+             #t))
+         (replace 'check
+           (lambda* (#:key make-flags #:allow-other-keys)
+             (apply invoke "make" "test_standalone" make-flags)
+             (invoke "sh" "test")))
+         (add-after 'check 'make-static
+           (lambda* (#:key make-flags #:allow-other-keys)
+             (apply invoke "make" "-f" "makefile.unix" "install" make-flags))))
+       #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
+                          "CC=gcc")))
+    (native-inputs
+     `(("libtool" ,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
+integer library written entirely in C.  The library is designed to provide a
+simple to work with API that provides fairly efficient routines that build out
+of the box without configuration.")
+    (license license:unlicense)))