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