gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / stb.scm
blobdf31bd0f86508ca1ac50ca17bbf6cc37ba4c86e2
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu packages stb)
20   #:use-module (guix packages)
21   #:use-module (guix git-download)
22   #:use-module (guix build-system gnu)
23   #:use-module (guix build-system trivial)
24   #:use-module ((guix licenses) #:select (expat public-domain)))
26 (define stb
27   ;; stb is a collection of libraries developed within the same repository.
28   ;; When updating this, remember to change versions below as appropriate.
29   (let ((commit "e6afb9cbae4064da8c3e69af3ff5c4629579c1d2")
30         (revision "0"))
31     (package
32       (name "stb")
33       (home-page "https://github.com/nothings/stb")
34       (version (git-version "0.0" revision commit))
35       (source (origin
36                 (method git-fetch)
37                 (uri (git-reference
38                       (url home-page)
39                       (commit commit)))
40                 (sha256
41                  (base32
42                   "079nsn9bnb8c0vfq26g5l53q6gzx19a5x9q2nb55mpcljxsgxnmf"))
43                 (file-name (git-file-name name version))))
44       (build-system gnu-build-system)
45       (arguments
46        `(#:modules ((ice-9 ftw)
47                     (ice-9 regex)
48                     (srfi srfi-26)
49                     ,@%gnu-build-system-modules)
50          #:phases (modify-phases %standard-phases
51                     (delete 'configure)
52                     (delete 'build)
53                     (replace 'check
54                       (lambda _
55                         (invoke "make" "-C" "tests" "CC=gcc")))
56                     (replace 'install
57                       (lambda* (#:key outputs #:allow-other-keys)
58                         (let ((out (assoc-ref outputs "out"))
59                               (files (make-regexp "\\.(c|h|md)$")))
60                           (for-each (lambda (file)
61                                       (install-file file out))
62                                     (scandir "." (cut regexp-exec files <>)))
63                           #t))))))
64       (synopsis "Single file libraries for C/C++")
65       (description
66        "This package contains a variety of small independent libraries for
67 the C programming language.")
68       ;; The user can choose either license.
69       (license (list expat public-domain)))))
71 (define (make-stb-header-package name version description)
72   (package
73     (inherit stb)
74     (name name)
75     (version version)
76     (source #f)
77     (inputs `(("stb" ,stb)))
78     (build-system trivial-build-system)
79     (arguments
80      `(#:modules ((guix build utils))
81        #:builder (begin
82                    (use-modules (guix build utils))
83                    (let ((stb (assoc-ref %build-inputs "stb"))
84                          (lib (string-join (string-split ,name #\-) "_"))
85                          (out (assoc-ref %outputs "out")))
86                      (install-file (string-append stb "/" lib ".h")
87                                    (string-append out "/include"))
88                      #t))))
89     (description description)))
91 ;; TODO: These descriptions are not translatable!  They should be
92 ;; converted to macros as outlined in <https://bugs.gnu.org/32155>.
93 (define-public stb-image
94   (make-stb-header-package
95    "stb-image" "2.19"
96    "stb-image is a small and self-contained library for image loading or
97 decoding from file or memory.  A variety of formats are supported."))
99 (define-public stb-image-write
100   (make-stb-header-package
101    "stb-image-write" "1.09"
102    "stb-image-write is a small library for writing image files to the
103 C@tie{}@code{stdio} interface."))