* [bug#28214] [PATCH] gnu: hdf5: Add output for Fortran interface.
@ 2017-08-24 9:53 Thomas Danckaert
2017-08-31 12:56 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Danckaert @ 2017-08-24 9:53 UTC (permalink / raw)
To: 28214
[-- Attachment #1: Type: Text/Plain, Size: 196 bytes --]
Hi Guix,
this patch adds the Fortran interface as a separate output to the
hdf5 package.
It also considerably reduces the footprint of the hdf5 package, by
removing references to gcc.
Thomas
[-- Attachment #2: 0001-gnu-hdf5-Add-output-for-fortran-interface.patch --]
[-- Type: Text/X-Patch, Size: 5372 bytes --]
From ea5b67230713bf79d625743eb18f57bf36d40407 Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <post@thomasdanckaert.be>
Date: Thu, 24 Aug 2017 11:00:59 +0200
Subject: [PATCH] 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; patch "libhdf5.settings" to
remove references to the C/C++/Fortran compilers; add a 'split phase to move
all Fortran-related files to the the Fortran output store location.
---
gnu/packages/maths.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 64 insertions(+), 3 deletions(-)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index d1651e5a7..5306daa14 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -648,16 +648,44 @@ 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 'configure 'patch-settings
+ (lambda _
+ ;; libhdf5.settings contains the full path of the
+ ;; compilers used, and its contents are included in
+ ;; libhdf5.so. We truncate the hashes to avoid
+ ;; unnecessary store references to those compilers:
+ (substitute* "src/libhdf5.settings"
+ (("(Fortran Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
+ (string-append prefix (string-take hash 10) "..."))
+ (("(C Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
+ (string-append prefix (string-take hash 10) "..."))
+ (("(C\\+\\+ Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
+ (string-append prefix (string-take hash 10) "...")))
#t))
(add-after 'install 'patch-references
(lambda* (#:key inputs outputs #:allow-other-keys)
@@ -666,7 +694,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
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [bug#28214] [PATCH] gnu: hdf5: Add output for Fortran interface.
2017-08-24 9:53 [bug#28214] [PATCH] gnu: hdf5: Add output for Fortran interface Thomas Danckaert
@ 2017-08-31 12:56 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-08-31 12:56 UTC (permalink / raw)
To: Thomas Danckaert; +Cc: 28214
Hi Thomas,
Thomas Danckaert <post@thomasdanckaert.be> skribis:
> From ea5b67230713bf79d625743eb18f57bf36d40407 Mon Sep 17 00:00:00 2001
> From: Thomas Danckaert <post@thomasdanckaert.be>
> Date: Thu, 24 Aug 2017 11:00:59 +0200
> Subject: [PATCH] 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; patch "libhdf5.settings" to
> remove references to the C/C++/Fortran compilers; add a 'split phase to move
> all Fortran-related files to the the Fortran output store location.
[...]
> + (add-after 'configure 'patch-settings
> + (lambda _
> + ;; libhdf5.settings contains the full path of the
> + ;; compilers used, and its contents are included in
> + ;; libhdf5.so. We truncate the hashes to avoid
> + ;; unnecessary store references to those compilers:
> + (substitute* "src/libhdf5.settings"
> + (("(Fortran Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
> + (string-append prefix (string-take hash 10) "..."))
> + (("(C Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
> + (string-append prefix (string-take hash 10) "..."))
> + (("(C\\+\\+ Compiler: /gnu/store/)([a-Z0-9]*)" all prefix hash)
> + (string-append prefix (string-take hash 10) "...")))
Nice trick with the ellipses. :-)
How about making it two patches: one that adds this ‘patch-settings’
phase, and one that does the Fortran thing?
Apart from that it LGTM!
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-31 12:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 9:53 [bug#28214] [PATCH] gnu: hdf5: Add output for Fortran interface Thomas Danckaert
2017-08-31 12:56 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.