Patchwork gnu: Add hdf4

login
register
mail settings
Submitter Thomas Danckaert
Date Oct. 12, 2016, 6:50 p.m.
Message ID <20161012.205046.1873161880859659372.post@thomasdanckaert.be>
Download mbox | patch
Permalink /patch/16448/
State New
Headers show

Comments

Thomas Danckaert - Oct. 12, 2016, 6:50 p.m.
From: ludo@gnu.org (Ludovic Courtès)

Subject: Re: [PATCH] gnu: Add hdf4
Date: Wed, 12 Oct 2016 14:54:40 +0200

>>  - I've also added a variant “hdf4-alt”: by default, HDF4 includes 

>> a

>>    netCDF API to access HDF4 files, which clashes with the symbols 

>> in

>>    the real netCDF library when you try to use both libraries in 

>> your

>>    program.  This variant uses the “--disable-netcdf” configure 

>> flag

>>    to avoid this.  We could call it “hdf4-nonetcdf”, but the name

>>    “hdf4-alt” is used by Debian, so maybe it's good to use the 

>> same?

>

> Would “hdf4-minimal” sound appropriate here?  That’s a convention 

> we use

> in similar cases.  Otherwise “hdf4-alt” is fine with me.


With --disable-netcdf, the library still includes all the same 
features, the netCDF API function names are just mangled to avoid 
conflicts.  So it's not really more “minimal” than the regular HDF4 
:-)  I'd either go for something that explicitly mentions netCDF, or 
hdf4-alt because that's what Debian uses.

>> +             (substitute*

>> +                 (map (lambda (dir) (string-append dir 

>> "/Makefile.in"))

>> +                      '("hdf" "hdf/examples" "hdf/fortran" 

>> "hdf/src"

>> +                        "hdf/test" "hdf/util" "mfhdf" 

>> "mfhdf/dumper"

>> +                        "mfhdf/examples" "mfhdf/fortran" 

>> "mfhdf/hdfimport"

>> +                        "mfhdf/hdiff" "mfhdf/hrepack" 

>> "mfhdf/libsrc"

>> +                        "mfhdf/ncgen" "mfhdf/ncdump" 

>> "mfhdf/nctest"

>> +                        "mfhdf/test" "mfhdf/xdr"))

>

> Maybe simply (find-files "." "^Makefile\\.in$")?


Yes, I was convinced something like that had to exist, but am not 
good at reading the docs, it seems.

> - CONFIG_DATE="`date`"

> + CONFIG_DATE="$SOURCE_DATE_EPOCH"

>

> The smaller the patch, the better.  :-)


I went with

+CONFIG_DATE=`date -u -d "@$SOURCE_DATE_EPOCH"`

(which just results in 1 Jan 1970, but anyway)

cheers,

Thomas
Ludovic Courtès - Oct. 12, 2016, 8:28 p.m.
Thomas Danckaert <post@thomasdanckaert.be> skribis:

>> Would “hdf4-minimal” sound appropriate here?  That’s a convention we
>> use
>> in similar cases.  Otherwise “hdf4-alt” is fine with me.
>
> With --disable-netcdf, the library still includes all the same
> features, the netCDF API function names are just mangled to avoid
> conflicts.  So it's not really more “minimal” than the regular HDF4
> :-)  I'd either go for something that explicitly mentions netCDF, or
> hdf4-alt because that's what Debian uses.

Works for me!

> From 3778ec2dfea4e5d7c0712ae1d354b463c8ee6694 Mon Sep 17 00:00:00 2001
> From: Thomas Danckaert <thomas.danckaert@gmail.com>
> Date: Wed, 28 Sep 2016 10:34:58 +0200
> Subject: [PATCH] gnu: Add hdf4
>
> * gnu/packages/maths.scm (hdf4, hdf4-alt): New variables.
> * gnu/packages/patches/hdf4-reproducibility.patch: New file.
> * gnu/packages/patches/hdf4-shared-fortran.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add patches.
>
> Co-Authored-By: Jeremy Robst <jpro@bas.ac.uk>

Applied, thanks!

Ludo’.
Andreas Enge - Oct. 14, 2016, 8:11 a.m.
Hello,

the packages fail to compile on arm and mips:
   http://hydra.gnu.org/eval/109281#tabs-new
   http://hydra.gnu.org/build/1521682

Could you maybe have a look at them?

Thanks!

Andreas
Thomas Danckaert - Oct. 14, 2016, 11:13 a.m.
From: Andreas Enge <andreas@enge.fr>
Subject: Re: [PATCH] gnu: Add hdf4
Date: Fri, 14 Oct 2016 10:11:45 +0200

