1{ stdenv
2, fetchurl
3, cmake
4, libjpeg
5, zlib
6, szip ? null
7}:
8
9stdenv.mkDerivation rec {
10 name = "hdf-${version}";
11 version = "4.2.12";
12 src = fetchurl {
13 url = "https://support.hdfgroup.org/ftp/HDF/releases/HDF${version}/src/hdf-${version}.tar.bz2";
14 sha256 = "020jh563sjyxsgml8l809d2i1d4ms9shivwj3gbm7n0ilxbll8id";
15 };
16
17 buildInputs = [
18 cmake
19 libjpeg
20 szip
21 zlib
22 ];
23
24 preConfigure = stdenv.lib.optionalString (szip != null) "export SZIP_INSTALL=${szip}";
25
26 cmakeFlags = [
27 "-DBUILD_SHARED_LIBS=ON"
28 "-DBUILD_TESTING=ON"
29 "-DHDF4_BUILD_TOOLS=ON"
30 "-DHDF4_BUILD_UTILS=ON"
31 "-DHDF4_BUILD_WITH_INSTALL_NAME=OFF"
32 "-DHDF4_ENABLE_JPEG_LIB_SUPPORT=ON"
33 "-DHDF4_ENABLE_NETCDF=OFF"
34 "-DHDF4_ENABLE_Z_LIB_SUPPORT=ON"
35 "-DHDF4_BUILD_FORTRAN=OFF"
36 "-DJPEG_DIR=${libjpeg}"
37 ] ++ stdenv.lib.optionals (szip != null) [
38 "-DHDF4_ENABLE_SZIP_ENCODING=ON"
39 "-DHDF4_ENABLE_SZIP_SUPPORT=ON"
40 ];
41
42 doCheck = true;
43
44 preCheck = ''
45 export LD_LIBRARY_PATH=$(pwd)/bin
46 '' + stdenv.lib.optionalString (stdenv.isDarwin) ''
47 export DYLD_LIBRARY_PATH=$(pwd)/bin
48 '';
49
50 excludedTests = [
51 "MFHDF_TEST-hdftest"
52 "MFHDF_TEST-hdftest-shared"
53 "HDP-dumpsds-18"
54 "NC_TEST-nctest"
55 ];
56
57 checkPhase = let excludedTestsRegex = if (excludedTests != [])
58 then "(" + (stdenv.lib.concatStringsSep "|" excludedTests) + ")"
59 else ""; in ''
60 runHook preCheck
61 ctest -E "${excludedTestsRegex}" --output-on-failure
62 runHook postCheck
63 '';
64
65 outputs = [ "bin" "dev" "out" ];
66
67 postInstall = ''
68 moveToOutput bin "$bin"
69 '';
70
71 meta = {
72 description = "Data model, library, and file format for storing and managing data";
73 homepage = https://support.hdfgroup.org/products/hdf4/;
74 maintainers = with stdenv.lib.maintainers; [ knedlsepp ];
75 platforms = stdenv.lib.platforms.unix;
76 };
77}