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