> Hello,
>
> the packages fail to compile on arm and mips:
>    http://hydra.gnu.org/eval/109281#tabs-new
>    http://hydra.gnu.org/build/1521682

Hi,

as far as I understand, the header hdfi.h defines fixed width 
datatypes such as float64, uint8, int32, ... depending on the 
detected architecture, and it's not detecting mips and arm properly.

I've checked, and see that Debian has a number patches for this and 
related issues, but I'm a bit out of my depth here (and don't have 
arm or mips systems to test before submitting any patches).  What are 
the options?  It would take me quite a bit of time to understand the 
Debian patches and see what we need.

Ideally, HDF4 maintainers would fix this in a future release.  I can 
try to contact them.

cheers,

Thomas
Andreas Enge - Oct. 16, 2016, 3:05 p.m.
Hi Thomas,

On Fri, Oct 14, 2016 at 11:00:29AM +0200, Thomas Danckaert wrote:
> as far as I understand, the header hdfi.h defines fixed width datatypes such
> as float64, uint8, int32, ... depending on the detected architecture, and
> it's not detecting mips and arm properly.
> 
> I've checked, and see that Debian has a number patches for this and related
> issues

thanks for your comments! I picked a (rather large) patch from Debian
modifying hdfi.h, and the package now builds on arm. I pushed this, and
we will see for mips once hydra tries to build it (there is also a mips
specific patch on debian).

> Ideally, HDF4 maintainers would fix this in a future release.  I can try to
> contact them.

That would be nice, assuming that hdf4 is still maintained.

Andreas

Patch

From 3778ec2dfea4e5d7c0712ae1d354b463c8ee6694 Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <thomas.danckaert@gmail.com>
Date: Wed, 28 Sep 2016 10:34:58 +0200
Subject: [PATCH] gnu: Add hdf4

* gnu/packages/maths.scm (hdf4, hdf4-alt): New variables.
* gnu/packages/patches/hdf4-reproducibility.patch: New file.
* gnu/packages/patches/hdf4-shared-fortran.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add patches.

Co-Authored-By: Jeremy Robst <jpro@bas.ac.uk>
---
 gnu/local.mk                                    |  2 +
 gnu/packages/maths.scm                          | 59 +++++++++++++++++++++++++
 gnu/packages/patches/hdf4-reproducibility.patch | 35 +++++++++++++++
 gnu/packages/patches/hdf4-shared-fortran.patch  | 25 +++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 gnu/packages/patches/hdf4-reproducibility.patch
 create mode 100644 gnu/packages/patches/hdf4-shared-fortran.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 1ce95f2..1b65e74 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -570,6 +570,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/gtk3-respect-GUIX_GTK3_PATH.patch	\
   %D%/packages/patches/gtk3-respect-GUIX_GTK3_IM_MODULE_FILE.patch \
   %D%/packages/patches/gtkglext-disable-disable-deprecated.patch \
+  %D%/packages/patches/hdf4-shared-fortran.patch 		\
+  %D%/packages/patches/hdf4-reproducibility.patch 		\
   %D%/packages/patches/hdf5-config-date.patch			\
   %D%/packages/patches/hdf-eos5-build-shared.patch 		\
   %D%/packages/patches/hdf-eos5-remove-gctp.patch		\
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index d5e82bb..07934e3 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -445,6 +445,65 @@  computations.")
     (home-page "https://github.com/OkoSanto/GCTP")
     (license license:public-domain))) ;https://www2.usgs.gov/laws/info_policies.html
 
