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>
14 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
55 (name "tcc") ;aka. "tinycc"
59 (uri (string-append "mirror://savannah/tinycc/tcc-"
63 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
64 (build-system gnu-build-system)
65 (native-inputs `(("perl" ,perl)
66 ("texinfo" ,texinfo)))
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")
74 (string-append "--sysincludepaths="
75 (assoc-ref %build-inputs "libc")
77 (assoc-ref %build-inputs
79 "/include:{B}/include")
80 (string-append "--libpaths="
81 (assoc-ref %build-inputs "libc")
83 ,@(if (string-prefix? "armhf-linux"
84 (or (%current-target-system)
86 `("--triplet=arm-linux-gnueabihf")
88 #:test-target "test"))
90 (list (search-path-specification
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")
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
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+)))
114 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
118 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
119 (build-system gnu-build-system)
122 (modify-phases %standard-phases
124 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
128 (synopsis "Portable C compiler")
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))))
138 (define-public libbytesize
145 "https://github.com/storaged-project/libbytesize/releases/"
146 "download/" version "/libbytesize-" version ".tar.gz"))
149 "1aivwypmnqcaj2230pifvf3jcgl5chja8rspkxf0j3480asm8g5r"))))
150 (build-system gnu-build-system)
154 `(("gettext" ,gettext-minimal)
155 ("pkg-config" ,pkg-config)
160 (home-page "https://github.com/storaged-project/libbytesize")
161 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
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:
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
173 @item How to interpret sizes entered by users according to their locale and
175 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
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+)))
183 (define-public udunits
189 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
190 "udunits-" version ".tar.gz"))
193 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
194 (build-system gnu-build-system)
197 (home-page "https://www.unidata.ucar.edu/software/udunits/")
198 (synopsis "C library for units of physical quantities and value-conversion utils")
200 "The UDUNITS-2 package provides support for units of physical quantities.
201 Its three main components are:
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.
209 ;; Like the BSD-3 license but with an extra anti patent clause.
210 (license (license:non-copyleft "file://COPYRIGHT"))))
212 (define-public libfixposix
216 (home-page "https://github.com/sionescu/libfixposix")
222 (commit (string-append "v" version))))
223 (file-name (git-file-name name version))
226 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
227 (build-system gnu-build-system)
229 `(("autoconf" ,autoconf)
230 ("automake" ,automake)
232 ("pkg-config" ,pkg-config)
234 (synopsis "Thin wrapper over POSIX syscalls")
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)))
247 (uri (string-append "mirror://sourceforge/libhx/libHX/"
248 "libHX-" version ".tar.xz"))
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")
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+)))
261 (define-public libwuya
262 ;; This commit is the one before "wuy_pool.h" was removed from libwuya,
263 ;; which libleak currently requires.
265 (commit "883502041044f4616cfbf75c8f2bb60059f704a9"))
268 (version (git-version "0.0" revision commit))
272 (url "https://github.com/WuBingzheng/libwuya")
274 (file-name (git-file-name name version))
277 "1xrsqbgr13g2v0ag165ryp7xrwzv41xfygzk2a3445ca98c1qpdc"))))
278 (build-system gnu-build-system)
280 `(#:tests? #f ;no test suite
281 #:phases (modify-phases %standard-phases
282 (add-after 'unpack 'patch-lua-includes
284 (substitute* '("wuy_cflua.h" "wuy_cflua.c")
285 (("<lua5\\.1/") "<"))
287 (add-after 'unpack 'add--fPIC-to-CFLAGS
289 (substitute* "Makefile"
290 (("CFLAGS[^\n]*" all)
291 (string-append all " -fPIC")))
293 (add-before 'build 'set-CC
297 (delete 'configure) ;no configure script
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))
306 (install-file "libwuya.a" (string-append out "/lib"))
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+))))
319 (define-public 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")
330 (commit (string-append "v" version))))
331 (file-name (git-file-name name version))
334 "0biyv835jlk43fvmmd3p8jafs7k2iw9qlaj37hvsl604ai6rd5aj"))))
335 (build-system gnu-build-system)
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.
344 (lambda* (#:key make-flags #:allow-other-keys)
345 (apply invoke "gcc" "-o" "packcc" "packcc.c"
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"))
354 (synopsis "Packrat parser generator for C")
356 "PackCC is a packrat parser generator for the C programming language.
357 Its main features are:
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.
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)))
370 (define-public sparse
377 (string-append "mirror://kernel.org/software/devel/sparse/dist/"
378 "sparse-" version ".tar.xz"))
381 "16d8c4dhipjzjf8z4z7pix1pdpqydz0v4r7i345f5s09hjnxpxnl"))))
382 (build-system gnu-build-system)
383 (inputs `(("perl" ,perl)))
385 '(#:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
386 #:phases (modify-phases %standard-phases
388 (add-after 'unpack 'patch-cgcc
391 (("'cc'") (string-append "'" (which "gcc") "'")))
393 (synopsis "Semantic C parser for Linux development")
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
402 (home-page "https://sparse.wiki.kernel.org/index.php/Main_Page")
403 (license license:expat)))
405 (define-public libestr
413 (url "https://github.com/rsyslog/libestr")
414 (commit (string-append "v" version))))
415 (file-name (git-file-name name version))
418 "1ca4rj90c0dn7kqpbcchkflxjw88a7rxcnwbr0gply4a28i01nd8"))))
419 (build-system gnu-build-system)
422 (modify-phases %standard-phases
423 ;; autogen.sh calls configure at the end of the script.
425 (lambda _ (invoke "autoreconf" "-vfi"))))))
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")
434 "This C library contains some essential string manipulation functions and
435 more, like escaping special characters.")
436 (license license:lgpl2.1+)))
438 (define-public libfastjson
446 (url "https://github.com/rsyslog/libfastjson")
447 (commit (string-append "v" version))))
448 (file-name (git-file-name name version))
451 "0qhs0g9slj3p0v2z4s3cnsx44msrlb4k78ljg7714qiziqbrbwyl"))))
452 (build-system gnu-build-system)
454 `(("autoconf" ,autoconf)
455 ("automake" ,automake)
456 ("libtool" ,libtool)))
457 (home-page "https://github.com/rsyslog/libfastjson")
458 (synopsis "Fast JSON library for C")
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)))
465 (define-public liblogging
473 (url "https://github.com/rsyslog/liblogging")
474 (commit (string-append "v" version))))
475 (file-name (git-file-name name version))
478 "1l32m0y65svf5vxsgw935jnqs6842rcqr56dmzwqvr00yfrjhjkp"))))
479 (build-system gnu-build-system)
482 (modify-phases %standard-phases
483 ;; autogen.sh calls configure at the end of the script.
485 (lambda _ (invoke "autoreconf" "-vfi"))))))
487 `(("autoconf" ,autoconf)
488 ("automake" ,automake)
489 ("pkg-config" ,pkg-config)
492 ("python-docutils" ,python-docutils)))
493 (home-page "https://github.com/rsyslog/liblogging")
494 (synopsis "Easy to use and lightweight signal-safe logging library")
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)))
500 (define-public unifdef
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"))
511 "00647bp3m9n01ck6ilw6r24fk4mivmimamvm4hxp5p6wxh10zkj3"))
512 (modules '((guix build utils)))
514 '(begin (delete-file-recursively "FreeBSD")
515 (delete-file-recursively "win32")
517 (build-system gnu-build-system)
519 `(#:phases (modify-phases %standard-phases
521 #:make-flags (list "CC=gcc" (string-append "prefix=" %output))
522 #:tests? #f)) ;no test suite
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
533 (license (list license:bsd-2 ;all files except...
534 license:bsd-3)))) ;...the unidef.1 manual page