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, 2021 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, 2021 Greg Hogan <code@greghogan.com>
15 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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 tls)
56 #:use-module (gnu packages xml))
60 (name "tcc") ;aka. "tinycc"
64 (uri (string-append "mirror://savannah/tinycc/tcc-"
68 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
69 (build-system gnu-build-system)
70 (native-inputs `(("perl" ,perl)
71 ("texinfo" ,texinfo)))
73 `(#:configure-flags (list (string-append "--elfinterp="
74 (assoc-ref %build-inputs "libc")
75 ,(glibc-dynamic-linker))
76 (string-append "--crtprefix="
77 (assoc-ref %build-inputs "libc")
79 (string-append "--sysincludepaths="
80 (assoc-ref %build-inputs "libc")
82 (assoc-ref %build-inputs
84 "/include:{B}/include")
85 (string-append "--libpaths="
86 (assoc-ref %build-inputs "libc")
88 ,@(if (string-prefix? "armhf-linux"
89 (or (%current-target-system)
91 `("--triplet=arm-linux-gnueabihf")
93 #:test-target "test"))
95 (list (search-path-specification
98 (search-path-specification
99 (variable "LIBRARY_PATH")
100 (files '("lib" "lib64")))))
101 ;; Fails to build on MIPS: "Unsupported CPU"
102 (supported-systems (delete "mips64el-linux" %supported-systems))
103 (synopsis "Tiny and fast C compiler")
105 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
106 written in C. It supports ANSI C with GNU and extensions and most of the C99
108 (home-page "http://www.tinycc.org/")
109 ;; An attempt to re-licence tcc under the Expat licence is underway but not
110 ;; (if ever) complete. See the RELICENSING file for more information.
111 (license license:lgpl2.1+)))
119 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
123 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
124 (build-system gnu-build-system)
127 (modify-phases %standard-phases
129 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
133 (synopsis "Portable C compiler")
135 "PCC is a portable C compiler. The project goal is to write a C99
136 compiler while still keeping it small, simple, fast and understandable.")
137 (home-page "http://pcc.ludd.ltu.se")
138 (supported-systems (delete "aarch64-linux" %supported-systems))
139 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
140 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
141 (license (list license:bsd-2 license:bsd-3))))
143 (define-public libbytesize
150 "https://github.com/storaged-project/libbytesize/releases/"
151 "download/" version "/libbytesize-" version ".tar.gz"))
154 "1aivwypmnqcaj2230pifvf3jcgl5chja8rspkxf0j3480asm8g5r"))))
155 (build-system gnu-build-system)
159 `(("gettext" ,gettext-minimal)
160 ("pkg-config" ,pkg-config)
165 (home-page "https://github.com/storaged-project/libbytesize")
166 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
168 "The goal of this project is to provide a tiny library that would
169 facilitate the common operations with sizes in bytes. Many projects need to
170 work with sizes in bytes (be it sizes of storage space, memory...) and all of
171 them need to deal with the same issues like:
174 @item How to get a human-readable string for the given size?
175 @item How to store the given size so that no significant information is lost?
176 @item If we store the size in bytes, what if the given size gets over the
178 @item How to interpret sizes entered by users according to their locale and
180 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
183 @code{libbytesize} offers a generally usable solution that could be used by
184 every project that needs to deal with sizes in bytes. It is written in the C
185 language with thin bindings for other languages.")
186 (license license:lgpl2.1+)))
188 (define-public udunits
191 ;; Four-part version numbers are development snapshots, not releases. See
192 ;; <https://github.com/Unidata/UDUNITS-2/issues/99#issuecomment-732323472>.
196 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
197 "udunits-" version ".tar.gz"))
200 "17jpbp6f0rr132jn2gqy8ry8mv1w27v6dyhfq1igv8v1674aw2sr"))))
201 (build-system gnu-build-system)
204 (list "--disable-static")))
207 (home-page "https://www.unidata.ucar.edu/software/udunits/")
208 (synopsis "C library for units of physical quantities and value-conversion utils")
210 "The UDUNITS-2 package provides support for units of physical quantities.
211 Its three main components are:
214 @item @code{udunits2lib}, a C library for units of physical quantities;
215 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
216 and for converting numeric values between compatible units; and
217 @item an extensive database of units.
219 ;; Like the BSD-3 license but with an extra anti patent clause.
220 (license (license:non-copyleft "file://COPYRIGHT"))))
222 (define-public libfixposix
226 (home-page "https://github.com/sionescu/libfixposix")
232 (commit (string-append "v" version))))
233 (file-name (git-file-name name version))
236 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
237 (build-system gnu-build-system)
239 `(("autoconf" ,autoconf)
240 ("automake" ,automake)
242 ("pkg-config" ,pkg-config)
244 (synopsis "Thin wrapper over POSIX syscalls")
246 "The purpose of libfixposix is to offer replacements for parts of POSIX
247 whose behaviour is inconsistent across *NIX flavours.")
248 (license license:boost1.0)))
257 (uri (string-append "mirror://sourceforge/libhx/libHX/"
258 "libHX-" version ".tar.xz"))
260 (base32 "12avn16f8aqb0cq6jplz0sv7rh6f07m85dwc8dasnnwsvijwbpbj"))))
261 (build-system gnu-build-system)
262 (home-page "http://libhx.sourceforge.net")
263 (synopsis "C library with common data structures and functions")
265 "This is a C library (with some C++ bindings available) that provides data
266 structures and functions commonly needed, such as maps, deques, linked lists,
267 string formatting and autoresizing, option and config file parsing, type
268 checking casts and more.")
269 (license license:lgpl2.1+)))
271 (define-public libwuya
272 ;; This commit is the one before "wuy_pool.h" was removed from libwuya,
273 ;; which libleak currently requires.
275 (commit "883502041044f4616cfbf75c8f2bb60059f704a9"))
278 (version (git-version "0.0" revision commit))
282 (url "https://github.com/WuBingzheng/libwuya")
284 (file-name (git-file-name name version))
287 "1xrsqbgr13g2v0ag165ryp7xrwzv41xfygzk2a3445ca98c1qpdc"))))
288 (build-system gnu-build-system)
290 `(#:tests? #f ;no test suite
291 #:phases (modify-phases %standard-phases
292 (add-after 'unpack 'patch-lua-includes
294 (substitute* '("wuy_cflua.h" "wuy_cflua.c")
295 (("<lua5\\.1/") "<"))
297 (add-after 'unpack 'add--fPIC-to-CFLAGS
299 (substitute* "Makefile"
300 (("CFLAGS[^\n]*" all)
301 (string-append all " -fPIC")))
303 (add-before 'build 'set-CC
307 (delete 'configure) ;no configure script
309 (lambda* (#:key outputs #:allow-other-keys)
310 (let* ((out (assoc-ref outputs "out"))
311 (include-dir (string-append out "/include"))
312 (headers (find-files "." "\\.h$")))
313 (for-each (lambda (h)
314 (install-file h include-dir))
316 (install-file "libwuya.a" (string-append out "/lib"))
318 (inputs `(("lua" ,lua)))
319 (home-page "https://github.com/WuBingzheng/libwuya/")
320 (synopsis "C library implementing various data structures")
321 (description "The @code{libwuya} library implements data structures such
322 as dictionaries, skip lists, and memory pools.")
323 ;; There is no clear information as to what license this is distributed
324 ;; under, but it is included (bundled) with libleak from the same author
325 ;; under the GNU GPL v2 or later license, so use this here until it is
326 ;; clarified (see: https://github.com/WuBingzheng/libwuya/issues/2).
327 (license license:gpl2+))))
329 (define-public packcc
332 ;; We need a few fixes on top of the latest release to prevent test
333 ;; failures in Universal Ctags.
334 (version "1.2.5-19-g58d1b9d")
335 (home-page "https://github.com/enechaev/packcc")
340 (commit (string-append "v" version))))
341 (file-name (git-file-name name version))
344 "0biyv835jlk43fvmmd3p8jafs7k2iw9qlaj37hvsl604ai6rd5aj"))))
345 (build-system gnu-build-system)
347 '(#:tests? #f ;no tests
348 #:make-flags '("-DUSE_SYSTEM_STRNLEN=1")
349 #:phases (modify-phases %standard-phases
350 ;; The project consists of a single source file and has
351 ;; no actual build system, so we need to do it manually.
354 (lambda* (#:key make-flags #:allow-other-keys)
355 (apply invoke "gcc" "-o" "packcc" "packcc.c"
358 (lambda* (#:key outputs #:allow-other-keys)
359 (let ((out (assoc-ref outputs "out")))
360 (install-file "packcc" (string-append out "/bin"))
361 (install-file "README.md"
362 (string-append out "/share/doc/packcc"))
364 (synopsis "Packrat parser generator for C")
366 "PackCC is a packrat parser generator for the C programming language.
367 Its main features are:
369 @item Generates a parser in C from a grammar described in a PEG.
370 @item Gives your parser great efficiency by packrat parsing.
371 @item Supports direct and indirect left-recursive grammar rules.
373 The grammar of your parser can be described in a @acronym{PEG, Parsing
374 Expression Grammar}. The PEG is a top-down parsing language, and is similar
375 to the regular-expression grammar. The PEG does not require tokenization to
376 be a separate step, and tokenization rules can be written in the same way as
377 any other grammar rules.")
378 (license license:expat)))
380 (define-public sparse
387 (string-append "mirror://kernel.org/software/devel/sparse/dist/"
388 "sparse-" version ".tar.xz"))
391 "16d8c4dhipjzjf8z4z7pix1pdpqydz0v4r7i345f5s09hjnxpxnl"))))
392 (build-system gnu-build-system)
393 (inputs `(("perl" ,perl)))
395 '(#:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
396 #:phases (modify-phases %standard-phases
398 (add-after 'unpack 'patch-cgcc
401 (("'cc'") (string-append "'" (which "gcc") "'")))
403 (synopsis "Semantic C parser for Linux development")
405 "Sparse is a semantic parser for C and is required for Linux development.
406 It provides a compiler frontend capable of parsing most of ANSI C as well as
407 many GCC extensions, and a collection of sample compiler backends, including a
408 static analyzer also called @file{sparse}. Sparse provides a set of
409 annotations designed to convey semantic information about types, such as what
410 address space pointers point to, or what locks a function acquires or
412 (home-page "https://sparse.wiki.kernel.org/index.php/Main_Page")
413 (license license:expat)))
415 (define-public libestr
423 (url "https://github.com/rsyslog/libestr")
424 (commit (string-append "v" version))))
425 (file-name (git-file-name name version))
428 "1ca4rj90c0dn7kqpbcchkflxjw88a7rxcnwbr0gply4a28i01nd8"))))
429 (build-system gnu-build-system)
432 (modify-phases %standard-phases
433 ;; autogen.sh calls configure at the end of the script.
435 (lambda _ (invoke "autoreconf" "-vfi"))))))
437 `(("autoconf" ,autoconf)
438 ("automake" ,automake)
439 ("pkg-config" ,pkg-config)
440 ("libtool" ,libtool)))
441 (home-page "https://github.com/rsyslog/libestr")
442 (synopsis "Helper functions for handling strings")
444 "This C library contains some essential string manipulation functions and
445 more, like escaping special characters.")
446 (license license:lgpl2.1+)))
448 (define-public libfastjson
456 (url "https://github.com/rsyslog/libfastjson")
457 (commit (string-append "v" version))))
458 (file-name (git-file-name name version))
460 (base32 "12rqcdqxazw8czzxbivdapdgj19pcswpw1jp2915sxbljis83g6q"))))
461 (build-system gnu-build-system)
463 `(("autoconf" ,autoconf)
464 ("automake" ,automake)
465 ("libtool" ,libtool)))
466 (home-page "https://github.com/rsyslog/libfastjson")
467 (synopsis "Fast JSON library for C")
469 "libfastjson is a fork from json-c aiming to provide: a small library
470 with essential JSON handling functions, sufficiently good JSON support (not
471 100% standards compliant), and very fast processing.")
472 (license license:expat)))
474 (define-public liblogging
482 (url "https://github.com/rsyslog/liblogging")
483 (commit (string-append "v" version))))
484 (file-name (git-file-name name version))
487 "1l32m0y65svf5vxsgw935jnqs6842rcqr56dmzwqvr00yfrjhjkp"))))
488 (build-system gnu-build-system)
491 (modify-phases %standard-phases
492 ;; autogen.sh calls configure at the end of the script.
494 (lambda _ (invoke "autoreconf" "-vfi"))))))
496 `(("autoconf" ,autoconf)
497 ("automake" ,automake)
498 ("pkg-config" ,pkg-config)
501 ("python-docutils" ,python-docutils)))
502 (home-page "https://github.com/rsyslog/liblogging")
503 (synopsis "Easy to use and lightweight signal-safe logging library")
505 "Liblogging is an easy to use library for logging. It offers an enhanced
506 replacement for the syslog() call, but retains its ease of use.")
507 (license license:bsd-2)))
509 (define-public unifdef
515 ;; https://dotat.at/prog/unifdef/unifdef-2.12.tar.xz
516 (uri (string-append "https://dotat.at/prog/" name "/"
517 name "-" version ".tar.xz"))
520 "00647bp3m9n01ck6ilw6r24fk4mivmimamvm4hxp5p6wxh10zkj3"))
521 (modules '((guix build utils)))
523 '(begin (delete-file-recursively "FreeBSD")
524 (delete-file-recursively "win32")
526 (build-system gnu-build-system)
528 `(#:phases (modify-phases %standard-phases
530 #:make-flags (list (string-append "CC=" ,(cc-for-target))
531 (string-append "prefix=" %output))
532 #:tests? #f)) ;no test suite
535 (home-page "https://dotat.at/prog/unifdef/")
536 (synopsis "Utility to selectively processes conditional C preprocessor")
537 (description "The @command{unifdef} utility selectively processes
538 conditional C preprocessor @code{#if} and @code{#ifdef} directives. It
539 removes from a file both the directives and the additional text that they
540 delimit, while otherwise leaving the file alone. It can be useful for
541 avoiding distractions when studying code that uses @code{#ifdef} heavily for
543 (license (list license:bsd-2 ;all files except...
544 license:bsd-3)))) ;...the unidef.1 manual page
546 (define-public aws-c-common
548 (name "aws-c-common")
553 (url (string-append "https://github.com/awslabs/" name))
554 (commit (string-append "v" version))))
555 (file-name (git-file-name name version))
558 "03fcvh3l1l6fkzkcbaprk10qmy8l77zhmh60h1px2ik09sqd9p72"))))
559 (build-system cmake-build-system)
562 '("-DBUILD_SHARED_LIBS=ON")))
563 (synopsis "Amazon Web Services core C library")
565 "This library provides common C99 primitives, configuration, data
566 structures, and error handling for the @acronym{AWS,Amazon Web Services} SDK.")
567 (home-page "https://github.com/awslabs/aws-c-common")
568 (license license:asl2.0)))
570 (define-public aws-checksums
572 (name "aws-checksums")
577 (url (string-append "https://github.com/awslabs/" name))
578 (commit (string-append "v" version))))
579 (file-name (git-file-name name version))
582 "1pjs31x3cq9wyw511y00kksz660m8im9zxk30hid8iwlilcbnyvx"))
583 (patches (search-patches "aws-checksums-cmake-prefix.patch"))))
584 (build-system cmake-build-system)
587 '("-DBUILD_SHARED_LIBS=ON")))
589 `(("aws-c-common" ,aws-c-common)))
590 (synopsis "Amazon Web Services checksum library")
592 "This library provides cross-Platform hardware accelerated CRC32c and CRC32
593 with fallback to efficient C99 software implementations.")
594 (home-page "https://github.com/awslabs/aws-checksums")
595 (license license:asl2.0)))
597 (define-public aws-c-event-stream
599 (name "aws-c-event-stream")
604 (url (string-append "https://github.com/awslabs/" name))
605 (commit (string-append "v" version))))
606 (file-name (git-file-name name version))
609 "0xwwr7gdgfrphk6j7vk12rgimfim6m4qnj6hg8hgg16cplhvsfzh"))
610 (patches (search-patches "aws-c-event-stream-cmake-prefix.patch"))))
611 (build-system cmake-build-system)
614 '("-DBUILD_SHARED_LIBS=ON")))
616 `(("aws-c-common" ,aws-c-common)
617 ("aws-c-io" ,aws-c-io)
618 ("aws-checksums" ,aws-checksums)))
620 `(("aws-c-cal" ,aws-c-cal)
622 (synopsis "Amazon Web Services client-server message format library")
624 "This library is a C99 implementation for @acronym{AWS,Amazon Web Services}
625 event stream encoding, a binary format for bidirectional client-server
627 (home-page "https://github.com/awslabs/aws-c-event-stream")
628 (license license:asl2.0)))
630 (define-public aws-c-io
637 (url (string-append "https://github.com/awslabs/" name))
638 (commit (string-append "v" version))))
639 (file-name (git-file-name name version))
642 "1vwyf1pm0hhcypyjc9xh9x7y50ic79xlbck1yf9d9wz0bnh43p7v"))
645 "aws-c-io-cmake-prefix.patch"
646 "aws-c-io-disable-networking-tests.patch"))))
647 (build-system cmake-build-system)
650 '("-DBUILD_SHARED_LIBS=ON")))
652 `(("aws-c-cal" ,aws-c-cal)
653 ("aws-c-common" ,aws-c-common)
655 (synopsis "Event driven framework for implementing application protocols")
656 (description "This library provides a C99 framework for constructing
657 event-driven, asynchronous network application protocols.")
658 (home-page "https://github.com/awslabs/aws-c-io")
659 (license license:asl2.0)))
661 (define-public aws-c-cal
668 (url (string-append "https://github.com/awslabs/" name))
669 (commit (string-append "v" version))))
670 (file-name (git-file-name name version))
673 "04acra1mnzw9q7jycs5966akfbgnx96hkrq90nq0dhw8pvarlyv6"))
674 (patches (search-patches "aws-c-cal-cmake-prefix.patch"))))
675 (build-system cmake-build-system)
678 '("-DBUILD_SHARED_LIBS=ON")))
680 `(("aws-c-common" ,aws-c-common)))
682 `(("openssl" ,openssl)
683 ("openssl:static" ,openssl "static")))
684 (synopsis "Amazon Web Services Crypto Abstraction Layer")
685 (description "This library provides a C99 wrapper for hash, HMAC, and ECC
686 cryptographic primitives for the @acronym{AWS,Amazon Web Services} SDK.")
687 (home-page "https://github.com/awslabs/aws-c-cal")
688 (license license:asl2.0)))