Subject: [bug#73399] [PATCH 18/26] gnu: Add healpix.

From: Sharlatan Hellseher <[email-masked]>
Date: Sat, 21 Sep 2024 00:31:43 +0100

* gnu/packages/astronomy.scm (healpix): New variable.

Change-Id: I41dcee1ba9df1988dd9c4ee40b07daab5418e001
---
 gnu/packages/astronomy.scm | 62 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm
index 6fab4491d6..3f1b70196a 100644
--- a/gnu/packages/astronomy.scm
+++ b/gnu/packages/astronomy.scm
@@ -111,6 +111,7 @@ (define-module (gnu packages astronomy)
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
   #:use-module (srfi srfi-1))
 
 (define-public alfa
@@ -586,6 +587,67 @@ (define-public cfitsio
     (license (license:non-copyleft "file://License.txt"
                                    "See License.txt in the distribution."))))
 
+(define* (healpix-source #:key version sha256-base32-hash)
+    ;; The sources of HEALPix containing 6 independent packages (Fortran90,
+    ;; IDL, C, C++, java and python) and distributed togather libsharp.
+     (origin
+       (method url-fetch)
+       (uri
+        (let* ((name "Healpix")
+               (version-list (string-split version #\.))
+               (name+version (format #f "~a_~{~a.~a~a~}" name version-list)))
+          (string-append "mirror://sourceforge/healpix/"
+                         name+version "/" name+version "_" "2022Jul28.tar.gz")))
+       (sha256
+        (base32 sha256-base32-hash ))))
+
+(define-public healpix
+  (package
+    (name "healpix")
+    (version "3.8.2")
+    (source
+     (healpix-source
+      #:version version
+      #:sha256-base32-hash "09x1lafq01gzk16yvmz2pdhrxnqfjp3b2p9hlgy0dbrdg82ryqj7"))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:tests? #f ; no tests
+      #:make-flags
+      #~(list "shared"
+              "AR=ar -rsv"
+              "OPT=-O2 -Wall"
+              "PIC=-fPIC"
+              (string-append "CC=" #$(cc-for-target))
+              (string-append "CFITSIO_INCDIR="
+                             #$(this-package-input "cfitsio") "/include")
+              (string-append "CFITSIO_LIBDIR="
+                             #$(this-package-input "cfitsio") "/lib")
+              (string-append "INCDIR=" #$output "/include")
+              (string-append "LIBDIR=" #$output "/lib"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure) ; no configure
+          (add-after 'unpack 'chdir-c
+            (lambda _
+              (chdir "src/C/subs")))
+          (add-before 'install 'set-output-directories
+            (lambda _
+              (mkdir-p (string-append #$output "/include"))
+              (mkdir-p (string-append #$output "/lib")))))))
+    (native-inputs
+     (list pkg-config autoconf automake))
+    (inputs
+     (list cfitsio))
+    (home-page "https://healpix.jpl.nasa.gov/")
+    (synopsis "Representation of spherical data")
+    (description
+     "@acronym{HEALPix, Hierarchical Equal Area isoLatitude Pixelation} of a
+sphere produces a subdivision of a spherical surface in which each pixel
+covers the same surface area as every other pixel.  This package provides the
+dynamic library for the C language implementation of HEALPix.")
+    (license license:gpl2+)))
+
 (define-public erfa
   (package
     (name "erfa")
-- 
2.46.0