@@ -0,0 +1,76 @@
1+{ stdenv
2+, fetchurl
3+, gcc
4+, removeReferencesTo
5+, cpp ? false
6+, gfortran ? null
7+, fortran2003 ? false
8+, zlib ? null
9+, szip ? null
10+, mpi ? null
11+, enableShared ? true
12+}:
13+
14+# cpp and mpi options are mutually exclusive
15+# (--enable-unsupported could be used to force the build)
16+assert !cpp || mpi == null;
17+
18+# Need a Fortran compiler for Fortran2003 bindings
19+assert fortran2003 -> gfortran != null;
20+
21+# No point splitting version 1.8.18 into multiple outputs.
22+# The library /lib/libhdf5.so has a reference to gcc-wrapper
23+
24+let inherit (stdenv.lib) optional optionals; in
25+
26+stdenv.mkDerivation rec {
27+ version = "1.8.19";
28+ name = "hdf5-${version}";
29+ src = fetchurl {
30+ url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/${name}/src/${name}.tar.bz2";
31+ sha256 = "0f3jfbqpaaq21ighi40qzs52nb52kc2d2yjk541rjmsx20b3ih2r" ;
32+ };
33+
34+ passthru = {
35+ mpiSupport = (mpi != null);
36+ inherit mpi;
37+ };
38+
39+ nativeBuildInputs = [ removeReferencesTo ];
40+
41+ buildInputs = []
42+ ++ optional (gfortran != null) gfortran
43+ ++ optional (szip != null) szip;
44+
45+ propagatedBuildInputs = []
46+ ++ optional (zlib != null) zlib
47+ ++ optional (mpi != null) mpi;
48+
49+ configureFlags = []
50+ ++ optional cpp "--enable-cxx"
51+ ++ optional (gfortran != null) "--enable-fortran"
52+ ++ optional fortran2003 "--enable-fortran2003"
53+ ++ optional (szip != null) "--with-szlib=${szip}"
54+ ++ optionals (mpi != null) ["--enable-parallel" "CC=${mpi}/bin/mpicc"]
55+ ++ optional enableShared "--enable-shared";
56+
57+ patches = [./bin-mv.patch];
58+
59+ postInstall = ''
60+ find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
61+ '';
62+
63+ meta = {
64+ description = "Data model, library, and file format for storing and managing data";
65+ longDescription = ''
66+ HDF5 supports an unlimited variety of datatypes, and is designed for flexible and efficient
67+ I/O and for high volume and complex data. HDF5 is portable and is extensible, allowing
68+ applications to evolve in their use of HDF5. The HDF5 Technology suite includes tools and
69+ applications for managing, manipulating, viewing, and analyzing data in the HDF5 format.
70+ '';
71+ license = stdenv.lib.licenses.free; # BSD-like
72+ homepage = https://www.hdfgroup.org/HDF5/;
73+ platforms = stdenv.lib.platforms.unix;
74+ broken = (gfortran != null) && stdenv.isDarwin;
75+ };
76+}