gnu: pies: Update to 1.4.
[jackhill/guix/guix.git] / gnu / packages / c.scm
CommitLineData
a5e2c9a9 1;;; GNU Guix --- Functional package management for GNU
350f50cb 2;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
011ec1e5 3;;; Copyright © 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
5d0bd1fb 4;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
07592c77 5;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz>
0270b24b 6;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
a5e2c9a9
LC
7;;;
8;;; This file is part of GNU Guix.
9;;;
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.
14;;;
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.
19;;;
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/>.
22
23(define-module (gnu packages c)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix download)
c229fb3d 27 #:use-module (guix git-download)
a5e2c9a9 28 #:use-module (guix build-system gnu)
9f088725 29 #:use-module (guix build-system trivial)
a5e2c9a9 30 #:use-module (gnu packages bootstrap)
f0316832 31 #:use-module (gnu packages bison)
07592c77 32 #:use-module (gnu packages check)
f0316832 33 #:use-module (gnu packages flex)
a5e2c9a9 34 #:use-module (gnu packages perl)
9f088725 35 #:use-module (gnu packages texinfo)
97b7201f 36 #:use-module (gnu packages guile)
c229fb3d
PN
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)
011ec1e5
RW
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages xml))
a5e2c9a9
LC
44
45(define-public tcc
46 (package
47 (name "tcc") ;aka. "tinycc"
5d0bd1fb 48 (version "0.9.27")
a5e2c9a9
LC
49 (source (origin
50 (method url-fetch)
51 (uri (string-append "mirror://savannah/tinycc/tcc-"
52 version ".tar.bz2"))
53 (sha256
54 (base32
5d0bd1fb 55 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
a5e2c9a9
LC
56 (build-system gnu-build-system)
57 (native-inputs `(("perl" ,perl)
58 ("texinfo" ,texinfo)))
59 (arguments
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")
65 "/lib")
66 (string-append "--sysincludepaths="
67 (assoc-ref %build-inputs "libc")
68 "/include:"
69 (assoc-ref %build-inputs
ce430bd6 70 "kernel-headers")
a5e2c9a9
LC
71 "/include:{B}/include")
72 (string-append "--libpaths="
73 (assoc-ref %build-inputs "libc")
9117d6df
EF
74 "/lib")
75 ,@(if (string-prefix? "armhf-linux"
76 (or (%current-target-system)
77 (%current-system)))
78 `("--triplet=arm-linux-gnueabihf")
79 '()))
a5e2c9a9 80 #:test-target "test"))
57a31efb 81 ;; Fails to build on MIPS: "Unsupported CPU"
0270b24b 82 (supported-systems (delete "mips64el-linux" %supported-systems))
a5e2c9a9
LC
83 (synopsis "Tiny and fast C compiler")
84 (description
85 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
86written in C. It supports ANSI C with GNU and extensions and most of the C99
87standard.")
88 (home-page "http://www.tinycc.org/")
5d0bd1fb
TGR
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.
a5e2c9a9 91 (license license:lgpl2.1+)))
9f088725
LC
92
93(define-public tcc-wrapper
94 (package
95 (inherit tcc)
96 (name "tcc-wrapper")
97 (build-system trivial-build-system)
98 (native-inputs '())
99 (inputs `(("tcc" ,tcc)
350f50cb 100 ("guile" ,guile-2.2)))
9f088725
LC
101
102 ;; By default TCC does not honor any search path environment variable.
103 ;; This wrapper adds them.
104 ;;
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.
107 (native-search-paths
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")))))
114
115 (arguments
116 '(#:builder
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")))
121 (mkdir out)
122 (mkdir bin)
123 (call-with-output-file (string-append bin "/cc")
124 (lambda (port)
125 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
126 (write
127 `(begin
128 (use-modules (ice-9 match)
129 (srfi srfi-26))
130
131 (define (split path)
132 (string-tokenize path (char-set-complement
133 (char-set #\:))))
134
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")
139 (#f '())
140 (str
141 (map (cut string-append "-I" <>)
142 (split str))))
143 (match (getenv "TCC_LIBRARY_PATH")
144 (#f '())
145 (str
146 (map (cut string-append "-L" <>)
147 (split str)))))))
148 port)
149 (chmod port #o777)))
150 #t)))
151 (synopsis "Wrapper providing the 'cc' command for TCC")))
f0316832
RW
152
153(define-public pcc
154 (package
155 (name "pcc")
156 (version "20170109")
157 (source (origin
158 (method url-fetch)
159 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
160 version ".tgz"))
161 (sha256
162 (base32
163 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
164 (build-system gnu-build-system)
165 (arguments
166 `(#:phases
167 (modify-phases %standard-phases
168 (replace 'check
9c30cba4 169 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
f0316832
RW
170 (native-inputs
171 `(("bison" ,bison)
172 ("flex" ,flex)))
173 (synopsis "Portable C compiler")
174 (description
175 "PCC is a portable C compiler. The project goal is to write a C99
176compiler while still keeping it small, simple, fast and understandable.")
177 (home-page "http://pcc.ludd.ltu.se")
6a052473 178 (supported-systems (delete "aarch64-linux" %supported-systems))
f0316832
RW
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))))
c229fb3d
PN
182
183(define-public libbytesize
184 (package
185 (name "libbytesize")
94617bdd 186 (version "1.4")
c229fb3d
PN
187 (source (origin
188 (method url-fetch)
189 (uri (string-append
94617bdd
TGR
190 "https://github.com/storaged-project/libbytesize/releases/"
191 "download/" version "/libbytesize-" version ".tar.gz"))
c229fb3d
PN
192 (sha256
193 (base32
bf6859e4
LC
194 "0bbqzln1nhjxl71aydq9k4jg3hvki9lqsb4w10s1i27jgibxqkdv"))
195 (modules '((guix build utils)))
196 (snippet
197 '(begin
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"))
203 #t))))
c229fb3d 204 (build-system gnu-build-system)
bf6859e4
LC
205 (arguments
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")
213
214 #:phases (modify-phases %standard-phases
215 (add-after 'configure 'create-merged-po-files
216 (lambda _
217 ;; Create "merged PO" (.mpo) files so that 'msgmerge'
218 ;; doesn't need to run.
219 (for-each (lambda (po-file)
220 (let ((merged-po
221 (string-append (dirname po-file) "/"
222 (basename po-file
223 ".po")
224 ".mpo")))
225 (copy-file po-file merged-po)))
226 (find-files "po" "\\.po$"))
227 #t)))
228
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.
232 #:tests? #f))
c229fb3d
PN
233 (native-inputs
234 `(("gettext" ,gettext-minimal)
235 ("pkg-config" ,pkg-config)
236 ("python" ,python)))
237 (inputs
238 `(("mpfr" ,mpfr)
239 ("pcre" ,pcre)))
c229fb3d
PN
240 (home-page "https://github.com/storaged-project/libbytesize")
241 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
242 (description
243 "The goal of this project is to provide a tiny library that would
244facilitate the common operations with sizes in bytes. Many projects need to
245work with sizes in bytes (be it sizes of storage space, memory...) and all of
246them need to deal with the same issues like:
247
248@itemize
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
252MAXUINT64 value?
253@item How to interpret sizes entered by users according to their locale and
254typing conventions?
255@item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
256@end itemize
257
258@code{libbytesize} offers a generally usable solution that could be used by
259every project that needs to deal with sizes in bytes. It is written in the C
260language with thin bindings for other languages.")
261 (license license:lgpl2.1+)))
011ec1e5
RW
262
263(define-public udunits
264 (package
265 (name "udunits")
266 (version "2.2.26")
267 (source (origin
268 (method url-fetch)
269 (uri (string-append "ftp://ftp.unidata.ucar.edu/pub/udunits/"
270 "udunits-" version ".tar.gz"))
271 (sha256
272 (base32
273 "0v9mqw4drnkzkm57331ail6yvs9485jmi37s40lhvmf7r5lli3rn"))))
274 (build-system gnu-build-system)
275 (inputs
276 `(("expat" ,expat)))
277 (home-page "https://www.unidata.ucar.edu/software/udunits/")
278 (synopsis "C library for units of physical quantities and value-conversion utils")
279 (description
280 "The UDUNITS-2 package provides support for units of physical quantities.
281Its three main components are:
282
283@enumerate
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.
288@end enumerate\n")
289 ;; Like the BSD-3 license but with an extra anti patent clause.
290 (license (license:non-copyleft "file://COPYRIGHT"))))
07592c77
PN
291
292(define-public libfixposix
293 (package
294 (name "libfixposix")
295 (version "0.4.3")
296 (home-page "https://github.com/sionescu/libfixposix")
297 (source
298 (origin
299 (method git-fetch)
300 (uri (git-reference
301 (url home-page)
302 (commit (string-append "v" version))))
303 (file-name (git-file-name name version))
304 (sha256
305 (base32
306 "1x4q6yspi5g2s98vq4qszw4z3zjgk9l5zs8471w4d4cs6l97w08j"))))
307 (build-system gnu-build-system)
308 (native-inputs
309 `(("autoconf" ,autoconf)
310 ("automake" ,automake)
311 ("libtool" ,libtool)
312 ("pkg-config" ,pkg-config)
313 ("check" ,check)))
314 (synopsis "Thin wrapper over POSIX syscalls")
315 (description
316 "The purpose of libfixposix is to offer replacements for parts of POSIX
317whose behaviour is inconsistent across *NIX flavours.")
318 (license license:boost1.0)))