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))
35 (name "tcc") ;aka. "tinycc"
39 (uri (string-append "mirror://savannah/tinycc/tcc-"
43 "0wbdbdq6090ayw8bxnbikiv989kykff3m5rzbia05hrnwhd707jj"))))
44 (build-system gnu-build-system)
45 (native-inputs `(("perl" ,perl)
46 ("texinfo" ,texinfo)))
48 `(#:configure-flags (list (string-append "--elfinterp="
49 (assoc-ref %build-inputs "libc")
50 ,(glibc-dynamic-linker))
51 (string-append "--crtprefix="
52 (assoc-ref %build-inputs "libc")
54 (string-append "--sysincludepaths="
55 (assoc-ref %build-inputs "libc")
57 (assoc-ref %build-inputs
59 "/include:{B}/include")
60 (string-append "--libpaths="
61 (assoc-ref %build-inputs "libc")
63 #:test-target "test"))
64 ;; Fails to build on MIPS: "Unsupported CPU"
65 (supported-systems (delete "mips64el-linux" %supported-systems))
66 (synopsis "Tiny and fast C compiler")
68 "TCC, also referred to as \"TinyCC\", is a small and fast C compiler
69 written in C. It supports ANSI C with GNU and extensions and most of the C99
71 (home-page "http://www.tinycc.org/")
72 (license license:lgpl2.1+)))
74 (define-public tcc-wrapper
78 (build-system trivial-build-system)
80 (inputs `(("tcc" ,tcc)
81 ("guile" ,guile-2.0)))
83 ;; By default TCC does not honor any search path environment variable.
84 ;; This wrapper adds them.
86 ;; FIXME: TCC includes its own linker so our 'ld-wrapper' hack to set the
87 ;; RUNPATH is ineffective here. We should modify TCC itself.
89 (list (search-path-specification
90 (variable "TCC_CPATH")
92 (search-path-specification
93 (variable "TCC_LIBRARY_PATH")
94 (files '("lib" "lib64")))))
98 (let* ((out (assoc-ref %outputs "out"))
99 (bin (string-append out "/bin"))
100 (tcc (assoc-ref %build-inputs "tcc"))
101 (guile (assoc-ref %build-inputs "guile")))
104 (call-with-output-file (string-append bin "/cc")
106 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
109 (use-modules (ice-9 match)
113 (string-tokenize path (char-set-complement
116 (apply execl ,(string-append tcc "/bin/tcc")
117 ,(string-append tcc "/bin/tcc") ;argv[0]
118 (append (cdr (command-line))
119 (match (getenv "TCC_CPATH")
122 (map (cut string-append "-I" <>)
124 (match (getenv "TCC_LIBRARY_PATH")
127 (map (cut string-append "-L" <>)
132 (synopsis "Wrapper providing the 'cc' command for TCC")))
140 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
144 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
145 (build-system gnu-build-system)
148 (modify-phases %standard-phases
151 (zero? (system* "make" "-C" "cc/cpp" "test")))))))
155 (synopsis "Portable C compiler")
157 "PCC is a portable C compiler. The project goal is to write a C99
158 compiler while still keeping it small, simple, fast and understandable.")
159 (home-page "http://pcc.ludd.ltu.se")
160 ;; PCC incorporates code under various BSD licenses; for new code bsd-2 is
161 ;; preferred. See http://pcc.ludd.ltu.se/licenses/ for more details.
162 (license (list license:bsd-2 license:bsd-3))))