Merge branch 'master' into staging
[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, 2020 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 ;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
8 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
9 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages c)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system trivial)
34 #:use-module (gnu packages bootstrap)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages texinfo)
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages multiprecision)
42 #:use-module (gnu packages pcre)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages gettext)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages xml))
48
49 (define-public tcc
50 (package
51 (name "tcc") ;aka. "tinycc"
52 (version "0.9.27")
53 (source (origin
54 (method url-fetch)
55 (uri (string-append "mirror://savannah/tinycc/tcc-"
56 version ".tar.bz2"))
57 (sha256
58 (base32
59 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
60 (build-system gnu-build-system)
61 (native-inputs `(("perl" ,perl)
62 ("texinfo" ,texinfo)))
63 (arguments
64 `(#:configure-flags (list (string-append "--elfinterp="
65 (assoc-ref %build-inputs "libc")
66 ,(glibc-dynamic-linker))
67 (string-append "--crtprefix="
68 (assoc-ref %build-inputs "libc")
69 "/lib")
70 (string-append "--sysincludepaths="
71 (assoc-ref %build-inputs "libc")
72 "/include:"
73 (assoc-ref %build-inputs
74 "kernel-headers")
75 "/include:{B}/include")
76 (string-append "--libpaths="
77 (assoc-ref %build-inputs "libc")
78 "/lib")
79 ,@(if (string-prefix? "armhf-linux"
80 (or (%current-target-system)
81 (%current-system)))
82 `("--triplet=arm-linux-gnueabihf")
83 '()))
84 #:test-target "test"))
85 (native-search-paths
86 (list (search-path-specification
87 (variable "CPATH")
88 (files '("include")))
89 (search-path-specification
90 (variable "LIBRARY_PATH")
91 (files '("lib" "lib64")))))
92 ;; Fails to build on MIPS: "Unsupported CPU"
93 (supported-systems (delete "mips64el-linux" %supported-systems))
94 (synopsis "Tiny and fast C compiler")
95 (description
96 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
97 written in C. It supports ANSI C with GNU and extensions and most of the C99
98 standard.")
99 (home-page "http://www.tinycc.org/")
100 ;; An attempt to re-licence tcc under the Expat licence is underway but not
101 ;; (if ever) complete. See the RELICENSING file for more information.
102 (license license:lgpl2.1+)))
103
104 (define-public pcc
105 (package
106 (name "pcc")
107 (version "20170109")
108 (source (origin
109 (method url-fetch)
110 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
111 version ".tgz"))
112 (sha256
113 (base32
114 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
115 (build-system gnu-build-system)
116 (arguments
117 `(#:phases
118 (modify-phases %standard-phases
119 (replace 'check
120 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
121 (native-inputs
122 `(("bison" ,bison)
123 ("flex" ,flex)))
124 (synopsis "Portable C compiler")
125 (description
126 "PCC is a portable C compiler. The project goal is to write a C99
127 compiler while still keeping it small, simple, fast and understandable.")
128 (home-page "http://pcc.ludd.ltu.se")
129 (supported-systems (delete "aarch64-linux" %supported-systems))
130 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
131 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
132 (license (list license:bsd-2 license:bsd-3))))
133
134 (define-public libbytesize
135 (package
136 (name "libbytesize")
137 (version "2.2")
138 (source (origin
139 (method url-fetch)
140 (uri (string-append
141 "https://github.com/storaged-project/libbytesize/releases/"
142 "download/" version "/libbytesize-" version ".tar.gz"))
143 (sha256
144 (base32
145 "1aivwypmnqcaj2230pifvf3jcgl5chja8rspkxf0j3480asm8g5r"))))
146 (build-system gnu-build-system)
147 (arguments
148 `(#:tests? #f))
149 (native-inputs
150 `(("gettext" ,gettext-minimal)
151 ("pkg-config" ,pkg-config)
152 ("python" ,python)))
153 (inputs
154 `(("mpfr" ,mpfr)
155 ("pcre2" ,pcre2)))
156 (home-page "https://github.com/storaged-project/libbytesize")
157 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
158 (description
159 "The goal of this project is to provide a tiny library that would
160 facilitate the common operations with sizes in bytes. Many projects need to
161 work with sizes in bytes (be it sizes of storage space, memory...) and all of
162 them need to deal with the same issues like:
163
164 @itemize
165 @item How to get a human-readable string for the given size?
166 @item How to store the given size so that no significant information is lost?
167 @item If we store the size in bytes, what if the given size gets over the
168 MAXUINT64 value?
169 @item How to interpret sizes entered by users according to their locale and
170 typing conventions?
171 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
172 @end itemize
173
174 @code{libbytesize} offers a generally usable solution that could be used by
175 every project that needs to deal with sizes in bytes. It is written in the C
176 language with thin bindings for other languages.")
177 (license license:lgpl2.1+)))
178
179 (define-public udunits
180 (package
181 (name "udunits")
182 (version "2.2.26")
183 (source (origin
184 (method url-fetch)
185 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
186 "udunits-" version ".tar.gz"))
187 (sha256
188 (base32
189 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
190 (build-system gnu-build-system)
191 (inputs
192 `(("expat" ,expat)))
193 (home-page "https://www.unidata.ucar.edu/software/udunits/")
194 (synopsis "C library for units of physical quantities and value-conversion utils")
195 (description
196 "The UDUNITS-2 package provides support for units of physical quantities.
197 Its three main components are:
198
199 @enumerate
200 @item @code{udunits2lib}, a C library for units of physical quantities;
201 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
202 and for converting numeric values between compatible units; and
203 @item an extensive database of units.
204 @end enumerate\n")
205 ;; Like the BSD-3 license but with an extra anti patent clause.
206 (license (license:non-copyleft "file://COPYRIGHT"))))
207
208 (define-public libfixposix
209 (package
210 (name "libfixposix")
211 (version "0.4.3")
212 (home-page "https://github.com/sionescu/libfixposix")
213 (source
214 (origin
215 (method git-fetch)
216 (uri (git-reference
217 (url home-page)
218 (commit (string-append "v" version))))
219 (file-name (git-file-name name version))
220 (sha256
221 (base32
222 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
223 (build-system gnu-build-system)
224 (native-inputs
225 `(("autoconf" ,autoconf)
226 ("automake" ,automake)
227 ("libtool" ,libtool)
228 ("pkg-config" ,pkg-config)
229 ("check" ,check)))
230 (synopsis "Thin wrapper over POSIX syscalls")
231 (description
232 "The purpose of libfixposix is to offer replacements for parts of POSIX
233 whose behaviour is inconsistent across *NIX flavours.")
234 (license license:boost1.0)))
235
236 (define-public libhx
237 (package
238 (name "libhx")
239 (version "3.24")
240 (source
241 (origin
242 (method url-fetch)
243 (uri (string-append "mirror://sourceforge/libhx/libHX/"
244 "libHX-" version ".tar.xz"))
245 (sha256
246 (base32
247 "0i8v2464p830c15myknvvs6bhxaf663lrqgga95l94ygfynkw6x5"))))
248 (build-system gnu-build-system)
249 (home-page "http://libhx.sourceforge.net")
250 (synopsis "C library with common data structures and functions")
251 (description
252 "This is a C library (with some C++ bindings available) that provides data
253 structures and functions commonly needed, such as maps, deques, linked lists,
254 string formatting and autoresizing, option and config file parsing, type
255 checking casts and more.")
256 (license license:lgpl2.1+)))
257
258 (define-public packcc
259 (package
260 (name "packcc")
261 ;; We need a few fixes on top of the latest release to prevent test
262 ;; failures in Universal Ctags.
263 (version "1.2.5-19-g58d1b9d")
264 (home-page "https://github.com/enechaev/packcc")
265 (source (origin
266 (method git-fetch)
267 (uri (git-reference
268 (url home-page)
269 (commit (string-append "v" version))))
270 (file-name (git-file-name name version))
271 (sha256
272 (base32
273 "0biyv835jlk43fvmmd3p8jafs7k2iw9qlaj37hvsl604ai6rd5aj"))))
274 (build-system gnu-build-system)
275 (arguments
276 '(#:tests? #f ;no tests
277 #:make-flags '("-DUSE_SYSTEM_STRNLEN=1")
278 #:phases (modify-phases %standard-phases
279 ;; The project consists of a single source file and has
280 ;; no actual build system, so we need to do it manually.
281 (delete 'configure)
282 (replace 'build
283 (lambda* (#:key make-flags #:allow-other-keys)
284 (apply invoke "gcc" "-o" "packcc" "packcc.c"
285 make-flags)))
286 (replace 'install
287 (lambda* (#:key outputs #:allow-other-keys)
288 (let ((out (assoc-ref outputs "out")))
289 (install-file "packcc" (string-append out "/bin"))
290 (install-file "README.md"
291 (string-append out "/share/doc/packcc"))
292 #t))))))
293 (synopsis "Packrat parser generator for C")
294 (description
295 "PackCC is a packrat parser generator for the C programming language.
296 Its main features are:
297 @itemize
298 @item Generates a parser in C from a grammar described in a PEG.
299 @item Gives your parser great efficiency by packrat parsing.
300 @item Supports direct and indirect left-recursive grammar rules.
301 @end itemize
302 The grammar of your parser can be described in a @acronym{PEG, Parsing
303 Expression Grammar}. The PEG is a top-down parsing language, and is similar
304 to the regular-expression grammar. The PEG does not require tokenization to
305 be a separate step, and tokenization rules can be written in the same way as
306 any other grammar rules.")
307 (license license:expat)))
308
309 (define-public sparse
310 (package
311 (name "sparse")
312 (version "0.6.1")
313 (source (origin
314 (method url-fetch)
315 (uri
316 (string-append "mirror://kernel.org/software/devel/sparse/dist/"
317 "sparse-" version ".tar.xz"))
318 (sha256
319 (base32
320 "0qavyryxmhd1rf11akgn1nq3r15k11bqa3qajaq36a56r225rc7x"))))
321 (build-system gnu-build-system)
322 (inputs `(("perl" ,perl)))
323 (arguments
324 '(#:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
325 #:phases (modify-phases %standard-phases
326 (delete 'configure)
327 (add-after 'unpack 'patch-cgcc
328 (lambda _
329 (substitute* "cgcc"
330 (("'cc'") (string-append "'" (which "gcc") "'")))
331 #t)))))
332 (synopsis "Semantic C parser for Linux development")
333 (description
334 "Sparse is a semantic parser for C and is required for Linux development.
335 It provides a compiler frontend capable of parsing most of ANSI C as well as
336 many GCC extensions, and a collection of sample compiler backends, including a
337 static analyzer also called @file{sparse}. Sparse provides a set of
338 annotations designed to convey semantic information about types, such as what
339 address space pointers point to, or what locks a function acquires or
340 releases.")
341 (home-page "https://sparse.wiki.kernel.org/index.php/Main_Page")
342 (license license:expat)))