diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/hdf5/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/hdf5/package.py | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py index f26e225b83..cae46d3301 100644 --- a/var/spack/repos/builtin/packages/hdf5/package.py +++ b/var/spack/repos/builtin/packages/hdf5/package.py @@ -24,6 +24,7 @@ ############################################################################## from spack import * +import shutil class Hdf5(Package): @@ -38,7 +39,7 @@ class Hdf5(Package): list_depth = 3 version('1.10.0', 'bdc935337ee8282579cd6bc4270ad199') - version('1.8.16', 'b8ed9a36ae142317f88b0c7ef4b9c618') + version('1.8.16', 'b8ed9a36ae142317f88b0c7ef4b9c618', preferred=True) version('1.8.15', '03cccb5b33dbe975fdcd8ae9dc021f24') version('1.8.13', 'c03426e9e77d7766944654280b467289') @@ -101,10 +102,10 @@ class Hdf5(Package): extra_args.append('--enable-cxx') if '+fortran' in spec: - extra_args.extend([ - '--enable-fortran', - '--enable-fortran2003' - ]) + extra_args.append('--enable-fortran') + # '--enable-fortran2003' no longer exists as of version 1.10.0 + if spec.satisfies('@:1.8.16'): + extra_args.append('--enable-fortran2003') if '+mpi' in spec: # The HDF5 configure script warns if cxx and mpi are enabled @@ -114,14 +115,16 @@ class Hdf5(Package): # this is not actually a problem. extra_args.extend([ "--enable-parallel", - "CC=%s" % spec['mpi'].prefix.bin + "/mpicc", + "CC=%s" % join_path(spec['mpi'].prefix.bin, "mpicc"), ]) if '+cxx' in spec: - extra_args.append("CXX=%s" % spec['mpi'].prefix.bin + "/mpic++") + extra_args.append("CXX=%s" % join_path(spec['mpi'].prefix.bin, + "mpic++")) if '+fortran' in spec: - extra_args.append("FC=%s" % spec['mpi'].prefix.bin + "/mpifort") + extra_args.append("FC=%s" % join_path(spec['mpi'].prefix.bin, + "mpifort")) if '+szip' in spec: extra_args.append("--with-szlib=%s" % spec['szip'].prefix) @@ -138,6 +141,58 @@ class Hdf5(Package): *extra_args) make() make("install") + self.check_install(spec) + + def check_install(self, spec): + "Build and run a small program to test the installed HDF5 library" + print "Checking HDF5 installation..." + checkdir = "spack-check" + with working_dir(checkdir, create=True): + source = r""" +#include <hdf5.h> +#include <assert.h> +#include <stdio.h> +int main(int argc, char **argv) { + unsigned majnum, minnum, relnum; + herr_t herr = H5get_libversion(&majnum, &minnum, &relnum); + assert(!herr); + printf("HDF5 version %d.%d.%d %u.%u.%u\n", H5_VERS_MAJOR, H5_VERS_MINOR, + H5_VERS_RELEASE, majnum, minnum, relnum); + return 0; +} +""" + expected = """\ +HDF5 version {version} {version} +""".format(version=str(spec.version)) + with open("check.c", 'w') as f: + f.write(source) + if '+mpi' in spec: + cc = which(join_path(spec['mpi'].prefix.bin, "mpicc")) + else: + cc = which('cc') + # TODO: Automate these path and library settings + cc('-c', "-I%s" % join_path(spec.prefix, "include"), "check.c") + cc('-o', "check", "check.o", + "-L%s" % join_path(spec.prefix, "lib"), "-lhdf5", + "-lz") + try: + check = Executable('./check') + output = check(return_output=True) + except: + output = "" + success = output == expected + if not success: + print "Produced output does not match expected output." + print "Expected output:" + print '-'*80 + print expected + print '-'*80 + print "Produced output:" + print '-'*80 + print output + print '-'*80 + raise RuntimeError("HDF5 install check failed") + shutil.rmtree(checkdir) def url_for_version(self, version): v = str(version) |