+(define-public hdf4
+  (package
+    (name "hdf4")
+    (version "4.2.11")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://support.hdfgroup.org/ftp/HDF/releases/HDF"
+                           version "/src/hdf-" version ".tar.bz2"))
+       (sha256
+        (base32 "16yr50j845zlfx20skmw3y75ww77akk9gg0affjqkg66ih5r03mv"))
+       (patches (search-patches "hdf4-reproducibility.patch"
+                                "hdf4-shared-fortran.patch"))))
+
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("gfortran" ,gfortran)
+       ("bison" ,bison)
+       ("flex" ,flex)))
+    (inputs
+     `(("zlib" ,zlib)
+       ("libjpeg" ,libjpeg)))
+    (arguments
+     `(#:parallel-tests? #f
+       #:configure-flags '("--enable-shared")
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'patchbuild
+           (lambda _
+             (substitute*
+                 '("mfhdf/hdfimport/testutil.sh.in" "hdf/util/testutil.sh.in")
+               (("/bin/rm") "rm")
+               (("/bin/mkdir") "mkdir"))
+             (substitute* (find-files "." "^Makefile\\.in$")
+               (("@HDF_BUILD_XDR_TRUE@XDR_ADD = \
+-R\\$\\(abs_top_builddir\\)/mfhdf/xdr/\\.libs") "")
+               (("@HDF_BUILD_SHARED_TRUE@AM_LDFLAGS = \
+-R\\$\\(abs_top_builddir\\)/mfhdf/libsrc/\\.libs \
+-R\\$\\(abs_top_builddir\\)/hdf/src/\\.libs \\$\\(XDR_ADD\\)") "")))))))
+    (home-page "https://www.hdfgroup.org/products/hdf4/")
+    (synopsis
+     "Library and multi-object file format for storing and managing data")
+    (description "HDF4 is a library and multi-object file format for storing
+and managing data between machines.  HDF4 is an older hierarchical data format,
+incompatible with HDF5.")
+    (license
+     (license:non-copyleft
+      "https://www.hdfgroup.org/ftp/HDF/HDF_Current/src/unpacked/COPYING"))))
+
+(define-public hdf4-alt
+  (package
+    (inherit hdf4)
+    (name "hdf4-alt")
+    (arguments
+     (substitute-keyword-arguments (package-arguments hdf4)
+       ((#:configure-flags flags) `(cons* "--disable-netcdf" ,flags))))
+    (synopsis
+     "HDF4 without netCDF API, can be combined with the regular netCDF library")))
+
 (define-public hdf5
   (package
     (name "hdf5")
diff --git a/gnu/packages/patches/hdf4-reproducibility.patch b/gnu/packages/patches/hdf4-reproducibility.patch
new file mode 100644
index 0000000..9b5fea6
--- /dev/null
+++ b/gnu/packages/patches/hdf4-reproducibility.patch
@@ -0,0 +1,35 @@ 
+Remove/patch unreproducible config data.
+
+diff --git a/configure b/configure
+index eb9f346..ebab94d 100755
+--- a/configure
++++ b/configure
+@@ -23163,7 +23163,7 @@ H4_VERSION="`cut -d' ' -f3 $srcdir/README.txt | head -1`"
+ 
+ 
+ ## Configuration date
+- CONFIG_DATE="`date`"
++CONFIG_DATE=`date -u -d "@$SOURCE_DATE_EPOCH"`
+ 
+ ## User doing the configuration
+  CONFIG_USER="`whoami`@`hostname`"
+diff --git a/libhdf4.settings.in b/libhdf4.settings.in
+index 1d9bbb9..4180d72 100644
+--- a/libhdf4.settings.in
++++ b/libhdf4.settings.in
+@@ -5,10 +5,10 @@ General Information:
+ -------------------
+ 		   HDF4 Version: @H4_VERSION@
+ 		  Configured on: @CONFIG_DATE@
+-		  Configured by: @CONFIG_USER@
++		  Configured by: guix
+ 		 Configure mode: @CONFIG_MODE@
+-		    Host system: @host_cpu@-@host_vendor@-@host_os@
+-              Uname information: @UNAME_INFO@
++		    Host system: guix
++              Uname information: guix
+ 		      Libraries: @STATIC_SHARED@
+ 	     Installation point: @prefix@
+ 
+-- 
+2.10.0
diff --git a/gnu/packages/patches/hdf4-shared-fortran.patch b/gnu/packages/patches/hdf4-shared-fortran.patch
new file mode 100644
index 0000000..60db355
--- /dev/null
+++ b/gnu/packages/patches/hdf4-shared-fortran.patch
@@ -0,0 +1,25 @@ 
+Allow building a shared library with Fortran.
+---
+ configure | 6 ------
+ 1 file changed, 6 deletions(-)
+
+diff --git a/configure b/configure
+index f37d2fa..eb9f346 100755
+--- a/configure
++++ b/configure
+@@ -6141,12 +6141,6 @@ if test "X${enable_shared}" != "Xyes"; then
+     enable_shared="no"
+ fi
+ 
+-if test "X${enable_shared}" = "Xyes"; then
+-    if test "X${BUILD_FORTRAN}" = "Xyes"; then
+-        as_fn_error $? "Cannot build shared fortran libraries. Please configure with --disable-fortran flag." "$LINENO" 5
+-    fi
+-fi
+-
+ 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+ $as_echo_n "checking whether ln -s works... " >&6; }
+-- 
+2.10.0
+
-- 
2.10.0