gnu: libbytesize: Update to 2.1.
[jackhill/guix/guix.git] / gnu / packages / c.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz>
6 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages c)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages check)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages texinfo)
36 #:use-module (gnu packages guile)
37 #:use-module (gnu packages multiprecision)
38 #:use-module (gnu packages pcre)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages xml))
44
45 (define-public tcc
46 (package
47 (name "tcc") ;aka. "tinycc"
48 (version "0.9.27")
49 (source (origin
50 (method url-fetch)
51 (uri (string-append "mirror://savannah/tinycc/tcc-"
52 version ".tar.bz2"))
53 (sha256
54 (base32
55 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
56 (build-system gnu-build-system)
57 (native-inputs `(("perl" ,perl)
58 ("texinfo" ,texinfo)))
59 (arguments
60 `(#:configure-flags (list (string-append "--elfinterp="
61 (assoc-ref %build-inputs "libc")
62 ,(glibc-dynamic-linker))
63 (string-append "--crtprefix="
64 (assoc-ref %build-inputs "libc")
65 "/lib")
66 (string-append "--sysincludepaths="
67 (assoc-ref %build-inputs "libc")
68 "/include:"
69 (assoc-ref %build-inputs
70 "kernel-headers")
71 "/include:{B}/include")
72 (string-append "--libpaths="
73 (assoc-ref %build-inputs "libc")
74 "/lib")
75 ,@(if (string-prefix? "armhf-linux"
76 (or (%current-target-system)
77 (%current-system)))
78 `("--triplet=arm-linux-gnueabihf")
79 '()))
80 #:test-target "test"))
81 ;; Fails to build on MIPS: "Unsupported CPU"
82 (supported-systems (delete "mips64el-linux" %supported-systems))
83 (synopsis "Tiny and fast C compiler")
84 (description
85 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
86 written in C. It supports ANSI C with GNU and extensions and most of the C99
87 standard.")
88 (home-page "http://www.tinycc.org/")
89 ;; An attempt to re-licence tcc under the Expat licence is underway but not
90 ;; (if ever) complete. See the RELICENSING file for more information.
91 (license license:lgpl2.1+)))
92
93 (define-public tcc-wrapper
94 (package
95 (inherit tcc)
96 (name "tcc-wrapper")
97 (build-system trivial-build-system)
98 (native-inputs '())
99 (inputs `(("tcc" ,tcc)
100 ("guile" ,guile-2.2)))
101
102 ;; By default TCC does not honor any search path environment variable.
103 ;; This wrapper adds them.
104 ;;
105 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
106 ;; RUNPATH is ineffective here. We should modify TCC itself.
107 (native-search-paths
108 (list (search-path-specification
109 (variable "TCC_CPATH")
110 (files '("include")))
111 (search-path-specification
112 (variable "TCC_LIBRARY_PATH")
113 (files '("lib" "lib64")))))
114
115 (arguments
116 '(#:builder
117 (let* ((out (assoc-ref %outputs "out"))
118 (bin (string-append out "/bin"))
119 (tcc (assoc-ref %build-inputs "tcc"))
120 (guile (assoc-ref %build-inputs "guile")))
121 (mkdir out)
122 (mkdir bin)
123 (call-with-output-file (string-append bin "/cc")
124 (lambda (port)
125 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
126 (write
127 `(begin
128 (use-modules (ice-9 match)
129 (srfi srfi-26))
130
131 (define (split path)
132 (string-tokenize path (char-set-complement
133 (char-set #\:))))
134
135 (apply execl ,(string-append tcc "/bin/tcc")
136 ,(string-append tcc "/bin/tcc") ;argv[0]
137 (append (cdr (command-line))
138 (match (getenv "TCC_CPATH")
139 (#f '())
140 (str
141 (map (cut string-append "-I" <>)
142 (split str))))
143 (match (getenv "TCC_LIBRARY_PATH")
144 (#f '())
145 (str
146 (map (cut string-append "-L" <>)
147 (split str)))))))
148 port)
149 (chmod port #o777)))
150 #t)))
151 (synopsis "Wrapper providing the 'cc' command for TCC")))
152
153 (define-public pcc
154 (package
155 (name "pcc")
156 (version "20170109")
157 (source (origin
158 (method url-fetch)
159 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
160 version ".tgz"))
161 (sha256
162 (base32
163 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
164 (build-system gnu-build-system)
165 (arguments
166 `(#:phases
167 (modify-phases %standard-phases
168 (replace 'check
169 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
170 (native-inputs
171 `(("bison" ,bison)
172 ("flex" ,flex)))
173 (synopsis "Portable C compiler")
174 (description
175 "PCC is a portable C compiler. The project goal is to write a C99
176 compiler while still keeping it small, simple, fast and understandable.")
177 (home-page "http://pcc.ludd.ltu.se")
178 (supported-systems (delete "aarch64-linux" %supported-systems))
179 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
180 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
181 (license (list license:bsd-2 license:bsd-3))))
182
183 (define-public libbytesize
184 (package
185 (name "libbytesize")
186 (version "2.1")
187 (source (origin
188 (method url-fetch)
189 (uri (string-append
190 "https://github.com/storaged-project/libbytesize/releases/"
191 "download/" version "/libbytesize-" version ".tar.gz"))
192 (sha256
193 (base32
194 "1bpz9cpb8s47kqplkkiz6ryfahas2ma95g9rh2axnfjp6w1d9ixc"))))
195 (build-system gnu-build-system)
196 (arguments
197 `(#:tests? #f))
198 (native-inputs
199 `(("gettext" ,gettext-minimal)
200 ("pkg-config" ,pkg-config)
201 ("python" ,python)))
202 (inputs
203 `(("mpfr" ,mpfr)
204 ("pcre2" ,pcre2)))
205 (home-page "https://github.com/storaged-project/libbytesize")
206 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
207 (description
208 "The goal of this project is to provide a tiny library that would
209 facilitate the common operations with sizes in bytes. Many projects need to
210 work with sizes in bytes (be it sizes of storage space, memory...) and all of
211 them need to deal with the same issues like:
212
213 @itemize
214 @item How to get a human-readable string for the given size?
215 @item How to store the given size so that no significant information is lost?
216 @item If we store the size in bytes, what if the given size gets over the
217 MAXUINT64 value?
218 @item How to interpret sizes entered by users according to their locale and
219 typing conventions?
220 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
221 @end itemize
222
223 @code{libbytesize} offers a generally usable solution that could be used by
224 every project that needs to deal with sizes in bytes. It is written in the C
225 language with thin bindings for other languages.")
226 (license license:lgpl2.1+)))
227
228 (define-public udunits
229 (package
230 (name "udunits")
231 (version "2.2.26")
232 (source (origin
233 (method url-fetch)
234 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
235 "udunits-" version ".tar.gz"))
236 (sha256
237 (base32
238 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
239 (build-system gnu-build-system)
240 (inputs
241 `(("expat" ,expat)))
242 (home-page "https://www.unidata.ucar.edu/software/udunits/")
243 (synopsis "C library for units of physical quantities and value-conversion utils")
244 (description
245 "The UDUNITS-2 package provides support for units of physical quantities.
246 Its three main components are:
247
248 @enumerate
249 @item @code{udunits2lib}, a C library for units of physical quantities;
250 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
251 and for converting numeric values between compatible units; and
252 @item an extensive database of units.
253 @end enumerate\n")
254 ;; Like the BSD-3 license but with an extra anti patent clause.
255 (license (license:non-copyleft "file://COPYRIGHT"))))
256
257 (define-public libfixposix
258 (package
259 (name "libfixposix")
260 (version "0.4.3")
261 (home-page "https://github.com/sionescu/libfixposix")
262 (source
263 (origin
264 (method git-fetch)
265 (uri (git-reference
266 (url home-page)
267 (commit (string-append "v" version))))
268 (file-name (git-file-name name version))
269 (sha256
270 (base32
271 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
272 (build-system gnu-build-system)
273 (native-inputs
274 `(("autoconf" ,autoconf)
275 ("automake" ,automake)
276 ("libtool" ,libtool)
277 ("pkg-config" ,pkg-config)
278 ("check" ,check)))
279 (synopsis "Thin wrapper over POSIX syscalls")
280 (description
281 "The purpose of libfixposix is to offer replacements for parts of POSIX
282 whose behaviour is inconsistent across *NIX flavours.")
283 (license license:boost1.0)))