1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
25 #:use-module (guix build-system trivial)
26 #:use-module (gnu packages bootstrap)
27 #:use-module (gnu packages bison)
28 #:use-module (gnu packages flex)
29 #:use-module (gnu packages perl)
30 #:use-module (gnu packages texinfo)
31 #:use-module (gnu packages guile)
32 #:use-module (srfi srfi-1))
36 (name "tcc") ;aka. "tinycc"
40 (uri (string-append "mirror://savannah/tinycc/tcc-"
44 "0wbdbdq6090ayw8bxnbikiv989kykff3m5rzbia05hrnwhd707jj"))))
45 (build-system gnu-build-system)
46 (native-inputs `(("perl" ,perl)
47 ("texinfo" ,texinfo)))
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")
55 (string-append "--sysincludepaths="
56 (assoc-ref %build-inputs "libc")
58 (assoc-ref %build-inputs
60 "/include:{B}/include")
61 (string-append "--libpaths="
62 (assoc-ref %build-inputs "libc")
64 #:test-target "test"))
65 ;; Fails to build on MIPS: "Unsupported CPU"
66 (supported-systems (fold delete %supported-systems
67 '("mips64el-linux" "aarch64-linux")))
68 (synopsis "Tiny and fast C compiler")
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
73 (home-page "http://www.tinycc.org/")
74 (license license:lgpl2.1+)))
76 (define-public tcc-wrapper
80 (build-system trivial-build-system)
82 (inputs `(("tcc" ,tcc)
83 ("guile" ,guile-2.0)))
85 ;; By default TCC does not honor any search path environment variable.
86 ;; This wrapper adds them.
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.
91 (list (search-path-specification
92 (variable "TCC_CPATH")
94 (search-path-specification
95 (variable "TCC_LIBRARY_PATH")
96 (files '("lib" "lib64")))))
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")))
106 (call-with-output-file (string-append bin "/cc")
108 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
111 (use-modules (ice-9 match)
115 (string-tokenize path (char-set-complement
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")
124 (map (cut string-append "-I" <>)
126 (match (getenv "TCC_LIBRARY_PATH")
129 (map (cut string-append "-L" <>)
134 (synopsis "Wrapper providing the 'cc' command for TCC")))
142 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
146 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
147 (build-system gnu-build-system)
150 (modify-phases %standard-phases
153 (zero? (system* "make" "-C" "cc/cpp" "test")))))))
157 (synopsis "Portable C compiler")
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")
162 (supported-systems (delete "aarch64-linux" %supported-systems))
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))))