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