1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
26 #:use-module (guix build-system trivial)
27 #:use-module (gnu packages bootstrap)
28 #:use-module (gnu packages bison)
29 #:use-module (gnu packages flex)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages texinfo)
32 #:use-module (gnu packages guile)
33 #:use-module (srfi srfi-1))
37 (name "tcc") ;aka. "tinycc"
41 (uri (string-append "mirror://savannah/tinycc/tcc-"
45 "177bdhwzrnqgyrdv1dwvpd04fcxj68s5pm1dzwny6359ziway8yy"))))
46 (build-system gnu-build-system)
47 (native-inputs `(("perl" ,perl)
48 ("texinfo" ,texinfo)))
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")
56 (string-append "--sysincludepaths="
57 (assoc-ref %build-inputs "libc")
59 (assoc-ref %build-inputs
61 "/include:{B}/include")
62 (string-append "--libpaths="
63 (assoc-ref %build-inputs "libc")
65 #:test-target "test"))
66 ;; Fails to build on MIPS: "Unsupported CPU"
67 (supported-systems (fold delete %supported-systems
68 '("mips64el-linux" "aarch64-linux")))
69 (synopsis "Tiny and fast C compiler")
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
74 (home-page "http://www.tinycc.org/")
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.
77 (license license:lgpl2.1+)))
79 (define-public tcc-wrapper
83 (build-system trivial-build-system)
85 (inputs `(("tcc" ,tcc)
86 ("guile" ,guile-2.2)))
88 ;; By default TCC does not honor any search path environment variable.
89 ;; This wrapper adds them.
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.
94 (list (search-path-specification
95 (variable "TCC_CPATH")
97 (search-path-specification
98 (variable "TCC_LIBRARY_PATH")
99 (files '("lib" "lib64")))))
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")))
109 (call-with-output-file (string-append bin "/cc")
111 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
114 (use-modules (ice-9 match)
118 (string-tokenize path (char-set-complement
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")
127 (map (cut string-append "-I" <>)
129 (match (getenv "TCC_LIBRARY_PATH")
132 (map (cut string-append "-L" <>)
137 (synopsis "Wrapper providing the 'cc' command for TCC")))
145 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
149 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
150 (build-system gnu-build-system)
153 (modify-phases %standard-phases
156 (zero? (system* "make" "-C" "cc/cpp" "test")))))))
160 (synopsis "Portable C compiler")
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")
165 (supported-systems (delete "aarch64-linux" %supported-systems))
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))))