* gnu/packages/crypto.scm (crypto++): New variable. --- gnu/packages/crypto.scm | 90 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm index e4a8a4bd5..2bf64f1f6 100644 --- a/gnu/packages/crypto.scm +++ b/gnu/packages/crypto.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2016 Tobias Geerinckx-Rice <m...@tobias.gr> ;;; Copyright © 2016 ng0 <n...@we.make.ritual.n0.is> ;;; Copyright © 2016 Eric Bavier <bav...@member.fsf.org> +;;; Copyright © 2017 Marius Bakke <mba...@fastmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -46,12 +47,99 @@ #:use-module (gnu packages tcl) #:use-module (gnu packages tls) #:use-module (gnu packages xml) + #:use-module (gnu packages zip) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix build-system cmake) - #:use-module (guix build-system gnu)) + #:use-module (guix build-system gnu) + #:use-module (guix utils) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match)) + +(define-public crypto++ + (package + (name "crypto++") + (version "5.6.5") + (source (origin + (method url-fetch) + (uri (let ((numeric-version + (match (string-split version #\.) + ((first-digit other-digits ...) + (string-append first-digit + (string-concatenate + other-digits)))))) + (string-append "https://cryptopp.com/cryptopp" + numeric-version ".zip"))) + (sha256 + (base32 + "0d1cqdz369ivi082k59025wvxzywvkizw7i0pf5h0a1izs3g8pm7")))) + (build-system gnu-build-system) + (arguments + `(#:make-flags + (list (string-append "PREFIX=" (assoc-ref %outputs "out")) + (string-append "BINDIR=" (assoc-ref %outputs "bin") "/bin") + (string-append "DATADIR=" (assoc-ref %outputs "doc") "/share") + "DISABLE_CXXFLAGS_OPTIMIZATIONS=1" + ;; Override "/sbin/ldconfig" with simply "echo" since + ;; we don't need ldconfig(8). + "LDCONF=echo") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'enter-source + ;; ??? Why are we in the TestData folder. + (lambda _ (chdir "..") #t)) + (add-after 'enter-source 'disable-optimizations + (lambda _ + ;; XXX: The disable optimizations flag above is not recognized in + ;; the current version. See https://github.com/weidai11/cryptopp/pull/354 . + ;; For now, just remove it the dirty way. + (substitute* "GNUmakefile" + (("-march=native") "")) + #t)) + (delete 'configure) + (add-after 'build 'build-shared + (lambda _ + ;; By default, only the static library is built. + (zero? (system* "make" "shared")))) + (add-after 'install 'move-static-library + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (lib (string-append out "/lib")) + (static (assoc-ref outputs "static")) + (slib (string-append static "/lib"))) + (mkdir-p slib) + (for-each (lambda (file) + (install-file file slib) + (delete-file file)) + (find-files lib "\\.l?a$")) + #t))) + (add-after 'move-static-library 'add-so-version-symlink + ;; The library is named MAJOR.MINOR.PATCHLEVEL. Some programs + ;; expect a MAJOR.MINOR symlink. + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (major+minor ,(version-major+minor version))) + (with-directory-excursion (string-append out "/lib") + (symlink (string-append "libcryptopp.so." ,version) + (string-append "libcryptopp.so." major+minor)) + #t))))))) + (outputs '("out" ; 6.4M shared library and headers + "bin" ; 6.3M cryptest.exe + "doc" ; 6.4M documentation and examples + "static")) ; 15M static library + (native-inputs + `(("unzip" ,unzip))) + (synopsis "C++ class library of cryptographic schemes") + (description + "Crypto++ is a large collection of cryptograhic algorithms and related +utilities for C++.") + (home-page "https://cryptopp.com") + ;; The compilation is licensed under Boost 1.0, while most individual + ;; files are in the public domain. + (license (list license:boost1.0 + license:public-domain)))) (define-public libsodium (package -- 2.11.0