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 ;;; Copyright © 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
12 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages c)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix git-download)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system trivial)
36 #:use-module (gnu packages bootstrap)
37 #:use-module (gnu packages bison)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages flex)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages texinfo)
42 #:use-module (gnu packages guile)
43 #:use-module (gnu packages lua)
44 #:use-module (gnu packages multiprecision)
45 #:use-module (gnu packages pcre)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages python-xyz)
48 #:use-module (gnu packages autotools)
49 #:use-module (gnu packages gettext)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages xml))
52
53 (define-public tcc
54 (package
55 (name "tcc") ;aka. "tinycc"
56 (version "0.9.27")
57 (source (origin
58 (method url-fetch)
59 (uri (string-append "mirror://savannah/tinycc/tcc-"
60 version ".tar.bz2"))
61 (sha256
62 (base32
63 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
64 (build-system gnu-build-system)
65 (native-inputs `(("perl" ,perl)
66 ("texinfo" ,texinfo)))
67 (arguments
68 `(#:configure-flags (list (string-append "--elfinterp="
69 (assoc-ref %build-inputs "libc")
70 ,(glibc-dynamic-linker))
71 (string-append "--crtprefix="
72 (assoc-ref %build-inputs "libc")
73 "/lib")
74 (string-append "--sysincludepaths="
75 (assoc-ref %build-inputs "libc")
76 "/include:"
77 (assoc-ref %build-inputs
78 "kernel-headers")
79 "/include:{B}/include")
80 (string-append "--libpaths="
81 (assoc-ref %build-inputs "libc")
82 "/lib")
83 ,@(if (string-prefix? "armhf-linux"
84 (or (%current-target-system)
85 (%current-system)))
86 `("--triplet=arm-linux-gnueabihf")
87 '()))
88 #:test-target "test"))
89 (native-search-paths
90 (list (search-path-specification
91 (variable "CPATH")
92 (files '("include")))
93 (search-path-specification
94 (variable "LIBRARY_PATH")
95 (files '("lib" "lib64")))))
96 ;; Fails to build on MIPS: "Unsupported CPU"
97 (supported-systems (delete "mips64el-linux" %supported-systems))
98 (synopsis "Tiny and fast C compiler")
99 (description
100 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
101 written in C. It supports ANSI C with GNU and extensions and most of the C99
102 standard.")
103 (home-page "http://www.tinycc.org/")
104 ;; An attempt to re-licence tcc under the Expat licence is underway but not
105 ;; (if ever) complete. See the RELICENSING file for more information.
106 (license license:lgpl2.1+)))
107
108 (define-public pcc
109 (package
110 (name "pcc")
111 (version "20170109")
112 (source (origin
113 (method url-fetch)
114 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
115 version ".tgz"))
116 (sha256
117 (base32
118 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
119 (build-system gnu-build-system)
120 (arguments
121 `(#:phases
122 (modify-phases %standard-phases
123 (replace 'check
124 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
125 (native-inputs
126 `(("bison" ,bison)
127 ("flex" ,flex)))
128 (synopsis "Portable C compiler")
129 (description
130 "PCC is a portable C compiler. The project goal is to write a C99
131 compiler while still keeping it small, simple, fast and understandable.")
132 (home-page "http://pcc.ludd.ltu.se")
133 (supported-systems (delete "aarch64-linux" %supported-systems))
134 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
135 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
136 (license (list license:bsd-2 license:bsd-3))))
137
138 (define-public libbytesize
139 (package
140 (name "libbytesize")
141 (version "2.2")
142 (source (origin
143 (method url-fetch)
144 (uri (string-append
145 "https://github.com/storaged-project/libbytesize/releases/"
146 "download/" version "/libbytesize-" version ".tar.gz"))
147 (sha256
148 (base32
149 "1aivwypmnqcaj2230pifvf3jcgl5chja8rspkxf0j3480asm8g5r"))))
150 (build-system gnu-build-system)
151 (arguments
152 `(#:tests? #f))
153 (native-inputs
154 `(("gettext" ,gettext-minimal)
155 ("pkg-config" ,pkg-config)
156 ("python" ,python)))
157 (inputs
158 `(("mpfr" ,mpfr)
159 ("pcre2" ,pcre2)))
160 (home-page "https://github.com/storaged-project/libbytesize")
161 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
162 (description
163 "The goal of this project is to provide a tiny library that would
164 facilitate the common operations with sizes in bytes. Many projects need to
165 work with sizes in bytes (be it sizes of storage space, memory...) and all of
166 them need to deal with the same issues like:
167
168 @itemize
169 @item How to get a human-readable string for the given size?
170 @item How to store the given size so that no significant information is lost?
171 @item If we store the size in bytes, what if the given size gets over the
172 MAXUINT64 value?
173 @item How to interpret sizes entered by users according to their locale and
174 typing conventions?
175 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
176 @end itemize
177
178 @code{libbytesize} offers a generally usable solution that could be used by
179 every project that needs to deal with sizes in bytes. It is written in the C
180 language with thin bindings for other languages.")
181 (license license:lgpl2.1+)))
182
183 (define-public udunits
184 (package
185 (name "udunits")
186 (version "2.2.26")
187 (source (origin
188 (method url-fetch)
189 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
190 "udunits-" version ".tar.gz"))
191 (sha256
192 (base32
193 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
194 (build-system gnu-build-system)
195 (inputs
196 `(("expat" ,expat)))
197 (home-page "https://www.unidata.ucar.edu/software/udunits/")
198 (synopsis "C library for units of physical quantities and value-conversion utils")
199 (description
200 "The UDUNITS-2 package provides support for units of physical quantities.
201 Its three main components are:
202
203 @enumerate
204 @item @code{udunits2lib}, a C library for units of physical quantities;
205 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
206 and for converting numeric values between compatible units; and
207 @item an extensive database of units.
208 @end enumerate\n")
209 ;; Like the BSD-3 license but with an extra anti patent clause.
210 (license (license:non-copyleft "file://COPYRIGHT"))))
211
212 (define-public libfixposix
213 (package
214 (name "libfixposix")
215 (version "0.4.3")
216 (home-page "https://github.com/sionescu/libfixposix")
217 (source
218 (origin
219 (method git-fetch)
220 (uri (git-reference
221 (url home-page)
222 (commit (string-append "v" version))))
223 (file-name (git-file-name name version))
224 (sha256
225 (base32
226 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
227 (build-system gnu-build-system)
228 (native-inputs
229 `(("autoconf" ,autoconf)
230 ("automake" ,automake)
231 ("libtool" ,libtool)
232 ("pkg-config" ,pkg-config)
233 ("check" ,check)))
234 (synopsis "Thin wrapper over POSIX syscalls")
235 (description
236 "The purpose of libfixposix is to offer replacements for parts of POSIX
237 whose behaviour is inconsistent across *NIX flavours.")
238 (license license:boost1.0)))
239
240 (define-public libhx
241 (package
242 (name "libhx")
243 (version "3.25")
244 (source
245 (origin
246 (method url-fetch)
247 (uri (string-append "mirror://sourceforge/libhx/libHX/"
248 "libHX-" version ".tar.xz"))
249 (sha256
250 (base32 "12avn16f8aqb0cq6jplz0sv7rh6f07m85dwc8dasnnwsvijwbpbj"))))
251 (build-system gnu-build-system)
252 (home-page "http://libhx.sourceforge.net")
253 (synopsis "C library with common data structures and functions")
254 (description
255 "This is a C library (with some C++ bindings available) that provides data
256 structures and functions commonly needed, such as maps, deques, linked lists,
257 string formatting and autoresizing, option and config file parsing, type
258 checking casts and more.")
259 (license license:lgpl2.1+)))
260
261 (define-public libwuya
262 ;; This commit is the one before "wuy_pool.h" was removed from libwuya,
263 ;; which libleak currently requires.
264 (let ((revision "1")
265 (commit "883502041044f4616cfbf75c8f2bb60059f704a9"))
266 (package
267 (name "libwuya")
268 (version (git-version "0.0" revision commit))
269 (source (origin
270 (method git-fetch)
271 (uri (git-reference
272 (url "https://github.com/WuBingzheng/libwuya")
273 (commit commit)))
274 (file-name (git-file-name name version))
275 (sha256
276 (base32
277 "1xrsqbgr13g2v0ag165ryp7xrwzv41xfygzk2a3445ca98c1qpdc"))))
278 (build-system gnu-build-system)
279 (arguments
280 `(#:tests? #f ;no test suite
281 #:phases (modify-phases %standard-phases
282 (add-after 'unpack 'patch-lua-includes
283 (lambda _
284 (substitute* '("wuy_cflua.h" "wuy_cflua.c")
285 (("<lua5\\.1/") "<"))
286 #t))
287 (add-after 'unpack 'add--fPIC-to-CFLAGS
288 (lambda _
289 (substitute* "Makefile"
290 (("CFLAGS[^\n]*" all)
291 (string-append all " -fPIC")))
292 #t))
293 (add-before 'build 'set-CC
294 (lambda _
295 (setenv "CC" "gcc")
296 #t))
297 (delete 'configure) ;no configure script
298 (replace 'install
299 (lambda* (#:key outputs #:allow-other-keys)
300 (let* ((out (assoc-ref outputs "out"))
301 (include-dir (string-append out "/include"))
302 (headers (find-files "." "\\.h$")))
303 (for-each (lambda (h)
304 (install-file h include-dir))
305 headers)
306 (install-file "libwuya.a" (string-append out "/lib"))
307 #t))))))
308 (inputs `(("lua" ,lua)))
309 (home-page "https://github.com/WuBingzheng/libwuya/")
310 (synopsis "C library implementing various data structures")
311 (description "The @code{libwuya} library implements data structures such
312 as dictionaries, skip lists, and memory pools.")
313 ;; There is no clear information as to what license this is distributed
314 ;; under, but it is included (bundled) with libleak from the same author
315 ;; under the GNU GPL v2 or later license, so use this here until it is
316 ;; clarified (see: https://github.com/WuBingzheng/libwuya/issues/2).
317 (license license:gpl2+))))
318
319 (define-public packcc
320 (package
321 (name "packcc")
322 ;; We need a few fixes on top of the latest release to prevent test
323 ;; failures in Universal Ctags.
324 (version "1.2.5-19-g58d1b9d")
325 (home-page "https://github.com/enechaev/packcc")
326 (source (origin
327 (method git-fetch)
328 (uri (git-reference
329 (url home-page)
330 (commit (string-append "v" version))))
331 (file-name (git-file-name name version))
332 (sha256
333 (base32
334 "0biyv835jlk43fvmmd3p8jafs7k2iw9qlaj37hvsl604ai6rd5aj"))))
335 (build-system gnu-build-system)
336 (arguments
337 '(#:tests? #f ;no tests
338 #:make-flags '("-DUSE_SYSTEM_STRNLEN=1")
339 #:phases (modify-phases %standard-phases
340 ;; The project consists of a single source file and has
341 ;; no actual build system, so we need to do it manually.
342 (delete 'configure)
343 (replace 'build
344 (lambda* (#:key make-flags #:allow-other-keys)
345 (apply invoke "gcc" "-o" "packcc" "packcc.c"
346 make-flags)))
347 (replace 'install
348 (lambda* (#:key outputs #:allow-other-keys)
349 (let ((out (assoc-ref outputs "out")))
350 (install-file "packcc" (string-append out "/bin"))
351 (install-file "README.md"
352 (string-append out "/share/doc/packcc"))
353 #t))))))
354 (synopsis "Packrat parser generator for C")
355 (description
356 "PackCC is a packrat parser generator for the C programming language.
357 Its main features are:
358 @itemize
359 @item Generates a parser in C from a grammar described in a PEG.
360 @item Gives your parser great efficiency by packrat parsing.
361 @item Supports direct and indirect left-recursive grammar rules.
362 @end itemize
363 The grammar of your parser can be described in a @acronym{PEG, Parsing
364 Expression Grammar}. The PEG is a top-down parsing language, and is similar
365 to the regular-expression grammar. The PEG does not require tokenization to
366 be a separate step, and tokenization rules can be written in the same way as
367 any other grammar rules.")
368 (license license:expat)))
369
370 (define-public sparse
371 (package
372 (name "sparse")
373 (version "0.6.3")
374 (source (origin
375 (method url-fetch)
376 (uri
377 (string-append "mirror://kernel.org/software/devel/sparse/dist/"
378 "sparse-" version ".tar.xz"))
379 (sha256
380 (base32
381 "16d8c4dhipjzjf8z4z7pix1pdpqydz0v4r7i345f5s09hjnxpxnl"))))
382 (build-system gnu-build-system)
383 (inputs `(("perl" ,perl)))
384 (arguments
385 '(#:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
386 #:phases (modify-phases %standard-phases
387 (delete 'configure)
388 (add-after 'unpack 'patch-cgcc
389 (lambda _
390 (substitute* "cgcc"
391 (("'cc'") (string-append "'" (which "gcc") "'")))
392 #t)))))
393 (synopsis "Semantic C parser for Linux development")
394 (description
395 "Sparse is a semantic parser for C and is required for Linux development.
396 It provides a compiler frontend capable of parsing most of ANSI C as well as
397 many GCC extensions, and a collection of sample compiler backends, including a
398 static analyzer also called @file{sparse}. Sparse provides a set of
399 annotations designed to convey semantic information about types, such as what
400 address space pointers point to, or what locks a function acquires or
401 releases.")
402 (home-page "https://sparse.wiki.kernel.org/index.php/Main_Page")
403 (license license:expat)))
404
405 (define-public libestr
406 (package
407 (name "libestr")
408 (version "0.1.11")
409 (source
410 (origin
411 (method git-fetch)
412 (uri (git-reference
413 (url "https://github.com/rsyslog/libestr")
414 (commit (string-append "v" version))))
415 (file-name (git-file-name name version))
416 (sha256
417 (base32
418 "1ca4rj90c0dn7kqpbcchkflxjw88a7rxcnwbr0gply4a28i01nd8"))))
419 (build-system gnu-build-system)
420 (arguments
421 `(#:phases
422 (modify-phases %standard-phases
423 ;; autogen.sh calls configure at the end of the script.
424 (replace 'bootstrap
425 (lambda _ (invoke "autoreconf" "-vfi"))))))
426 (native-inputs
427 `(("autoconf" ,autoconf)
428 ("automake" ,automake)
429 ("pkg-config" ,pkg-config)
430 ("libtool" ,libtool)))
431 (home-page "https://github.com/rsyslog/libestr")
432 (synopsis "Helper functions for handling strings")
433 (description
434 "This C library contains some essential string manipulation functions and
435 more, like escaping special characters.")
436 (license license:lgpl2.1+)))
437
438 (define-public libfastjson
439 (package
440 (name "libfastjson")
441 (version "0.99.8")
442 (source
443 (origin
444 (method git-fetch)
445 (uri (git-reference
446 (url "https://github.com/rsyslog/libfastjson")
447 (commit (string-append "v" version))))
448 (file-name (git-file-name name version))
449 (sha256
450 (base32
451 "0qhs0g9slj3p0v2z4s3cnsx44msrlb4k78ljg7714qiziqbrbwyl"))))
452 (build-system gnu-build-system)
453 (native-inputs
454 `(("autoconf" ,autoconf)
455 ("automake" ,automake)
456 ("libtool" ,libtool)))
457 (home-page "https://github.com/rsyslog/libfastjson")
458 (synopsis "Fast JSON library for C")
459 (description
460 "libfastjson is a fork from json-c aiming to provide: a small library
461 with essential JSON handling functions, sufficiently good JSON support (not
462 100% standards compliant), and very fast processing.")
463 (license license:expat)))
464
465 (define-public liblogging
466 (package
467 (name "liblogging")
468 (version "1.0.6")
469 (source
470 (origin
471 (method git-fetch)
472 (uri (git-reference
473 (url "https://github.com/rsyslog/liblogging")
474 (commit (string-append "v" version))))
475 (file-name (git-file-name name version))
476 (sha256
477 (base32
478 "1l32m0y65svf5vxsgw935jnqs6842rcqr56dmzwqvr00yfrjhjkp"))))
479 (build-system gnu-build-system)
480 (arguments
481 `(#:phases
482 (modify-phases %standard-phases
483 ;; autogen.sh calls configure at the end of the script.
484 (replace 'bootstrap
485 (lambda _ (invoke "autoreconf" "-vfi"))))))
486 (native-inputs
487 `(("autoconf" ,autoconf)
488 ("automake" ,automake)
489 ("pkg-config" ,pkg-config)
490 ("libtool" ,libtool)
491 ;; For rst2man.py
492 ("python-docutils" ,python-docutils)))
493 (home-page "https://github.com/rsyslog/liblogging")
494 (synopsis "Easy to use and lightweight signal-safe logging library")
495 (description
496 "Liblogging is an easy to use library for logging. It offers an enhanced
497 replacement for the syslog() call, but retains its ease of use.")
498 (license license:bsd-2)))
499
500 (define-public unifdef
501 (package
502 (name "unifdef")
503 (version "2.12")
504 (source (origin
505 (method url-fetch)
506 ;; https://dotat.at/prog/unifdef/unifdef-2.12.tar.xz
507 (uri (string-append "https://dotat.at/prog/" name "/"
508 name "-" version ".tar.xz"))
509 (sha256
510 (base32
511 "00647bp3m9n01ck6ilw6r24fk4mivmimamvm4hxp5p6wxh10zkj3"))
512 (modules '((guix build utils)))
513 (snippet
514 '(begin (delete-file-recursively "FreeBSD")
515 (delete-file-recursively "win32")
516 #t))))
517 (build-system gnu-build-system)
518 (arguments
519 `(#:phases (modify-phases %standard-phases
520 (delete 'configure))
521 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
522 #:tests? #f)) ;no test suite
523 (native-inputs
524 `(("perl" ,perl)))
525 (home-page "https://dotat.at/prog/unifdef/")
526 (synopsis "Utility to selectively processes conditional C preprocessor")
527 (description "The @command{unifdef} utility selectively processes
528 conditional C preprocessor @code{#if} and @code{#ifdef} directives. It
529 removes from a file both the directives and the additional text that they
530 delimit, while otherwise leaving the file alone. It can be useful for
531 avoiding distractions when studying code that uses @code{#ifdef} heavily for
532 portability.")
533 (license (list license:bsd-2 ;all files except...
534 license:bsd-3)))) ;...the unidef.1 manual page