>From 6e390fd37c1562188c0c40a3d4c9c8987462abd1 Mon Sep 17 00:00:00 2001
From: Adonay Felipe Nogueira
Date: Sat, 24 Jun 2017 13:09:46 -0300
Subject: [PATCH] gnu: Add crypto++.
* gnu/packages/crypto.scm (crypto++): New variable.
---
gnu/packages/crypto.scm | 103 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 102 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index 6f02d86..4d32750 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -6,6 +6,8 @@
;;; Copyright © 2016 Tobias Geerinckx-Rice
;;; Copyright © 2016 ng0
;;; Copyright © 2016, 2017 Eric Bavier
+;;; Copyright © 2017 Marius Bakke
+;;; Copyright © 2017 Adonay "adfeno" Felipe Nogueira
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +31,7 @@
#:use-module (gnu packages attr)
#:use-module (gnu packages autotools)
#:use-module (gnu packages boost)
+ #:use-module (gnu packages compression)
#:use-module (gnu packages cryptsetup)
#:use-module (gnu packages gettext)
#:use-module (gnu packages gnupg)
@@ -50,9 +53,107 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix build utils)
#:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
- #:use-module (guix build-system python))
+ #:use-module (guix build-system python)
+ #:use-module (guix utils)
+ #:use-module (ice-9 match))
+
+(define-public crypto++
+ (let ((release "5.6.5")
+ (revision 1))
+ (package
+ (name "crypto++")
+ (version (if (zero? revision)
+ release
+ (string-append release "-"
+ (number->string revision))))
+ (source (origin
+ (method url-fetch)
+ (uri (let ((numeric-version
+ (match (string-split release #\.)
+ ((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
+ `(,(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
+ ;; They have made a zip-bomb.
+ (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 release)))
+ (with-directory-excursion (string-append out "/lib")
+ (symlink (string-append "libcryptopp.so." ,release)
+ (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.
+ ;; Should we add two licenses?
+ (license license:boost1.0))))
(define-public libsodium
(package
--
1.9.1