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 "0bbqzln1nhjxl71aydq9k4jg3hvki9lqsb4w10s1i27jgibxqkdv"))
195 (modules '((guix build utils)))
198 ;; This Makefile hard-codes MSGMERGE et al. instead of
199 ;; honoring what 'configure' detected. Fix that.
200 (substitute* "po/Makefile.in"
201 (("^MSGMERGE = msgmerge")
202 "MSGMERGE = @MSGMERGE@\n"))
204 (build-system gnu-build-system)
206 ;; When running "make", the POT files are built with the build time as
207 ;; their "POT-Creation-Date". Later on, "make" notices that .pot
208 ;; files were updated and goes on to run "msgmerge"; as a result, the
209 ;; non-deterministic POT-Creation-Date finds its way into .po files,
210 ;; and then in .gmo files. To avoid that, simply make sure 'msgmerge'
211 ;; never runs. See <https://bugs.debian.org/792687>.
212 '(#:configure-flags '("ac_cv_path_MSGMERGE=true")
214 #:phases (modify-phases %standard-phases
215 (add-after 'configure 'create-merged-po-files
217 ;; Create "merged PO" (.mpo) files so that 'msgmerge'
218 ;; doesn't need to run.
219 (for-each (lambda (po-file)
221 (string-append (dirname po-file) "/"
225 (copy-file po-file merged-po)))
226 (find-files "po" "\\.po$"))
229 ;; One test fails because busctl (systemd only?) and python2-pocketlint
230 ;; are missing. Should we fix it, we would need the "python-2" ,
231 ;; "python2-polib" and "python2-six" native-inputs.
234 `(("gettext" ,gettext-minimal)
235 ("pkg-config" ,pkg-config)
240 (home-page "https://github.com/storaged-project/libbytesize")
241 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
243 "The goal of this project is to provide a tiny library that would
244 facilitate the common operations with sizes in bytes. Many projects need to
245 work with sizes in bytes (be it sizes of storage space, memory...) and all of
246 them need to deal with the same issues like:
249 @item How to get a human-readable string for the given size?
250 @item How to store the given size so that no significant information is lost?
251 @item If we store the size in bytes, what if the given size gets over the
253 @item How to interpret sizes entered by users according to their locale and
255 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
258 @code{libbytesize} offers a generally usable solution that could be used by
259 every project that needs to deal with sizes in bytes. It is written in the C
260 language with thin bindings for other languages.")
261 (license license:lgpl2.1+)))
263 (define-public udunits
269 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
270 "udunits-" version ".tar.gz"))
273 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
274 (build-system gnu-build-system)
277 (home-page "https://www.unidata.ucar.edu/software/udunits/")
278 (synopsis "C library for units of physical quantities and value-conversion utils")
280 "The UDUNITS-2 package provides support for units of physical quantities.
281 Its three main components are:
284 @item @code{udunits2lib}, a C library for units of physical quantities;
285 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
286 and for converting numeric values between compatible units; and
287 @item an extensive database of units.
289 ;; Like the BSD-3 license but with an extra anti patent clause.
290 (license (license:non-copyleft "file://COPYRIGHT"))))
292 (define-public libfixposix
296 (home-page "https://github.com/sionescu/libfixposix")
302 (commit (string-append "v" version))))
303 (file-name (git-file-name name version))
306 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
307 (build-system gnu-build-system)
309 `(("autoconf" ,autoconf)
310 ("automake" ,automake)
312 ("pkg-config" ,pkg-config)
314 (synopsis "Thin wrapper over POSIX syscalls")
316 "The purpose of libfixposix is to offer replacements for parts of POSIX
317 whose behaviour is inconsistent across *NIX flavours.")
318 (license license:boost1.0)))