Commit | Line | Data |
---|---|---|
a5e2c9a9 LC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org> | |
f0316832 | 3 | ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net> |
5d0bd1fb | 4 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
a5e2c9a9 LC |
5 | ;;; |
6 | ;;; This file is part of GNU Guix. | |
7 | ;;; | |
8 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
9 | ;;; under the terms of the GNU General Public License as published by | |
10 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
11 | ;;; your option) any later version. | |
12 | ;;; | |
13 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
14 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;;; GNU General Public License for more details. | |
17 | ;;; | |
18 | ;;; You should have received a copy of the GNU General Public License | |
19 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
20 | ||
21 | (define-module (gnu packages c) | |
22 | #:use-module ((guix licenses) #:prefix license:) | |
23 | #:use-module (guix packages) | |
24 | #:use-module (guix download) | |
25 | #:use-module (guix build-system gnu) | |
9f088725 | 26 | #:use-module (guix build-system trivial) |
a5e2c9a9 | 27 | #:use-module (gnu packages bootstrap) |
f0316832 RW |
28 | #:use-module (gnu packages bison) |
29 | #:use-module (gnu packages flex) | |
a5e2c9a9 | 30 | #:use-module (gnu packages perl) |
9f088725 | 31 | #:use-module (gnu packages texinfo) |
97b7201f EF |
32 | #:use-module (gnu packages guile) |
33 | #:use-module (srfi srfi-1)) | |
a5e2c9a9 LC |
34 | |
35 | (define-public tcc | |
36 | (package | |
37 | (name "tcc") ;aka. "tinycc" | |
5d0bd1fb | 38 | (version "0.9.27") |
a5e2c9a9 LC |
39 | (source (origin |
40 | (method url-fetch) | |
41 | (uri (string-append "mirror://savannah/tinycc/tcc-" | |
42 | version ".tar.bz2")) | |
43 | (sha256 | |
44 | (base32 | |
5d0bd1fb | 45 | "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy")))) |
a5e2c9a9 LC |
46 | (build-system gnu-build-system) |
47 | (native-inputs `(("perl" ,perl) | |
48 | ("texinfo" ,texinfo))) | |
49 | (arguments | |
50 | `(#:configure-flags (list (string-append "--elfinterp=" | |
51 | (assoc-ref %build-inputs "libc") | |
52 | ,(glibc-dynamic-linker)) | |
53 | (string-append "--crtprefix=" | |
54 | (assoc-ref %build-inputs "libc") | |
55 | "/lib") | |
56 | (string-append "--sysincludepaths=" | |
57 | (assoc-ref %build-inputs "libc") | |
58 | "/include:" | |
59 | (assoc-ref %build-inputs | |
ce430bd6 | 60 | "kernel-headers") |
a5e2c9a9 LC |
61 | "/include:{B}/include") |
62 | (string-append "--libpaths=" | |
63 | (assoc-ref %build-inputs "libc") | |
64 | "/lib")) | |
65 | #:test-target "test")) | |
57a31efb | 66 | ;; Fails to build on MIPS: "Unsupported CPU" |
97b7201f EF |
67 | (supported-systems (fold delete %supported-systems |
68 | '("mips64el-linux" "aarch64-linux"))) | |
a5e2c9a9 LC |
69 | (synopsis "Tiny and fast C compiler") |
70 | (description | |
71 | "TCC, also referred to as \"TinyCC\", is a small and fast C compiler | |
72 | written in C. It supports ANSI C with GNU and extensions and most of the C99 | |
73 | standard.") | |
74 | (home-page "http://www.tinycc.org/") | |
5d0bd1fb TGR |
75 | ;; An attempt to re-licence tcc under the Expat licence is underway but not |
76 | ;; (if ever) complete. See the RELICENSING file for more information. | |
a5e2c9a9 | 77 | (license license:lgpl2.1+))) |
9f088725 LC |
78 | |
79 | (define-public tcc-wrapper | |
80 | (package | |
81 | (inherit tcc) | |
82 | (name "tcc-wrapper") | |
83 | (build-system trivial-build-system) | |
84 | (native-inputs '()) | |
85 | (inputs `(("tcc" ,tcc) | |
86 | ("guile" ,guile-2.0))) | |
87 | ||
88 | ;; By default TCC does not honor any search path environment variable. | |
89 | ;; This wrapper adds them. | |
90 | ;; | |
91 | ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the | |
92 | ;; RUNPATH is ineffective here. We should modify TCC itself. | |
93 | (native-search-paths | |
94 | (list (search-path-specification | |
95 | (variable "TCC_CPATH") | |
96 | (files '("include"))) | |
97 | (search-path-specification | |
98 | (variable "TCC_LIBRARY_PATH") | |
99 | (files '("lib" "lib64"))))) | |
100 | ||
101 | (arguments | |
102 | '(#:builder | |
103 | (let* ((out (assoc-ref %outputs "out")) | |
104 | (bin (string-append out "/bin")) | |
105 | (tcc (assoc-ref %build-inputs "tcc")) | |
106 | (guile (assoc-ref %build-inputs "guile"))) | |
107 | (mkdir out) | |
108 | (mkdir bin) | |
109 | (call-with-output-file (string-append bin "/cc") | |
110 | (lambda (port) | |
111 | (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile) | |
112 | (write | |
113 | `(begin | |
114 | (use-modules (ice-9 match) | |
115 | (srfi srfi-26)) | |
116 | ||
117 | (define (split path) | |
118 | (string-tokenize path (char-set-complement | |
119 | (char-set #\:)))) | |
120 | ||
121 | (apply execl ,(string-append tcc "/bin/tcc") | |
122 | ,(string-append tcc "/bin/tcc") ;argv[0] | |
123 | (append (cdr (command-line)) | |
124 | (match (getenv "TCC_CPATH") | |
125 | (#f '()) | |
126 | (str | |
127 | (map (cut string-append "-I" <>) | |
128 | (split str)))) | |
129 | (match (getenv "TCC_LIBRARY_PATH") | |
130 | (#f '()) | |
131 | (str | |
132 | (map (cut string-append "-L" <>) | |
133 | (split str))))))) | |
134 | port) | |
135 | (chmod port #o777))) | |
136 | #t))) | |
137 | (synopsis "Wrapper providing the 'cc' command for TCC"))) | |
f0316832 RW |
138 | |
139 | (define-public pcc | |
140 | (package | |
141 | (name "pcc") | |
142 | (version "20170109") | |
143 | (source (origin | |
144 | (method url-fetch) | |
145 | (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-" | |
146 | version ".tgz")) | |
147 | (sha256 | |
148 | (base32 | |
149 | "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww")))) | |
150 | (build-system gnu-build-system) | |
151 | (arguments | |
152 | `(#:phases | |
153 | (modify-phases %standard-phases | |
154 | (replace 'check | |
155 | (lambda _ | |
156 | (zero? (system* "make" "-C" "cc/cpp" "test"))))))) | |
157 | (native-inputs | |
158 | `(("bison" ,bison) | |
159 | ("flex" ,flex))) | |
160 | (synopsis "Portable C compiler") | |
161 | (description | |
162 | "PCC is a portable C compiler. The project goal is to write a C99 | |
163 | compiler while still keeping it small, simple, fast and understandable.") | |
164 | (home-page "http://pcc.ludd.ltu.se") | |
6a052473 | 165 | (supported-systems (delete "aarch64-linux" %supported-systems)) |
f0316832 RW |
166 | ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is |
167 | ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details. | |
168 | (license (list license:bsd-2 license:bsd-3)))) |