gnu: igt-gpu-tools: Don't use NAME in source URI.
[jackhill/guix/guix.git] / gnu / packages / c.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016, 2017, 2018 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>
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)
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
43 (define-public tcc
44 (package
45 (name "tcc") ;aka. "tinycc"
46 (version "0.9.27")
47 (source (origin
48 (method url-fetch)
49 (uri (string-append "mirror://savannah/tinycc/tcc-"
50 version ".tar.bz2"))
51 (sha256
52 (base32
53 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
54 (build-system gnu-build-system)
55 (native-inputs `(("perl" ,perl)
56 ("texinfo" ,texinfo)))
57 (arguments
58 `(#:configure-flags (list (string-append "--elfinterp="
59 (assoc-ref %build-inputs "libc")
60 ,(glibc-dynamic-linker))
61 (string-append "--crtprefix="
62 (assoc-ref %build-inputs "libc")
63 "/lib")
64 (string-append "--sysincludepaths="
65 (assoc-ref %build-inputs "libc")
66 "/include:"
67 (assoc-ref %build-inputs
68 "kernel-headers")
69 "/include:{B}/include")
70 (string-append "--libpaths="
71 (assoc-ref %build-inputs "libc")
72 "/lib")
73 ,@(if (string-prefix? "armhf-linux"
74 (or (%current-target-system)
75 (%current-system)))
76 `("--triplet=arm-linux-gnueabihf")
77 '()))
78 #:test-target "test"))
79 ;; Fails to build on MIPS: "Unsupported CPU"
80 (supported-systems (delete "mips64el-linux" %supported-systems))
81 (synopsis "Tiny and fast C compiler")
82 (description
83 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
84 written in C. It supports ANSI C with GNU and extensions and most of the C99
85 standard.")
86 (home-page "http://www.tinycc.org/")
87 ;; An attempt to re-licence tcc under the Expat licence is underway but not
88 ;; (if ever) complete. See the RELICENSING file for more information.
89 (license license:lgpl2.1+)))
90
91 (define-public tcc-wrapper
92 (package
93 (inherit tcc)
94 (name "tcc-wrapper")
95 (build-system trivial-build-system)
96 (native-inputs '())
97 (inputs `(("tcc" ,tcc)
98 ("guile" ,guile-2.2)))
99
100 ;; By default TCC does not honor any search path environment variable.
101 ;; This wrapper adds them.
102 ;;
103 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
104 ;; RUNPATH is ineffective here. We should modify TCC itself.
105 (native-search-paths
106 (list (search-path-specification
107 (variable "TCC_CPATH")
108 (files '("include")))
109 (search-path-specification
110 (variable "TCC_LIBRARY_PATH")
111 (files '("lib" "lib64")))))
112
113 (arguments
114 '(#:builder
115 (let* ((out (assoc-ref %outputs "out"))
116 (bin (string-append out "/bin"))
117 (tcc (assoc-ref %build-inputs "tcc"))
118 (guile (assoc-ref %build-inputs "guile")))
119 (mkdir out)
120 (mkdir bin)
121 (call-with-output-file (string-append bin "/cc")
122 (lambda (port)
123 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
124 (write
125 `(begin
126 (use-modules (ice-9 match)
127 (srfi srfi-26))
128
129 (define (split path)
130 (string-tokenize path (char-set-complement
131 (char-set #\:))))
132
133 (apply execl ,(string-append tcc "/bin/tcc")
134 ,(string-append tcc "/bin/tcc") ;argv[0]
135 (append (cdr (command-line))
136 (match (getenv "TCC_CPATH")
137 (#f '())
138 (str
139 (map (cut string-append "-I" <>)
140 (split str))))
141 (match (getenv "TCC_LIBRARY_PATH")
142 (#f '())
143 (str
144 (map (cut string-append "-L" <>)
145 (split str)))))))
146 port)
147 (chmod port #o777)))
148 #t)))
149 (synopsis "Wrapper providing the 'cc' command for TCC")))
150
151 (define-public pcc
152 (package
153 (name "pcc")
154 (version "20170109")
155 (source (origin
156 (method url-fetch)
157 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
158 version ".tgz"))
159 (sha256
160 (base32
161 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
162 (build-system gnu-build-system)
163 (arguments
164 `(#:phases
165 (modify-phases %standard-phases
166 (replace 'check
167 (lambda _ (invoke "make" "-C" "cc/cpp" "test") #t)))))
168 (native-inputs
169 `(("bison" ,bison)
170 ("flex" ,flex)))
171 (synopsis "Portable C compiler")
172 (description
173 "PCC is a portable C compiler. The project goal is to write a C99
174 compiler while still keeping it small, simple, fast and understandable.")
175 (home-page "http://pcc.ludd.ltu.se")
176 (supported-systems (delete "aarch64-linux" %supported-systems))
177 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
178 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
179 (license (list license:bsd-2 license:bsd-3))))
180
181 (define-public libbytesize
182 (package
183 (name "libbytesize")
184 (version "1.4")
185 (source (origin
186 (method url-fetch)
187 (uri (string-append
188 "https://github.com/storaged-project/libbytesize/releases/"
189 "download/" version "/libbytesize-" version ".tar.gz"))
190 (sha256
191 (base32
192 "0bbqzln1nhjxl71aydq9k4jg3hvki9lqsb4w10s1i27jgibxqkdv"))
193 (modules '((guix build utils)))
194 (snippet
195 '(begin
196 ;; This Makefile hard-codes MSGMERGE et al. instead of
197 ;; honoring what 'configure' detected. Fix that.
198 (substitute* "po/Makefile.in"
199 (("^MSGMERGE = msgmerge")
200 "MSGMERGE = @MSGMERGE@\n"))
201 #t))))
202 (build-system gnu-build-system)
203 (arguments
204 ;; When running "make", the POT files are built with the build time as
205 ;; their "POT-Creation-Date". Later on, "make" notices that .pot
206 ;; files were updated and goes on to run "msgmerge"; as a result, the
207 ;; non-deterministic POT-Creation-Date finds its way into .po files,
208 ;; and then in .gmo files. To avoid that, simply make sure 'msgmerge'
209 ;; never runs. See <https://bugs.debian.org/792687>.
210 '(#:configure-flags '("ac_cv_path_MSGMERGE=true")
211
212 #:phases (modify-phases %standard-phases
213 (add-after 'configure 'create-merged-po-files
214 (lambda _
215 ;; Create "merged PO" (.mpo) files so that 'msgmerge'
216 ;; doesn't need to run.
217 (for-each (lambda (po-file)
218 (let ((merged-po
219 (string-append (dirname po-file) "/"
220 (basename po-file
221 ".po")
222 ".mpo")))
223 (copy-file po-file merged-po)))
224 (find-files "po" "\\.po$"))
225 #t)))
226
227 ;; One test fails because busctl (systemd only?) and python2-pocketlint
228 ;; are missing. Should we fix it, we would need the "python-2" ,
229 ;; "python2-polib" and "python2-six" native-inputs.
230 #:tests? #f))
231 (native-inputs
232 `(("gettext" ,gettext-minimal)
233 ("pkg-config" ,pkg-config)
234 ("python" ,python)))
235 (inputs
236 `(("mpfr" ,mpfr)
237 ("pcre" ,pcre)))
238 (home-page "https://github.com/storaged-project/libbytesize")
239 (synopsis "Tiny C library for working with arbitrary big sizes in bytes")
240 (description
241 "The goal of this project is to provide a tiny library that would
242 facilitate the common operations with sizes in bytes. Many projects need to
243 work with sizes in bytes (be it sizes of storage space, memory...) and all of
244 them need to deal with the same issues like:
245
246 @itemize
247 @item How to get a human-readable string for the given size?
248 @item How to store the given size so that no significant information is lost?
249 @item If we store the size in bytes, what if the given size gets over the
250 MAXUINT64 value?
251 @item How to interpret sizes entered by users according to their locale and
252 typing conventions?
253 @item How to deal with the decimal/binary units (MB versus MiB) ambiguity?
254 @end itemize
255
256 @code{libbytesize} offers a generally usable solution that could be used by
257 every project that needs to deal with sizes in bytes. It is written in the C
258 language with thin bindings for other languages.")
259 (license license:lgpl2.1+)))