gnu: python-pandas: Fix build on 32-bit.
[jackhill/guix/guix.git] / gnu / packages / c.scm
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>
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)
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
33 (define-public tcc
34 (package
35 (name "tcc") ;aka. "tinycc"
36 (version "0.9.26")
37 (source (origin
38 (method url-fetch)
39 (uri (string-append "mirror://savannah/tinycc/tcc-"
40 version ".tar.bz2"))
41 (sha256
42 (base32
43 "0wbdbdq6090ayw8bxnbikiv989kykff3m5rzbia05hrnwhd707jj"))))
44 (build-system gnu-build-system)
45 (native-inputs `(("perl" ,perl)
46 ("texinfo" ,texinfo)))
47 (arguments
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")
53 "/lib")
54 (string-append "--sysincludepaths="
55 (assoc-ref %build-inputs "libc")
56 "/include:"
57 (assoc-ref %build-inputs
58 "kernel-headers")
59 "/include:{B}/include")
60 (string-append "--libpaths="
61 (assoc-ref %build-inputs "libc")
62 "/lib"))
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")
67 (description
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
70 standard.")
71 (home-page "http://www.tinycc.org/")
72 (license license:lgpl2.1+)))
73
74 (define-public tcc-wrapper
75 (package
76 (inherit tcc)
77 (name "tcc-wrapper")
78 (build-system trivial-build-system)
79 (native-inputs '())
80 (inputs `(("tcc" ,tcc)
81 ("guile" ,guile-2.0)))
82
83 ;; By default TCC does not honor any search path environment variable.
84 ;; This wrapper adds them.
85 ;;
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.
88 (native-search-paths
89 (list (search-path-specification
90 (variable "TCC_CPATH")
91 (files '("include")))
92 (search-path-specification
93 (variable "TCC_LIBRARY_PATH")
94 (files '("lib" "lib64")))))
95
96 (arguments
97 '(#:builder
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")))
102 (mkdir out)
103 (mkdir bin)
104 (call-with-output-file (string-append bin "/cc")
105 (lambda (port)
106 (format port "#!~a/bin/guile --no-auto-compile~%!#~%" guile)
107 (write
108 `(begin
109 (use-modules (ice-9 match)
110 (srfi srfi-26))
111
112 (define (split path)
113 (string-tokenize path (char-set-complement
114 (char-set #\:))))
115
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")
120 (#f '())
121 (str
122 (map (cut string-append "-I" <>)
123 (split str))))
124 (match (getenv "TCC_LIBRARY_PATH")
125 (#f '())
126 (str
127 (map (cut string-append "-L" <>)
128 (split str)))))))
129 port)
130 (chmod port #o777)))
131 #t)))
132 (synopsis "Wrapper providing the 'cc' command for TCC")))
133
134 (define-public pcc
135 (package
136 (name "pcc")
137 (version "20170109")
138 (source (origin
139 (method url-fetch)
140 (uri (string-append "http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-"
141 version ".tgz"))
142 (sha256
143 (base32
144 "1p34w496095mi0473f815w6wbi57zxil106mg7pj6sg6gzpjcgww"))))
145 (build-system gnu-build-system)
146 (arguments
147 `(#:phases
148 (modify-phases %standard-phases
149 (replace 'check
150 (lambda _
151 (zero? (system* "make" "-C" "cc/cpp" "test")))))))
152 (native-inputs
153 `(("bison" ,bison)
154 ("flex" ,flex)))
155 (synopsis "Portable C compiler")
156 (description
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))))