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>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages c)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system trivial)
34 #:use-module (gnu packages bootstrap)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages texinfo)
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages multiprecision)
42 #:use-module (gnu packages pcre)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages gettext)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages xml))
51 (name "tcc") ;aka. "tinycc"
55 (uri (string-append "mirror://savannah/tinycc/tcc-"
59 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
60 (build-system gnu-build-system)
61 (native-inputs `(("perl" ,perl)
62 ("texinfo" ,texinfo)))
64 `(#:configure-flags (list (string-append "--elfinterp="
65 (assoc-ref %build-inputs "libc")
66 ,(glibc-dynamic-linker))
67 (string-append "--crtprefix="
68 (assoc-ref %build-inputs "libc")
70 (string-append "--sysincludepaths="
71 (assoc-ref %build-inputs "libc")
73 (assoc-ref %build-inputs
75 "/include:{B}/include")
76 (string-append "--libpaths="
77 (assoc-ref %build-inputs "libc")
79 ,@(if (string-prefix? "armhf-linux"
80 (or (%current-target-system)
82 `("--triplet=arm-linux-gnueabihf")
84 #:test-target "test"))
86 (list (search-path-specification
89 (search-path-specification
90 (variable "LIBRARY_PATH")
91 (files '("lib" "lib64")))))
92 ;; Fails to build on MIPS: "Unsupported CPU"
93 (supported-systems (delete "mips64el-linux" %supported-systems))
94 (synopsis "Tiny and fast C compiler")
96 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
97 written in C. It supports ANSI C with GNU and extensions and most of the C99
99 (home-page "http://www.tinycc.org/")
100 ;; An attempt to re-licence tcc under the Expat licence is underway but not
101 ;; (if ever) complete. See the RELICENSING file for more information.
102 (license license:lgpl2.1+)))
110 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
114 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
115 (build-system gnu-build-system)
118 (modify-phases %standard-phases
120 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
124 (synopsis "Portable C compiler")
126 "PCC is a portable C compiler. The project goal is to write a C99
127 compiler while still keeping it small, simple, fast and understandable.")
128 (home-page "http://pcc.ludd.ltu.se")
129 (supported-systems (delete "aarch64-linux" %supported-systems))
130 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
131 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
132 (license (list license:bsd-2 license:bsd-3))))
134 (define-public libbytesize
141 "https://github.com/storaged-project/libbytesize/releases/"
142 "download/" version "/libbytesize-" version ".tar.gz"))
145 "1aivwypmnqcaj2230pifvf3jcgl5chja8rspkxf0j3480asm8g5r"))))
146 (build-system gnu-build-system)
150 `(("gettext" ,gettext-minimal)
151 ("pkg-config" ,pkg-config)
156 (home-page "https://github.com/storaged-project/libbytesize")
157 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
159 "The goal of this project is to provide a tiny library that would
160 facilitate the common operations with sizes in bytes. Many projects need to
161 work with sizes in bytes (be it sizes of storage space, memory...) and all of
162 them need to deal with the same issues like:
165 @item How to get a human-readable string for the given size?
166 @item How to store the given size so that no significant information is lost?
167 @item If we store the size in bytes, what if the given size gets over the
169 @item How to interpret sizes entered by users according to their locale and
171 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
174 @code{libbytesize} offers a generally usable solution that could be used by
175 every project that needs to deal with sizes in bytes. It is written in the C
176 language with thin bindings for other languages.")
177 (license license:lgpl2.1+)))
179 (define-public udunits
185 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
186 "udunits-" version ".tar.gz"))
189 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
190 (build-system gnu-build-system)
193 (home-page "https://www.unidata.ucar.edu/software/udunits/")
194 (synopsis "C library for units of physical quantities and value-conversion utils")
196 "The UDUNITS-2 package provides support for units of physical quantities.
197 Its three main components are:
200 @item @code{udunits2lib}, a C library for units of physical quantities;
201 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
202 and for converting numeric values between compatible units; and
203 @item an extensive database of units.
205 ;; Like the BSD-3 license but with an extra anti patent clause.
206 (license (license:non-copyleft "file://COPYRIGHT"))))
208 (define-public libfixposix
212 (home-page "https://github.com/sionescu/libfixposix")
218 (commit (string-append "v" version))))
219 (file-name (git-file-name name version))
222 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
223 (build-system gnu-build-system)
225 `(("autoconf" ,autoconf)
226 ("automake" ,automake)
228 ("pkg-config" ,pkg-config)
230 (synopsis "Thin wrapper over POSIX syscalls")
232 "The purpose of libfixposix is to offer replacements for parts of POSIX
233 whose behaviour is inconsistent across *NIX flavours.")
234 (license license:boost1.0)))
243 (uri (string-append "mirror://sourceforge/libhx/libHX/"
244 "libHX-" version ".tar.xz"))
247 "0i8v2464p830c15myknvvs6bhxaf663lrqgga95l94ygfynkw6x5"))))
248 (build-system gnu-build-system)
249 (home-page "http://libhx.sourceforge.net")
250 (synopsis "C library with common data structures and functions")
252 "This is a C library (with some C++ bindings available) that provides data
253 structures and functions commonly needed, such as maps, deques, linked lists,
254 string formatting and autoresizing, option and config file parsing, type
255 checking casts and more.")
256 (license license:lgpl2.1+)))
258 (define-public packcc
261 ;; We need a few fixes on top of the latest release to prevent test
262 ;; failures in Universal Ctags.
263 (version "1.2.5-19-g58d1b9d")
264 (home-page "https://github.com/enechaev/packcc")
269 (commit (string-append "v" version))))
270 (file-name (git-file-name name version))
273 "0biyv835jlk43fvmmd3p8jafs7k2iw9qlaj37hvsl604ai6rd5aj"))))
274 (build-system gnu-build-system)
276 '(#:tests? #f ;no tests
277 #:make-flags '("-DUSE_SYSTEM_STRNLEN=1")
278 #:phases (modify-phases %standard-phases
279 ;; The project consists of a single source file and has
280 ;; no actual build system, so we need to do it manually.
283 (lambda* (#:key make-flags #:allow-other-keys)
284 (apply invoke "gcc" "-o" "packcc" "packcc.c"
287 (lambda* (#:key outputs #:allow-other-keys)
288 (let ((out (assoc-ref outputs "out")))
289 (install-file "packcc" (string-append out "/bin"))
290 (install-file "README.md"
291 (string-append out "/share/doc/packcc"))
293 (synopsis "Packrat parser generator for C")
295 "PackCC is a packrat parser generator for the C programming language.
296 Its main features are:
298 @item Generates a parser in C from a grammar described in a PEG.
299 @item Gives your parser great efficiency by packrat parsing.
300 @item Supports direct and indirect left-recursive grammar rules.
302 The grammar of your parser can be described in a @acronym{PEG, Parsing
303 Expression Grammar}. The PEG is a top-down parsing language, and is similar
304 to the regular-expression grammar. The PEG does not require tokenization to
305 be a separate step, and tokenization rules can be written in the same way as
306 any other grammar rules.")
307 (license license:expat)))
309 (define-public sparse
316 (string-append "mirror://kernel.org/software/devel/sparse/dist/"
317 "sparse-" version ".tar.xz"))
320 "0qavyryxmhd1rf11akgn1nq3r15k11bqa3qajaq36a56r225rc7x"))))
321 (build-system gnu-build-system)
322 (inputs `(("perl" ,perl)))
324 '(#:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out")))
325 #:phases (modify-phases %standard-phases
327 (add-after 'unpack 'patch-cgcc
330 (("'cc'") (string-append "'" (which "gcc") "'")))
332 (synopsis "Semantic C parser for Linux development")
334 "Sparse is a semantic parser for C and is required for Linux development.
335 It provides a compiler frontend capable of parsing most of ANSI C as well as
336 many GCC extensions, and a collection of sample compiler backends, including a
337 static analyzer also called @file{sparse}. Sparse provides a set of
338 annotations designed to convey semantic information about types, such as what
339 address space pointers point to, or what locks a function acquires or
341 (home-page "https://sparse.wiki.kernel.org/index.php/Main_Page")
342 (license license:expat)))