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