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 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>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages c)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system trivial)
31 #:use-module (gnu packages bootstrap)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages check)
34 #:use-module (gnu packages flex)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages texinfo)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages multiprecision)
39 #:use-module (gnu packages pcre)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages xml))
48 (name "tcc") ;aka. "tinycc"
52 (uri (string-append "mirror://savannah/tinycc/tcc-"
56 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
57 (build-system gnu-build-system)
58 (native-inputs `(("perl" ,perl)
59 ("texinfo" ,texinfo)))
61 `(#:configure-flags (list (string-append "--elfinterp="
62 (assoc-ref %build-inputs "libc")
63 ,(glibc-dynamic-linker))
64 (string-append "--crtprefix="
65 (assoc-ref %build-inputs "libc")
67 (string-append "--sysincludepaths="
68 (assoc-ref %build-inputs "libc")
70 (assoc-ref %build-inputs
72 "/include:{B}/include")
73 (string-append "--libpaths="
74 (assoc-ref %build-inputs "libc")
76 ,@(if (string-prefix? "armhf-linux"
77 (or (%current-target-system)
79 `("--triplet=arm-linux-gnueabihf")
81 #:test-target "test"))
82 ;; Fails to build on MIPS: "Unsupported CPU"
83 (supported-systems (delete "mips64el-linux" %supported-systems))
84 (synopsis "Tiny and fast C compiler")
86 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
87 written in C. It supports ANSI C with GNU and extensions and most of the C99
89 (home-page "http://www.tinycc.org/")
90 ;; An attempt to re-licence tcc under the Expat licence is underway but not
91 ;; (if ever) complete. See the RELICENSING file for more information.
92 (license license:lgpl2.1+)))
94 (define-public tcc-wrapper
98 (build-system trivial-build-system)
100 (inputs `(("tcc" ,tcc)
101 ("guile" ,guile-2.2)))
103 ;; By default TCC does not honor any search path environment variable.
104 ;; This wrapper adds them.
106 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
107 ;; RUNPATH is ineffective here. We should modify TCC itself.
109 (list (search-path-specification
110 (variable "TCC_CPATH")
111 (files '("include")))
112 (search-path-specification
113 (variable "TCC_LIBRARY_PATH")
114 (files '("lib" "lib64")))))
118 (let* ((out (assoc-ref %outputs "out"))
119 (bin (string-append out "/bin"))
120 (tcc (assoc-ref %build-inputs "tcc"))
121 (guile (assoc-ref %build-inputs "guile")))
124 (call-with-output-file (string-append bin "/cc")
126 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
129 (use-modules (ice-9 match)
133 (string-tokenize path (char-set-complement
136 (apply execl ,(string-append tcc "/bin/tcc")
137 ,(string-append tcc "/bin/tcc") ;argv[0]
138 (append (cdr (command-line))
139 (match (getenv "TCC_CPATH")
142 (map (cut string-append "-I" <>)
144 (match (getenv "TCC_LIBRARY_PATH")
147 (map (cut string-append "-L" <>)
152 (synopsis "Wrapper providing the 'cc' command for TCC")))
160 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
164 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
165 (build-system gnu-build-system)
168 (modify-phases %standard-phases
170 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
174 (synopsis "Portable C compiler")
176 "PCC is a portable C compiler. The project goal is to write a C99
177 compiler while still keeping it small, simple, fast and understandable.")
178 (home-page "http://pcc.ludd.ltu.se")
179 (supported-systems (delete "aarch64-linux" %supported-systems))
180 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
181 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
182 (license (list license:bsd-2 license:bsd-3))))
184 (define-public libbytesize
191 "https://github.com/storaged-project/libbytesize/releases/"
192 "download/" version "/libbytesize-" version ".tar.gz"))
195 "1bpz9cpb8s47kqplkkiz6ryfahas2ma95g9rh2axnfjp6w1d9ixc"))))
196 (build-system gnu-build-system)
200 `(("gettext" ,gettext-minimal)
201 ("pkg-config" ,pkg-config)
206 (home-page "https://github.com/storaged-project/libbytesize")
207 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
209 "The goal of this project is to provide a tiny library that would
210 facilitate the common operations with sizes in bytes. Many projects need to
211 work with sizes in bytes (be it sizes of storage space, memory...) and all of
212 them need to deal with the same issues like:
215 @item How to get a human-readable string for the given size?
216 @item How to store the given size so that no significant information is lost?
217 @item If we store the size in bytes, what if the given size gets over the
219 @item How to interpret sizes entered by users according to their locale and
221 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
224 @code{libbytesize} offers a generally usable solution that could be used by
225 every project that needs to deal with sizes in bytes. It is written in the C
226 language with thin bindings for other languages.")
227 (license license:lgpl2.1+)))
229 (define-public udunits
235 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
236 "udunits-" version ".tar.gz"))
239 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
240 (build-system gnu-build-system)
243 (home-page "https://www.unidata.ucar.edu/software/udunits/")
244 (synopsis "C library for units of physical quantities and value-conversion utils")
246 "The UDUNITS-2 package provides support for units of physical quantities.
247 Its three main components are:
250 @item @code{udunits2lib}, a C library for units of physical quantities;
251 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
252 and for converting numeric values between compatible units; and
253 @item an extensive database of units.
255 ;; Like the BSD-3 license but with an extra anti patent clause.
256 (license (license:non-copyleft "file://COPYRIGHT"))))
258 (define-public libfixposix
262 (home-page "https://github.com/sionescu/libfixposix")
268 (commit (string-append "v" version))))
269 (file-name (git-file-name name version))
272 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
273 (build-system gnu-build-system)
275 `(("autoconf" ,autoconf)
276 ("automake" ,automake)
278 ("pkg-config" ,pkg-config)
280 (synopsis "Thin wrapper over POSIX syscalls")
282 "The purpose of libfixposix is to offer replacements for parts of POSIX
283 whose behaviour is inconsistent across *NIX flavours.")
284 (license license:boost1.0)))
293 (uri (string-append "mirror://sourceforge/libhx/libHX/"
294 "libHX-" version ".tar.xz"))
297 "0i8v2464p830c15myknvvs6bhxaf663lrqgga95l94ygfynkw6x5"))))
298 (build-system gnu-build-system)
299 (home-page "http://libhx.sourceforge.net")
300 (synopsis "C library with common data structures and functions")
302 "This is a C library (with some C++ bindings available) that provides data
303 structures and functions commonly needed, such as maps, deques, linked lists,
304 string formatting and autoresizing, option and config file parsing, type
305 checking casts and more.")
306 (license license:lgpl2.1+)))