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>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages c)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages check)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages texinfo)
36 #:use-module (gnu packages guile)
37 #:use-module (gnu packages multiprecision)
38 #:use-module (gnu packages pcre)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages xml))
47 (name "tcc") ;aka. "tinycc"
51 (uri (string-append "mirror://savannah/tinycc/tcc-"
55 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
56 (build-system gnu-build-system)
57 (native-inputs `(("perl" ,perl)
58 ("texinfo" ,texinfo)))
60 `(#:configure-flags (list (string-append "--elfinterp="
61 (assoc-ref %build-inputs "libc")
62 ,(glibc-dynamic-linker))
63 (string-append "--crtprefix="
64 (assoc-ref %build-inputs "libc")
66 (string-append "--sysincludepaths="
67 (assoc-ref %build-inputs "libc")
69 (assoc-ref %build-inputs
71 "/include:{B}/include")
72 (string-append "--libpaths="
73 (assoc-ref %build-inputs "libc")
75 ,@(if (string-prefix? "armhf-linux"
76 (or (%current-target-system)
78 `("--triplet=arm-linux-gnueabihf")
80 #:test-target "test"))
81 ;; Fails to build on MIPS: "Unsupported CPU"
82 (supported-systems (delete "mips64el-linux" %supported-systems))
83 (synopsis "Tiny and fast C compiler")
85 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
86 written in C. It supports ANSI C with GNU and extensions and most of the C99
88 (home-page "http://www.tinycc.org/")
89 ;; An attempt to re-licence tcc under the Expat licence is underway but not
90 ;; (if ever) complete. See the RELICENSING file for more information.
91 (license license:lgpl2.1+)))
93 (define-public tcc-wrapper
97 (build-system trivial-build-system)
99 (inputs `(("tcc" ,tcc)
100 ("guile" ,guile-2.2)))
102 ;; By default TCC does not honor any search path environment variable.
103 ;; This wrapper adds them.
105 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
106 ;; RUNPATH is ineffective here. We should modify TCC itself.
108 (list (search-path-specification
109 (variable "TCC_CPATH")
110 (files '("include")))
111 (search-path-specification
112 (variable "TCC_LIBRARY_PATH")
113 (files '("lib" "lib64")))))
117 (let* ((out (assoc-ref %outputs "out"))
118 (bin (string-append out "/bin"))
119 (tcc (assoc-ref %build-inputs "tcc"))
120 (guile (assoc-ref %build-inputs "guile")))
123 (call-with-output-file (string-append bin "/cc")
125 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
128 (use-modules (ice-9 match)
132 (string-tokenize path (char-set-complement
135 (apply execl ,(string-append tcc "/bin/tcc")
136 ,(string-append tcc "/bin/tcc") ;argv[0]
137 (append (cdr (command-line))
138 (match (getenv "TCC_CPATH")
141 (map (cut string-append "-I" <>)
143 (match (getenv "TCC_LIBRARY_PATH")
146 (map (cut string-append "-L" <>)
151 (synopsis "Wrapper providing the 'cc' command for TCC")))
159 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
163 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
164 (build-system gnu-build-system)
167 (modify-phases %standard-phases
169 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
173 (synopsis "Portable C compiler")
175 "PCC is a portable C compiler. The project goal is to write a C99
176 compiler while still keeping it small, simple, fast and understandable.")
177 (home-page "http://pcc.ludd.ltu.se")
178 (supported-systems (delete "aarch64-linux" %supported-systems))
179 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
180 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
181 (license (list license:bsd-2 license:bsd-3))))
183 (define-public libbytesize
190 "https://github.com/storaged-project/libbytesize/releases/"
191 "download/" version "/libbytesize-" version ".tar.gz"))
194 "1bpz9cpb8s47kqplkkiz6ryfahas2ma95g9rh2axnfjp6w1d9ixc"))))
195 (build-system gnu-build-system)
199 `(("gettext" ,gettext-minimal)
200 ("pkg-config" ,pkg-config)
205 (home-page "https://github.com/storaged-project/libbytesize")
206 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
208 "The goal of this project is to provide a tiny library that would
209 facilitate the common operations with sizes in bytes. Many projects need to
210 work with sizes in bytes (be it sizes of storage space, memory...) and all of
211 them need to deal with the same issues like:
214 @item How to get a human-readable string for the given size?
215 @item How to store the given size so that no significant information is lost?
216 @item If we store the size in bytes, what if the given size gets over the
218 @item How to interpret sizes entered by users according to their locale and
220 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
223 @code{libbytesize} offers a generally usable solution that could be used by
224 every project that needs to deal with sizes in bytes. It is written in the C
225 language with thin bindings for other languages.")
226 (license license:lgpl2.1+)))
228 (define-public udunits
234 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
235 "udunits-" version ".tar.gz"))
238 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
239 (build-system gnu-build-system)
242 (home-page "https://www.unidata.ucar.edu/software/udunits/")
243 (synopsis "C library for units of physical quantities and value-conversion utils")
245 "The UDUNITS-2 package provides support for units of physical quantities.
246 Its three main components are:
249 @item @code{udunits2lib}, a C library for units of physical quantities;
250 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
251 and for converting numeric values between compatible units; and
252 @item an extensive database of units.
254 ;; Like the BSD-3 license but with an extra anti patent clause.
255 (license (license:non-copyleft "file://COPYRIGHT"))))
257 (define-public libfixposix
261 (home-page "https://github.com/sionescu/libfixposix")
267 (commit (string-append "v" version))))
268 (file-name (git-file-name name version))
271 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
272 (build-system gnu-build-system)
274 `(("autoconf" ,autoconf)
275 ("automake" ,automake)
277 ("pkg-config" ,pkg-config)
279 (synopsis "Thin wrapper over POSIX syscalls")
281 "The purpose of libfixposix is to offer replacements for parts of POSIX
282 whose behaviour is inconsistent across *NIX flavours.")
283 (license license:boost1.0)))