| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2017, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
| 3 | ;;; Copyright © 2021 Ryan Prior <rprior@protonmail.com> |
| 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; |
| 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 8 | ;;; under the terms of the GNU General Public License as published by |
| 9 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 10 | ;;; your option) any later version. |
| 11 | ;;; |
| 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | ;;; GNU General Public License for more details. |
| 16 | ;;; |
| 17 | ;;; You should have received a copy of the GNU General Public License |
| 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | (define-module (gnu packages digest) |
| 21 | #:use-module ((guix licenses) #:prefix license:) |
| 22 | #:use-module (guix packages) |
| 23 | #:use-module (guix git-download) |
| 24 | #:use-module (guix build-system gnu) |
| 25 | #:use-module (guix build-system trivial) |
| 26 | #:use-module (guix utils) |
| 27 | #:use-module (ice-9 match)) |
| 28 | |
| 29 | (define-public wyhash |
| 30 | (package |
| 31 | (name "wyhash") |
| 32 | (version "5") |
| 33 | (source (origin |
| 34 | (method git-fetch) |
| 35 | (uri (git-reference |
| 36 | (url "https://github.com/wangyi-fudan/wyhash") |
| 37 | (commit (string-append "wyhash_v" version)))) |
| 38 | (file-name (git-file-name name version)) |
| 39 | (sha256 |
| 40 | (base32 "03ljs5iw9zrm3bydwggjvpwrcwmsd75h3dv1j4am4hw3h22cjdjc")))) |
| 41 | (build-system trivial-build-system) ;; source-only package |
| 42 | (arguments |
| 43 | `(#:modules ((guix build utils)) |
| 44 | #:builder |
| 45 | (begin |
| 46 | (use-modules (guix build utils)) |
| 47 | (let* ((out (string-append (assoc-ref %outputs "out"))) |
| 48 | (include (string-append out "/include")) |
| 49 | (doc (string-append out "/share/doc/" ,name "-" ,version)) |
| 50 | (source (assoc-ref %build-inputs "source"))) |
| 51 | (with-directory-excursion source |
| 52 | (install-file "wyhash.h" include) |
| 53 | (install-file "LICENSE" doc) |
| 54 | (install-file "README.md" doc)) |
| 55 | #t)))) |
| 56 | (home-page "https://github.com/wangyi-fudan/wyhash") |
| 57 | (synopsis "Embeddable hash function and random number generator") |
| 58 | (description "This package provides a portable hash function and random |
| 59 | number generator suitable for use in data structures. Provided by default in |
| 60 | Zig, V, and Nim programming language standard libraries.") |
| 61 | (license license:unlicense))) |
| 62 | |
| 63 | (define-public xxhash |
| 64 | (package |
| 65 | (name "xxhash") |
| 66 | (version "0.8.0") |
| 67 | (source |
| 68 | (origin |
| 69 | (method git-fetch) |
| 70 | (uri (git-reference |
| 71 | (url "https://github.com/Cyan4973/xxHash") |
| 72 | (commit (string-append "v" version)))) |
| 73 | (file-name (git-file-name name version)) |
| 74 | (sha256 |
| 75 | (base32 "0hpbzdd6kfki5f61g103vp7pfczqkdj0js63avl0ss552jfb8h96")))) |
| 76 | (build-system gnu-build-system) |
| 77 | (arguments |
| 78 | `(#:make-flags |
| 79 | (list ,(string-append "CC=" (cc-for-target)) |
| 80 | ,(match (or (%current-target-system) |
| 81 | (%current-system)) |
| 82 | ;; Detect vector instruction set at run time. |
| 83 | ((or "i686-linux" "x86_64-linux") "DISPATCH=1") |
| 84 | (_ "DISPATCH=0")) |
| 85 | "XXH_FORCE_MEMORY_ACCESS=1" ; improved performance with GCC |
| 86 | (string-append "prefix=" (assoc-ref %outputs "out"))) |
| 87 | #:phases |
| 88 | (modify-phases %standard-phases |
| 89 | (delete 'configure)))) ; no configure script |
| 90 | (home-page "https://cyan4973.github.io/xxHash/") |
| 91 | (synopsis "Extremely fast hash algorithm") |
| 92 | (description |
| 93 | "xxHash is an extremely fast non-cryptographic hash algorithm. It works |
| 94 | at speeds close to RAM limits, and comes in both 32- and 64-bit flavours. |
| 95 | The code is highly portable, and hashes of the same length are identical on all |
| 96 | platforms (both big and little endian).") |
| 97 | (license (list license:bsd-2 ; xxhash library (xxhash.[ch]) |
| 98 | license:gpl2+)))) ; xxhsum.c |