diff mbox series

[bug#64114] gnu: fftw: Update to 3.3.10 and build entirely from source.

Message ID 9ae0d0f6a21a74fc0b36c52f23bbbd44b251d039.1686934712.git.david.elsing@posteo.net
State New
Headers show
Series [bug#64114] gnu: fftw: Update to 3.3.10 and build entirely from source. | expand

Commit Message

David Elsing June 16, 2023, 5:16 p.m. UTC
* gnu/packages/algebra.scm (fftw): Update to 3.3.10.
[source]: Use git checkout without autogenerated files.
[arguments]<#:configure-flags>: Use Gexps and set --enable-maintainer-mode.
<#:modules>: Add (ice-9 ftw) and (srfi srfi-26).
<#:phases>: Add phases to run the code generation and build documentation.
[native-inputs]: Add autoconf, automake, ghostscript, indent, libtool, ocaml,
ocamlbuild, ocaml-num, ocaml-findlib, texinfo and transfig.
(fftwf,fftw-openmpi)[arguments]: Use Gexps.
---
Hello,
I noticed that the FFTW release tarballs already contain the
autogenerated codelets and the built documentation. Building them of
course adds a lot more dependencies.
 gnu/packages/algebra.scm | 140 +++++++++++++++++++++++++++------------
 1 file changed, 98 insertions(+), 42 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm
index 3babf90b3c..ca5831066a 100644
--- a/gnu/packages/algebra.scm
+++ b/gnu/packages/algebra.scm
@@ -15,6 +15,7 @@ 
 ;;; Copyright © 2020, 2021, 2023 Vinicius Monego <monego@posteo.net>
 ;;; Copyright © 2021 Lars-Dominik Braun <ldb@leibniz-psychology.org>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,6 +39,7 @@  (define-module (gnu packages algebra)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages code)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cpp)
   #:use-module (gnu packages documentation)
@@ -45,6 +47,7 @@  (define-module (gnu packages algebra)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fltk)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages image)
@@ -63,6 +66,7 @@  (define-module (gnu packages algebra)
   #:use-module (gnu packages shells)
   #:use-module (gnu packages tex)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages xfig)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
@@ -737,39 +741,91 @@  (define-public kiss-fft-for-extempore
 (define-public fftw
   (package
     (name "fftw")
-    (version "3.3.8")
+    (version "3.3.10")
     (source (origin
-             (method url-fetch)
-             (uri (string-append "ftp://ftp.fftw.org/pub/fftw/fftw-"
-                                 version".tar.gz"))
-             (sha256
-              (base32
-               "00z3k8fq561wq2khssqg0kallk0504dzlx989x3vvicjdqpjc4v1"))))
+              ;; Release tarball contains many generated files
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/FFTW/fftw3")
+                    (commit (string-append "fftw-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "11r4kd1478mi35vv6fgmg6qibqkqjhb77pqxaa8374rxdlqazgyy"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:configure-flags
-       '("--enable-shared" "--enable-openmp" "--enable-threads"
-         ,@(let ((system (or (%current-target-system) (%current-system))))
-             ;; Enable SIMD extensions for codelets.  See details at:
-             ;; <http://fftw.org/fftw3_doc/Installation-on-Unix.html>.
-             (cond
-              ((string-prefix? "x86_64" system)
-               '("--enable-sse2" "--enable-avx" "--enable-avx2"
-                 "--enable-avx512" "--enable-avx-128-fma"))
-              ((string-prefix? "i686" system)
-               '("--enable-sse2"))
-              ((string-prefix? "aarch64" system)
-               ;; Note that fftw supports NEON on 32-bit ARM only when
-               ;; compiled for single-precision.
-               '("--enable-neon"))
-              (else
-               '())))
-         ;; By default '-mtune=native' is used.  However, that may cause the
-         ;; use of ISA extensions (e.g. AVX) that are not necessarily
-         ;; available on the user's machine when that package is built on a
-         ;; different machine.
-         "ax_cv_c_flags__mtune_native=no")))
-    (native-inputs (list perl))
+     (list
+      #:configure-flags
+      #~(list "--enable-shared"
+              "--enable-openmp"
+              "--enable-threads"
+              "--enable-maintainer-mode"
+              #$@(let ((system (or (%current-target-system) (%current-system))))
+                   ;; Enable SIMD extensions for codelets.  See details at:
+                   ;; <https://fftw.org/fftw3_doc/Installation-on-Unix.html>.
+                   (cond
+                    ((string-prefix? "x86_64" system)
+                     '("--enable-sse2" "--enable-avx" "--enable-avx2"
+                       "--enable-avx512" "--enable-avx-128-fma"))
+                    ((string-prefix? "i686" system)
+                     '("--enable-sse2"))
+                    ((string-prefix? "aarch64" system)
+                     ;; Note that fftw supports NEON on 32-bit ARM only when
+                     ;; compiled for single-precision.
+                     '("--enable-neon"))
+                    (else '())))
+              ;; By default '-mtune=native' is used.  However, that may cause the
+              ;; use of ISA extensions (e.g. AVX) that are not necessarily
+              ;; available on the user's machine when that package is built on a
+              ;; different machine.
+              "ax_cv_c_flags__mtune_native=no")
+      #:modules '((ice-9 ftw)
+                  (srfi srfi-26)
+                  (guix build utils)
+                  (guix build gnu-build-system))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'remove-bootstrap
+            (lambda _
+              ;; This script calls configure
+              (delete-file "bootstrap.sh")
+              (invoke "touch" "ChangeLog")
+              ;; OCaml Num library
+              (substitute* "genfft/Makefile.am"
+                ((",nums")
+                 " -package num"))))
+          (add-after 'build 'build-doc
+            (lambda _
+              ;; Reproducibility
+              (substitute* "doc/FAQ/m-html.pl"
+                (("- \\$html_date\\\\n") "")
+                (("\\$html_year \\$user_copyholder")
+                 "2022 $user_copyholder"))
+              (substitute* "doc/FAQ/fftw-faq.bfnn"
+                ((".*`date.*") ""))
+              (invoke "make" "-C" "doc")
+              (invoke "make" "-C" "doc" "html")
+              (invoke "make" "-C" "doc/FAQ" "faq")))
+          (add-after 'install 'install-doc
+            (let ((doc (string-append #$output "/share/doc/"
+                                      #$name "-" #$version)))
+              (lambda _
+                (copy-recursively "doc/html" (string-append doc "/html"))
+                (copy-recursively "doc/FAQ/fftw-faq.html"
+                                  (string-append doc "/fftw-faq.html"))
+                (install-file "doc/FAQ/fftw-faq.ascii" doc)))))))
+    (native-inputs (list autoconf
+                         automake
+                         ghostscript
+                         indent
+                         libtool
+                         ocaml
+                         ocamlbuild
+                         ocaml-num
+                         ocaml-findlib
+                         perl
+                         texinfo
+                         transfig))
     (home-page "https://fftw.org")
     (synopsis "Computing the discrete Fourier transform")
     (description
@@ -785,14 +841,14 @@  (define-public fftwf
     (arguments
      (substitute-keyword-arguments (package-arguments fftw)
        ((#:configure-flags fftw-configure-flags)
-        `(cons* "--enable-single"
-                ,@(if (string-prefix? "arm" (or (%current-target-system)
-                                                (%current-system)))
-                      ;; fftw supports NEON on 32-bit ARM only when compiled
-                      ;; for single-precision, so add it here.
-                      '("--enable-neon")
-                      '())
-                ,fftw-configure-flags))))
+        #~(cons* "--enable-single"
+                 #$@(if (string-prefix? "arm" (or (%current-target-system)
+                                                  (%current-system)))
+                        ;; fftw supports NEON on 32-bit ARM only when compiled
+                        ;; for single-precision, so add it here.
+                        '("--enable-neon")
+                        '())
+                 #$fftw-configure-flags))))
     (description
      (string-append (package-description fftw)
                     "  Single-precision version."))))
@@ -806,11 +862,11 @@  (define-public fftw-openmpi
     (arguments
      (substitute-keyword-arguments (package-arguments fftw)
        ((#:configure-flags cf)
-        `(cons "--enable-mpi" ,cf))
+        #~(cons "--enable-mpi" #$cf))
        ((#:phases phases '%standard-phases)
-        `(modify-phases ,phases
-           (add-before 'check 'mpi-setup
-             ,%openmpi-setup)))))
+        #~(modify-phases #$phases
+            (add-before 'check 'mpi-setup
+              #$%openmpi-setup)))))
     (description
      (string-append (package-description fftw)
                     "  With OpenMPI parallelism support."))))