Subject: Re: [PATCH 07/11] gnu: Add freesasa.

From: Liliana Marie Prikler <[email-masked]>
Date: Tue, 04 Oct 2022 10:02:29 +0200

Am Montag, dem 03.10.2022 um 00:19 +0000 schrieb David Elsing:
> * gnu/packages/chemistry.scm (freesasa): New variable.
> ---
>  gnu/packages/chemistry.scm | 81
> ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 81 insertions(+)
> 
> diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm
> index f8fd85814f..223a27a20d 100644
> --- a/gnu/packages/chemistry.scm
> +++ b/gnu/packages/chemistry.scm
> @@ -34,11 +34,13 @@ (define-module (gnu packages chemistry)
>    #:use-module (gnu packages algebra)
>    #:use-module (gnu packages autotools)
>    #:use-module (gnu packages backup)
> +  #:use-module (gnu packages bison)
>    #:use-module (gnu packages boost)
>    #:use-module (gnu packages check)
>    #:use-module (gnu packages compression)
>    #:use-module (gnu packages cpp)
>    #:use-module (gnu packages documentation)
> +  #:use-module (gnu packages flex)
>    #:use-module (gnu packages fontutils)
>    #:use-module (gnu packages gl)
>    #:use-module (gnu packages graphviz)
> @@ -54,6 +56,7 @@ (define-module (gnu packages chemistry)
>    #:use-module (gnu packages serialization)
>    #:use-module (gnu packages sphinx)
>    #:use-module (gnu packages stb)
> +  #:use-module (gnu packages web)
>    #:use-module (gnu packages xml)
>    #:use-module (guix build-system cmake)
>    #:use-module (guix build-system copy)
> @@ -688,3 +691,81 @@ (define-public gemmi
>  @item crystallographic symmetry.
>  @end enumerate")
>      (license license:mpl2.0)))
> +
> +(define-public freesasa
> +  (package
> +    (name "freesasa")
> +    (version "2.1.2")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/mittinatten/freesasa")
> +                    (commit version)))
> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +               
> "07wdnahf3g355ryaiqvfxd5f4rl54wv8jwxcbn0nia89fqysbv0f"))
> +              (modules '((guix build utils)))
> +              (snippet
> +               '(begin
> +                  ;; Remove C files generated by Flex and Bison
> +                  (for-each delete-file
> +                            '("src/parser.c" "src/parser.h"
> +                              "src/lexer.c" "src/lexer.h"))
> +                  #t))))
> +    (build-system gnu-build-system)
> +    (inputs
> +     (list gemmi json-c libxml2))
> +    (native-inputs
> +     (list bison flex check autoconf automake pkg-config doxygen
> perl libtool))
> +    (outputs '("out" "doc"))
> +    (arguments
> +     (list
> +      #:configure-flags
> +      #~(list "--enable-check"
> +              "--enable-parser-generator"
> +              "CXXFLAGS=-std=c++17"
> +              "--enable-doxygen")
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'remove-libc++-linking
> +            (lambda _
> +              (substitute* "src/Makefile.am"
> +                (("-lc\\+\\+") ""))
> +              #t))
Why?  If it's because you're building a shared library, do this in the
next phase.
> +          (add-after 'unpack 'build-shared-library
> +            (lambda _
> +              (substitute* "src/Makefile.am"
> +                (("lib_LIBRARIES") "lib_LTLIBRARIES")
> +                (("libfreesasa\\.a") "libfreesasa.la")
> +                (("freesasa_LDADD \\+= libfreesasa\\.la" prev)
> +                 (string-append prev "\nlibfreesasa_la_LIBADD"
> +                                " = -ljson-c ${libxml2_LIBS}\n"))
> +                (("_a_SOURCES") "_la_SOURCES"))
> +              (substitute* "configure.ac"
> +                (("AC_PROG_INSTALL" inst)
> +                 (string-append "AM_PROG_LIBTOOL\n" inst)))
> +              (substitute* "tests/Makefile.am"
> +                (("libfreesasa\\.a") "libfreesasa.la"))
> +              #t))
> +          (add-before 'build 'build-lexer-and-parser
> +            (lambda _
> +              (with-directory-excursion "src"
> +                (invoke "make" "lexer.h")
> +                (invoke "make" "parser.h"))
> +              #t))
You can do this in one make.
> +          (add-after 'install 'install-doc
> +            (lambda _
> +              (copy-recursively
> +               "doc/html"
> +               (string-append #$output:doc "/share/doc/" #$name "-"
> #$version))
> +              #t)))))
> +    (home-page "https://freesasa.github.io/")
> +    (synopsis "Library for calculating the solvent accessible
> surface area
> +(SASA) of molecules")
"Calculate the..."
> +    (description "FreeSASA is a command line tool and C-library for
> +calculating solvent accessible surface areas (SASA).  By default Lee
> &
Use @abbr.
> +Richards' algorithm is used, but Shrake & Rupley's is also
> available.  Both can
> +be parameterized to arbitrary precision, and for high resolution
> versions of
> +the algorithms, the calculations give identical results.")
> +    (license license:expat)))

Cheers