summary refs log tree commit diff
path: root/gnu/packages
diff options
context:
space:
mode:
authorThomas Danckaert <post@thomasdanckaert.be>2017-08-24 11:00:59 +0200
committerThomas Danckaert <thomas.danckaert@gmail.com>2017-09-01 08:34:24 +0200
commite3a1a1deda03e52fbdb38e9c7a92ce69f78c8eb3 (patch)
tree441fe23102d055656ce5b77e32372ef0cdab2a2f /gnu/packages
parenta0596a2f27c339bcb4c5d3f2ffc8d6df38ff7947 (diff)
downloadguix-e3a1a1deda03e52fbdb38e9c7a92ce69f78c8eb3.tar.gz
gnu: hdf5: Add output for fortran interface.
* gnu/packages/maths.scm (hdf5) [native-inputs]: Add gfortran.
  [outputs]: Add "fortran".
  [arguments]: Enable Fortran compilation; add "/lib" directory of the fortran
  output to the runpath of the Fortran libs; add a 'split phase to move
  all Fortran-related files to the the Fortran output store location.
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/maths.scm53
1 files changed, 50 insertions, 3 deletions
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 7481636faa..b56153199b 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -648,16 +648,30 @@ incompatible with HDF5.")
     (build-system gnu-build-system)
     (inputs
      `(("zlib" ,zlib)))
+    (native-inputs
+     `(("gfortran" ,gfortran)))
+    (outputs '("out"       ; core library
+               "fortran")) ; fortran interface
     (arguments
      `(;; Some of the users, notably Flann, need the C++ interface.
-       #:configure-flags '("--enable-cxx")
+       #:configure-flags '("--enable-cxx"
+                           "--enable-fortran"
+                           "--enable-fortran2003")
 
        #:phases
        (modify-phases %standard-phases
          (add-before 'configure 'patch-configure
-           (lambda _
+           (lambda* (#:key outputs #:allow-other-keys)
              (substitute* "configure"
                (("/bin/mv") "mv"))
+             (substitute* "fortran/src/Makefile.in"
+               (("libhdf5_fortran_la_LDFLAGS =")
+                (string-append "libhdf5_fortran_la_LDFLAGS = -Wl-rpath="
+                               (assoc-ref outputs "fortran") "/lib")))
+             (substitute* "hl/fortran/src/Makefile.in"
+               (("libhdf5hl_fortran_la_LDFLAGS =")
+                (string-append "libhdf5hl_fortran_la_LDFLAGS = -Wl,-rpath="
+                               (assoc-ref outputs "fortran") "/lib")))
              #t))
          (add-after 'install 'patch-references
            (lambda* (#:key inputs outputs #:allow-other-keys)
@@ -666,7 +680,40 @@ incompatible with HDF5.")
                (substitute* (find-files bin "h5p?cc")
                  (("-lz" lib)
                   (string-append "-L" zlib "/lib " lib)))
-               #t))))))
+               #t)))
+         (add-after 'install 'split
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              ;; Move all fortran-related files
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin"))
+                     (lib (string-append out "/lib"))
+                     (inc (string-append out "/include"))
+                     (ex (string-append out "/share/hdf5_examples/fortran"))
+                     (fort (assoc-ref outputs "fortran"))
+                     (fbin (string-append fort "/bin"))
+                     (flib (string-append fort "/lib"))
+                     (finc (string-append fort "/include"))
+                     (fex (string-append fort "/share/hdf5_examples/fortran")))
+                (mkdir-p fbin)
+                (mkdir-p flib)
+                (mkdir-p finc)
+                (mkdir-p fex)
+                (rename-file (string-append bin "/h5fc")
+                             (string-append fbin "/h5fc"))
+                (for-each (lambda (file)
+                            (rename-file file
+                                         (string-append flib "/" (basename file))))
+                          (find-files lib ".*fortran.*"))
+                (for-each (lambda (file)
+                            (rename-file file
+                                         (string-append finc "/" (basename file))))
+                          (find-files inc ".*mod"))
+                (for-each (lambda (file)
+                            (rename-file file
+                                         (string-append fex "/" (basename file))))
+                          (find-files ex ".*"))
+                (delete-file-recursively ex))
+              #t)))))
     (home-page "http://www.hdfgroup.org")
     (synopsis "Management suite for extremely large and complex data")
     (description "HDF5 is a suite that makes possible the management of