Subject: [bug#64114] [PATCH v2 2/2] gnu: Add fftw-documentation.

From: David Elsing <[email-masked]>
Date: Sun, 26 Jan 2025 16:54:33 +0000

* gnu/packages/algebra.scm (fftw-documentation): New variable.
---
 gnu/packages/algebra.scm | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gnu/packages/algebra.scm b/gnu/packages/algebra.scm
index 96f9b36a0e..56fc90b518 100644
--- a/gnu/packages/algebra.scm
+++ b/gnu/packages/algebra.scm
@@ -799,6 +799,48 @@ (define-public fftw
 cosine/ sine transforms or DCT/DST).")
     (license license:gpl2+)))
 
+;; Separate package to prevent dependency cycle
+(define-public fftw-documentation
+  (package/inherit fftw
+    (name "fftw-documentation")
+    (arguments
+     (substitute-keyword-arguments (package-arguments fftw)
+       ((#:tests? _ #f) #f)
+       ((#:phases phases '%standard-phases)
+        #~(modify-phases #$phases
+            (replace 'build
+              (lambda _
+                ;; Reproducibility
+                (substitute* "doc/FAQ/m-html.pl"
+                  (("- \\$html_date\\\\n") "")
+                  (("\\$html_year \\$user_copyholder")
+                   "2021 $user_copyholder"))
+                (substitute* "doc/FAQ/fftw-faq.bfnn"
+                  ((".*`date.*") ""))
+                (invoke "make" "-C" "doc")
+                (invoke "make" "-C" "doc" "html")
+                (invoke "make" "-C" "doc/FAQ" "faq")))
+            (replace 'install
+              (let ((doc (string-append #$output "/share/doc/"
+                                        #$(package-name this-package) "-"
+                                        #$(package-version this-package))))
+                (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
+     (modify-inputs (package-native-inputs fftw)
+       (prepend ghostscript texinfo fig2dev)))
+    (home-page "https://fftw.org")
+    (synopsis "Computing the discrete Fourier transform")
+    (description
+     "FFTW is a C subroutine library for computing the discrete Fourier
+transform (DFT) in one or more dimensions, of arbitrary input size, and of
+both real and complex data (as well as of even/odd data---i.e. the discrete
+cosine/ sine transforms or DCT/DST).")
+    (license license:gpl2+)))
+
 (define-public fftw-cmake
   (package/inherit fftw
     ;; Cmake compiling is experimental since 2017, and it is not clear if this
-- 
2.46.0