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