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