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 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 flex)
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages texinfo)
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages multiprecision)
37 #:use-module (gnu packages pcre)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages autotools)
40 #:use-module (gnu packages gettext)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages xml))
46 (name "tcc") ;aka. "tinycc"
50 (uri (string-append "mirror://savannah/tinycc/tcc-"
54 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
55 (build-system gnu-build-system)
56 (native-inputs `(("perl" ,perl)
57 ("texinfo" ,texinfo)))
59 `(#:configure-flags (list (string-append "--elfinterp="
60 (assoc-ref %build-inputs "libc")
61 ,(glibc-dynamic-linker))
62 (string-append "--crtprefix="
63 (assoc-ref %build-inputs "libc")
65 (string-append "--sysincludepaths="
66 (assoc-ref %build-inputs "libc")
68 (assoc-ref %build-inputs
70 "/include:{B}/include")
71 (string-append "--libpaths="
72 (assoc-ref %build-inputs "libc")
74 ,@(if (string-prefix? "armhf-linux"
75 (or (%current-target-system)
77 `("--triplet=arm-linux-gnueabihf")
79 #:test-target "test"))
80 ;; Fails to build on MIPS: "Unsupported CPU"
81 (supported-systems (delete "mips64el-linux" %supported-systems))
82 (synopsis "Tiny and fast C compiler")
84 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
85 written in C. It supports ANSI C with GNU and extensions and most of the C99
87 (home-page "http://www.tinycc.org/")
88 ;; An attempt to re-licence tcc under the Expat licence is underway but not
89 ;; (if ever) complete. See the RELICENSING file for more information.
90 (license license:lgpl2.1+)))
92 (define-public tcc-wrapper
96 (build-system trivial-build-system)
98 (inputs `(("tcc" ,tcc)
99 ("guile" ,guile-2.2)))
101 ;; By default TCC does not honor any search path environment variable.
102 ;; This wrapper adds them.
104 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
105 ;; RUNPATH is ineffective here. We should modify TCC itself.
107 (list (search-path-specification
108 (variable "TCC_CPATH")
109 (files '("include")))
110 (search-path-specification
111 (variable "TCC_LIBRARY_PATH")
112 (files '("lib" "lib64")))))
116 (let* ((out (assoc-ref %outputs "out"))
117 (bin (string-append out "/bin"))
118 (tcc (assoc-ref %build-inputs "tcc"))
119 (guile (assoc-ref %build-inputs "guile")))
122 (call-with-output-file (string-append bin "/cc")
124 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
127 (use-modules (ice-9 match)
131 (string-tokenize path (char-set-complement
134 (apply execl ,(string-append tcc "/bin/tcc")
135 ,(string-append tcc "/bin/tcc") ;argv[0]
136 (append (cdr (command-line))
137 (match (getenv "TCC_CPATH")
140 (map (cut string-append "-I" <>)
142 (match (getenv "TCC_LIBRARY_PATH")
145 (map (cut string-append "-L" <>)
150 (synopsis "Wrapper providing the 'cc' command for TCC")))
158 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
162 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
163 (build-system gnu-build-system)
166 (modify-phases %standard-phases
168 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
172 (synopsis "Portable C compiler")
174 "PCC is a portable C compiler. The project goal is to write a C99
175 compiler while still keeping it small, simple, fast and understandable.")
176 (home-page "http://pcc.ludd.ltu.se")
177 (supported-systems (delete "aarch64-linux" %supported-systems))
178 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
179 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
180 (license (list license:bsd-2 license:bsd-3))))
182 (define-public libbytesize
189 "https://github.com/storaged-project/libbytesize/releases/"
190 "download/" version "/libbytesize-" version ".tar.gz"))
193 "0bbqzln1nhjxl71aydq9k4jg3hvki9lqsb4w10s1i27jgibxqkdv"))
194 (modules '((guix build utils)))
197 ;; This Makefile hard-codes MSGMERGE et al. instead of
198 ;; honoring what 'configure' detected. Fix that.
199 (substitute* "po/Makefile.in"
200 (("^MSGMERGE = msgmerge")
201 "MSGMERGE = @MSGMERGE@\n"))
203 (build-system gnu-build-system)
205 ;; When running "make", the POT files are built with the build time as
206 ;; their "POT-Creation-Date". Later on, "make" notices that .pot
207 ;; files were updated and goes on to run "msgmerge"; as a result, the
208 ;; non-deterministic POT-Creation-Date finds its way into .po files,
209 ;; and then in .gmo files. To avoid that, simply make sure 'msgmerge'
210 ;; never runs. See <https://bugs.debian.org/792687>.
211 '(#:configure-flags '("ac_cv_path_MSGMERGE=true")
213 #:phases (modify-phases %standard-phases
214 (add-after 'configure 'create-merged-po-files
216 ;; Create "merged PO" (.mpo) files so that 'msgmerge'
217 ;; doesn't need to run.
218 (for-each (lambda (po-file)
220 (string-append (dirname po-file) "/"
224 (copy-file po-file merged-po)))
225 (find-files "po" "\\.po$"))
228 ;; One test fails because busctl (systemd only?) and python2-pocketlint
229 ;; are missing. Should we fix it, we would need the "python-2" ,
230 ;; "python2-polib" and "python2-six" native-inputs.
233 `(("gettext" ,gettext-minimal)
234 ("pkg-config" ,pkg-config)
239 (home-page "https://github.com/storaged-project/libbytesize")
240 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
242 "The goal of this project is to provide a tiny library that would
243 facilitate the common operations with sizes in bytes. Many projects need to
244 work with sizes in bytes (be it sizes of storage space, memory...) and all of
245 them need to deal with the same issues like:
248 @item How to get a human-readable string for the given size?
249 @item How to store the given size so that no significant information is lost?
250 @item If we store the size in bytes, what if the given size gets over the
252 @item How to interpret sizes entered by users according to their locale and
254 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
257 @code{libbytesize} offers a generally usable solution that could be used by
258 every project that needs to deal with sizes in bytes. It is written in the C
259 language with thin bindings for other languages.")
260 (license license:lgpl2.1+)))
262 (define-public udunits
268 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
269 "udunits-" version ".tar.gz"))
272 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
273 (build-system gnu-build-system)
276 (home-page "https://www.unidata.ucar.edu/software/udunits/")
277 (synopsis "C library for units of physical quantities and value-conversion utils")
279 "The UDUNITS-2 package provides support for units of physical quantities.
280 Its three main components are:
283 @item @code{udunits2lib}, a C library for units of physical quantities;
284 @item @code{udunits2prog}, a utility for obtaining the definition of a unit
285 and for converting numeric values between compatible units; and
286 @item an extensive database of units.
288 ;; Like the BSD-3 license but with an extra anti patent clause.
289 (license (license:non-copyleft "file://COPYRIGHT"))))