gnu: Add propeller-gcc-4.
[jackhill/guix/guix.git] / gnu / packages / embedded.scm
CommitLineData
35a37efb 1;;; GNU Guix --- Functional package management for GNU
2d7c9213 2;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
dbc3c34e 3;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
e5e45c06 4;;; Copyright © 2016 David Craven <david@craven.ch>
35a37efb
RW
5;;;
6;;; This file is part of GNU Guix.
7;;;
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.
12;;;
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.
17;;;
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/>.
20
21(define-module (gnu packages embedded)
22 #:use-module (guix utils)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix svn-download)
26 #:use-module (guix git-download)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix build-system gnu)
569f6016
TF
29 #:use-module (guix build-system trivial)
30 #:use-module (guix build utils)
35a37efb 31 #:use-module (gnu packages)
e5e45c06 32 #:use-module (gnu packages autotools)
8ea42482 33 #:use-module ((gnu packages base) #:prefix base:)
2d7c9213 34 #:use-module (gnu packages bison)
35a37efb 35 #:use-module (gnu packages cross-base)
2d7c9213 36 #:use-module (gnu packages dejagnu)
35a37efb 37 #:use-module (gnu packages flex)
dbc3c34e 38 #:use-module (gnu packages gcc)
94f36a4f 39 #:use-module (gnu packages gdb)
8ea42482 40 #:use-module (gnu packages guile)
5b83b7b8 41 #:use-module (gnu packages libftdi)
e5e45c06 42 #:use-module (gnu packages libusb)
35a37efb 43 #:use-module (gnu packages perl)
e5e45c06 44 #:use-module (gnu packages pkg-config)
7894ea61
LC
45 #:use-module (gnu packages texinfo)
46 #:use-module (srfi srfi-1))
35a37efb
RW
47
48;; We must not use the released GCC sources here, because the cross-compiler
49;; does not produce working binaries. Instead we take the very same SVN
50;; revision from the branch that is used for a release of the "GCC ARM
51;; embedded" project on launchpad.
52;; See https://launchpadlibrarian.net/218827644/release.txt
53(define-public gcc-arm-none-eabi-4.9
54 (let ((xgcc (cross-gcc "arm-none-eabi"
7b3318e3
RW
55 #:xgcc gcc-4.9
56 #:xbinutils (cross-binutils "arm-none-eabi")))
35a37efb
RW
57 (revision "1")
58 (svn-revision 227977))
59 (package (inherit xgcc)
60 (version (string-append (package-version xgcc) "-"
61 revision "." (number->string svn-revision)))
62 (source
63 (origin
64 (method svn-fetch)
65 (uri (svn-reference
66 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
67 (revision svn-revision)))
68 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
69 (sha256
70 (base32
71 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
7894ea61
LC
72
73 ;; Remove the one patch that doesn't apply to this 4.9 snapshot (the
74 ;; patch is for 4.9.4 and later but this svn snapshot is older).
75 (patches (remove (lambda (patch)
76 (string=? (basename patch)
77 "gcc-arm-bug-71399.patch"))
78 (origin-patches (package-source xgcc))))))
35a37efb
RW
79 (native-inputs
80 `(("flex" ,flex)
81 ,@(package-native-inputs xgcc)))
82 (arguments
83 (substitute-keyword-arguments (package-arguments xgcc)
84 ((#:phases phases)
85 `(modify-phases ,phases
86 (add-after 'unpack 'fix-genmultilib
87 (lambda _
88 (substitute* "gcc/genmultilib"
89 (("#!/bin/sh") (string-append "#!" (which "sh"))))
90 #t))))
91 ((#:configure-flags flags)
92 ;; The configure flags are largely identical to the flags used by the
93 ;; "GCC ARM embedded" project.
94 `(append (list "--enable-multilib"
95 "--with-newlib"
96 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
97 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
98 "--enable-plugins"
99 "--disable-decimal-float"
100 "--disable-libffi"
101 "--disable-libgomp"
102 "--disable-libmudflap"
103 "--disable-libquadmath"
104 "--disable-libssp"
105 "--disable-libstdcxx-pch"
106 "--disable-nls"
107 "--disable-shared"
108 "--disable-threads"
109 "--disable-tls")
110 (delete "--disable-multilib" ,flags)))))
111 (native-search-paths
112 (list (search-path-specification
113 (variable "CROSS_C_INCLUDE_PATH")
114 (files '("arm-none-eabi/include")))
115 (search-path-specification
116 (variable "CROSS_CPLUS_INCLUDE_PATH")
117 (files '("arm-none-eabi/include")))
118 (search-path-specification
119 (variable "CROSS_LIBRARY_PATH")
120 (files '("arm-none-eabi/lib"))))))))
6c39886a 121
dbc3c34e
TF
122(define-public gcc-arm-none-eabi-6
123 (package
124 (inherit gcc-arm-none-eabi-4.9)
125 (version (package-version gcc-6))
126 (source (origin (inherit (package-source gcc-6))
127 (patches
128 (append
129 (origin-patches (package-source gcc-6))
130 (search-patches "gcc-6-cross-environment-variables.patch"
131 "gcc-6-arm-none-eabi-multilib.patch")))))))
132
6c39886a
RW
133(define-public newlib-arm-none-eabi
134 (package
135 (name "newlib")
136 (version "2.4.0")
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
140 version ".tar.gz"))
141 (sha256
142 (base32
143 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
144 (build-system gnu-build-system)
145 (arguments
146 `(#:out-of-source? #t
147 ;; The configure flags are identical to the flags used by the "GCC ARM
148 ;; embedded" project.
149 #:configure-flags '("--target=arm-none-eabi"
150 "--enable-newlib-io-long-long"
151 "--enable-newlib-register-fini"
152 "--disable-newlib-supplied-syscalls"
153 "--disable-nls")
154 #:phases
155 (modify-phases %standard-phases
156 (add-after 'unpack 'fix-references-to-/bin/sh
157 (lambda _
158 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
159 "libgloss/arm/Makefile.in"
160 "libgloss/libnosys/Makefile.in"
161 "libgloss/Makefile.in")
162 (("/bin/sh") (which "sh")))
163 #t)))))
164 (native-inputs
165 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
166 ("xgcc" ,gcc-arm-none-eabi-4.9)
167 ("texinfo" ,texinfo)))
168 (home-page "http://www.sourceware.org/newlib/")
169 (synopsis "C library for use on embedded systems")
170 (description "Newlib is a C library intended for use on embedded
171systems. It is a conglomeration of several library parts that are easily
172usable on embedded products.")
173 (license (license:non-copyleft
174 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
a299a899
RW
175
176(define-public newlib-nano-arm-none-eabi
177 (package (inherit newlib-arm-none-eabi)
178 (name "newlib-nano")
179 (arguments
180 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
181 ;; The configure flags are identical to the flags used by the "GCC ARM
182 ;; embedded" project. They optimize newlib for use on small embedded
183 ;; systems with limited memory.
184 ((#:configure-flags flags)
185 ''("--target=arm-none-eabi"
186 "--enable-multilib"
187 "--disable-newlib-supplied-syscalls"
188 "--enable-newlib-reent-small"
189 "--disable-newlib-fvwrite-in-streamio"
190 "--disable-newlib-fseek-optimization"
191 "--disable-newlib-wide-orient"
192 "--enable-newlib-nano-malloc"
193 "--disable-newlib-unbuf-stream-opt"
194 "--enable-lite-exit"
195 "--enable-newlib-global-atexit"
196 "--enable-newlib-nano-formatted-io"
197 "--disable-nls"))))
198 (synopsis "Newlib variant for small systems with limited memory")))
569f6016 199
1a1e8336
RW
200(define (make-libstdc++-arm-none-eabi xgcc newlib)
201 (let ((libstdc++ (make-libstdc++ xgcc)))
202 (package (inherit libstdc++)
203 (name "libstdc++-arm-none-eabi")
204 (arguments
205 (substitute-keyword-arguments (package-arguments libstdc++)
206 ((#:configure-flags flags)
207 ``("--target=arm-none-eabi"
208 "--host=arm-none-eabi"
209 "--disable-libstdcxx-pch"
210 "--enable-multilib"
211 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
212 "--disable-shared"
213 "--disable-tls"
214 "--disable-plugin"
215 "--with-newlib"
216 ,(string-append "--with-gxx-include-dir="
217 (assoc-ref %outputs "out")
218 "/arm-none-eabi/include")))))
219 (native-inputs
220 `(("newlib" ,newlib)
221 ("xgcc" ,xgcc)
222 ,@(package-native-inputs libstdc++))))))
223
569f6016
TF
224(define (arm-none-eabi-toolchain xgcc newlib)
225 "Produce a cross-compiler toolchain package with the compiler XGCC and the C
226library variant NEWLIB."
227 (let ((newlib-with-xgcc (package (inherit newlib)
228 (native-inputs
229 (alist-replace "xgcc" (list xgcc)
230 (package-native-inputs newlib))))))
231 (package
232 (name (string-append "arm-none-eabi"
233 (if (string=? (package-name newlib-with-xgcc)
234 "newlib-nano")
235 "-nano" "")
236 "-toolchain"))
237 (version (package-version xgcc))
238 (source #f)
239 (build-system trivial-build-system)
9cdf4872
RW
240 (arguments
241 '(#:modules ((guix build union))
242 #:builder
243 (begin
244 (use-modules (ice-9 match)
245 (guix build union))
246 (match %build-inputs
247 (((names . directories) ...)
248 (union-build (assoc-ref %outputs "out")
249 directories))))))
569f6016
TF
250 (propagated-inputs
251 `(("binutils" ,(cross-binutils "arm-none-eabi"))
8ea169d0 252 ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
569f6016
TF
253 ("gcc" ,xgcc)
254 ("newlib" ,newlib-with-xgcc)))
255 (synopsis "Complete GCC tool chain for ARM bare metal development")
256 (description "This package provides a complete GCC tool chain for ARM
257bare metal development. This includes the GCC arm-none-eabi cross compiler
258and newlib (or newlib-nano) as the C library. The supported programming
259languages are C and C++.")
260 (home-page (package-home-page xgcc))
261 (license (package-license xgcc)))))
262
263(define-public arm-none-eabi-toolchain-4.9
264 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
265 newlib-arm-none-eabi))
266
267(define-public arm-none-eabi-nano-toolchain-4.9
268 (arm-none-eabi-toolchain gcc-arm-none-eabi-4.9
269 newlib-nano-arm-none-eabi))
270
271(define-public arm-none-eabi-toolchain-6
272 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
273 newlib-arm-none-eabi))
274
275(define-public arm-none-eabi-nano-toolchain-6
276 (arm-none-eabi-toolchain gcc-arm-none-eabi-6
277 newlib-nano-arm-none-eabi))
94f36a4f
TF
278
279(define-public gdb-arm-none-eabi
280 (package
281 (inherit gdb)
282 (name "gdb-arm-none-eabi")
283 (arguments
284 `(#:configure-flags '("--target=arm-none-eabi"
285 "--enable-multilib"
286 "--enable-interwork"
287 "--enable-languages=c,c++"
288 "--disable-nls")
289 ,@(package-arguments gdb)))))
e5e45c06
DC
290
291(define-public libjaylink
292 ;; No release tarballs available.
293 (let ((commit "faa2a433fdd3de211728f3da5921133214af9dd3")
294 (revision "1"))
295 (package
296 (name "libjaylink")
297 (version (string-append "0.1.0-" revision "."
298 (string-take commit 7)))
299 (source (origin
300 (method git-fetch)
301 (uri (git-reference
302 (url "git://git.zapb.de/libjaylink.git")
303 (commit commit)))
304 (file-name (string-append name "-" version "-checkout"))
305 (sha256
306 (base32
307 "02crr56csz8whq3q4mrmdzzgwp5b0qvxm0fb18drclc3zj44yxl2"))))
308 (build-system gnu-build-system)
309 (native-inputs
310 `(("autoconf" ,autoconf)
311 ("automake" ,automake)
312 ("libtool" ,libtool)
313 ("pkg-config" ,pkg-config)))
314 (inputs
315 `(("libusb" ,libusb)))
316 (arguments
317 `(#:phases
318 (modify-phases %standard-phases
319 (add-before 'configure 'autoreconf
320 (lambda _
321 (zero? (system* "autoreconf" "-vfi")))))))
322 (home-page "http://repo.or.cz/w/libjaylink.git")
323 (synopsis "Library to interface Segger J-Link devices")
324 (description "libjaylink is a shared library written in C to access
325SEGGER J-Link and compatible devices.")
326 (license license:gpl2+))))
91ba6935
DC
327
328(define-public jimtcl
329 (package
330 (name "jimtcl")
331 (version "0.77")
332 (source (origin
333 (method url-fetch)
334 (uri (string-append
335 "https://github.com/msteveb/jimtcl"
336 "/archive/" version ".tar.gz"))
337 (file-name (string-append name "-" version ".tar.gz"))
338 (sha256
339 (base32
340 "1cmk3qscqckg70chjyimzxa2qcka4qac0j4wq908kiijp45cax08"))))
341 (build-system gnu-build-system)
342 (arguments
343 `(#:phases
344 (modify-phases %standard-phases
345 ;; Doesn't use autoconf.
346 (replace 'configure
347 (lambda* (#:key outputs #:allow-other-keys)
348 (let ((out (assoc-ref outputs "out")))
349 (zero? (system* "./configure"
350 (string-append "--prefix=" out)))))))))
351 (home-page "http://jim.tcl.tk")
352 (synopsis "Small footprint Tcl implementation")
353 (description "Jim is a small footprint implementation of the Tcl programming
354language.")
355 (license license:bsd-2)))
5b83b7b8
TF
356
357(define-public openocd
358 ;; FIXME: Use tarball release after nrf52 patch is merged.
359 (let ((commit "674141e8a7a6413cb803d90c2a20150260015f81")
360 (revision "1"))
361 (package
362 (name "openocd")
363 (version (string-append "0.9.0-" revision "."
364 (string-take commit 7)))
365 (source (origin
366 (method git-fetch)
367 (uri (git-reference
368 (url "git://git.code.sf.net/p/openocd/code.git")
369 (commit commit)))
370 (sha256
371 (base32
372 "1i86jp0wawq78d73z8hp7q1pn7lmlvhjjr19f7299h4w40a5jf8j"))
373 (file-name (string-append name "-" version "-checkout"))
374 (patches
375 (search-patches "openocd-nrf52.patch"))))
376 (build-system gnu-build-system)
377 (native-inputs
378 `(("autoconf" ,autoconf)
379 ("automake" ,automake)
380 ("libtool" ,libtool)
381 ("pkg-config" ,pkg-config)))
382 (inputs
383 `(("hidapi" ,hidapi)
384 ("jimtcl" ,jimtcl)
385 ("libftdi" ,libftdi)
386 ("libjaylink" ,libjaylink)
387 ("libusb-compat" ,libusb-compat)))
388 (arguments
389 '(#:configure-flags
390 (append (list "--disable-werror"
391 "--disable-internal-jimtcl"
392 "--disable-internal-libjaylink")
393 (map (lambda (programmer)
394 (string-append "--enable-" programmer))
395 '("amtjtagaccel" "armjtagew" "buspirate" "ftdi"
396 "gw16012" "jlink" "oocd_trace" "opendous" "osbdm"
397 "parport" "aice" "cmsis-dap" "dummy" "jtag_vpi"
398 "remote-bitbang" "rlink" "stlink" "ti-icdi" "ulink"
399 "usbprog" "vsllink" "usb-blaster-2" "usb_blaster"
400 "presto" "openjtag")))
401 #:phases
402 (modify-phases %standard-phases
403 (add-before 'configure 'autoreconf
404 (lambda _
405 (zero? (system* "autoreconf" "-vfi")))))))
406 (home-page "http://openocd.org")
407 (synopsis "On-Chip Debugger")
408 (description "OpenOCD provides on-chip programming and debugging support
409with a layered architecture of JTAG interface and TAP support.")
6d1b3bf5 410 (license license:gpl2+))))
2d7c9213
RW
411
412;; The commits for all propeller tools are the latest versions as published
413;; here: https://github.com/dbetz/propeller-gcc
414
415(define propeller-binutils
416 (let ((xbinutils (cross-binutils "propeller-elf"))
417 (commit "3bfba30076f8ce160a2f42914fdb68f24445fd44")
418 (revision "1"))
419 (package
420 (inherit xbinutils)
421 (name "propeller-binutils")
422 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
423 (source (origin (inherit (package-source xbinutils))
424 (method git-fetch)
425 (uri (git-reference
426 (url "https://github.com/totalspectrum/binutils-propeller.git")
427 (commit commit)))
428 (file-name (string-append name "-" commit "-checkout"))
429 (sha256
430 (base32
431 "1v3rgxwj7b8817wy5ccf8621v75qcxvcxygk4acr3hbc6yqybr8h"))))
432 (arguments
433 `(;; FIXME: For some reason there are many test failures. Some of them
434 ;; appear to be due to regular expression mismatch, but it's not
435 ;; obvious how to fix the failures.
436 #:tests? #f
437 #:phases
438 (modify-phases %standard-phases
439 (add-after 'unpack 'patch-/bin/sh-in-tests
440 (lambda _
441 (substitute* '("sim/testsuite/Makefile.in"
442 "sim/testsuite/mips64el-elf/Makefile.in"
443 "sim/testsuite/d10v-elf/Makefile.in"
444 "sim/testsuite/sim/cris/asm/badarch1.ms")
445 (("/bin/sh") (which "sh")))
446 #t)))
447 ,@(package-arguments xbinutils)))
448 (native-inputs
449 `(("bison" ,bison)
67656b7a 450 ("flex" ,flex-2.6.1) ; needed because of yywrap error
2d7c9213
RW
451 ("texinfo" ,texinfo)
452 ("dejagnu" ,dejagnu)
453 ,@(package-native-inputs xbinutils))))))
454
68cb2784
RW
455(define-public propeller-gcc
456 (let ((xgcc (cross-gcc "propeller-elf"
7b3318e3 457 #:xbinutils propeller-binutils))
68cb2784
RW
458 (commit "b4f45a4725e0b6d0af59e594c4e3e35ca4105867")
459 (revision "1"))
460 (package (inherit xgcc)
461 (name "propeller-gcc")
462 (version (string-append "6.0.0-" revision "." (string-take commit 9)))
463 (source (origin
464 (method git-fetch)
465 (uri (git-reference
466 (url "https://github.com/totalspectrum/gcc-propeller.git")
467 (commit commit)))
468 (file-name (string-append name "-" commit "-checkout"))
469 (sha256
470 (base32
471 "0d9kdxm2fzanjqa7q5850kzbsfl0fqyaahxn74h6nkxxacwa11zb"))
472 (patches
473 (append
474 (origin-patches (package-source gcc-6))
475 (search-patches "gcc-cross-environment-variables.patch")))))
476 (native-inputs
477 `(("flex" ,flex)
478 ,@(package-native-inputs xgcc)))
479 ;; All headers and cross libraries of the propeller toolchain are
480 ;; installed under the "propeller-elf" prefix.
481 (native-search-paths
482 (list (search-path-specification
483 (variable "CROSS_C_INCLUDE_PATH")
484 (files '("propeller-elf/include")))
485 (search-path-specification
486 (variable "CROSS_LIBRARY_PATH")
487 (files '("propeller-elf/lib")))))
488 (home-page "https://github.com/totalspectrum/gcc-propeller")
489 (synopsis "GCC for the Parallax Propeller"))))
490
db90eb8c
RW
491(define-public propeller-gcc-4
492 (let ((xgcc propeller-gcc)
493 (commit "f1b01001b760d691a91ff1db4830d41bb712557f")
494 (revision "1"))
495 (package (inherit xgcc)
496 (name "propeller-gcc")
497 (version (string-append "4.6.1-" revision "." (string-take commit 9)))
498 (source (origin
499 (method git-fetch)
500 (uri (git-reference
501 (url "https://github.com/dbetz/propgcc-gcc.git")
502 (commit commit)))
503 (file-name (string-append name "-" commit "-checkout"))
504 (sha256
505 (base32
506 "15mxrhk2v4vqmdkvcqy33ag1wrg9x9q20kx2w33kkw8pkrijknbi"))
507 (patches
508 (append
509 (origin-patches (package-source gcc-4.7))
510 (search-patches "gcc-4.6-gnu-inline.patch")))))
511 (home-page "https://github.com/dbetz/propgcc-gcc"))))
512
0d0079b2
RW
513;; There is no release, so we take the latest version as referenced from here:
514;; https://github.com/dbetz/propeller-gcc
515(define-public proplib
516 (let ((commit "844741fe0ceb140ab2fdf9d0667f68c1c39c31da")
517 (revision "1"))
518 (package
519 (name "proplib")
520 (version (string-append "0.0.0-" revision "." (string-take commit 9)))
521 (source (origin
522 (method git-fetch)
523 (uri (git-reference
524 (url "https://github.com/totalspectrum/proplib.git")
525 (commit commit)))
526 (file-name (string-append name "-" commit "-checkout"))
527 (sha256
528 (base32
529 "0q7irf1x8iqx07n7lzksax9armrdkizs49swsz76nbks0mw67wiv"))))
530 (build-system gnu-build-system)
531 (arguments
532 `(#:tests? #f ; no tests
533 #:make-flags
534 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
535 (string-append "BUILD=" (getcwd) "/build"))
536 #:phases
537 (modify-phases %standard-phases
538 (delete 'configure)
539 (add-after 'unpack 'fix-Makefile
540 (lambda _
541 (substitute* "Makefile"
542 ;; The GCC sources are not part of this package, so we cannot
543 ;; install the out-of-tree license file.
544 (("cp \\.\\..*") "")
545 ;; Control the installation time of the headers.
546 ((" install-includes") ""))
547 #t))
548 ;; The Makefile does not separate building from installation, so we
549 ;; have to create the target directories at build time.
550 (add-before 'build 'create-target-directories
551 (lambda* (#:key make-flags #:allow-other-keys)
552 (zero? (apply system* "make" "install-dirs" make-flags))))
553 (add-before 'build 'set-cross-environment-variables
554 (lambda* (#:key outputs #:allow-other-keys)
555 (setenv "CROSS_LIBRARY_PATH"
556 (string-append (assoc-ref outputs "out")
557 "/propeller-elf/lib:"
558 (or (getenv "CROSS_LIBRARY_PATH") "")))
559 (setenv "CROSS_C_INCLUDE_PATH"
560 (string-append (assoc-ref outputs "out")
561 "/propeller-elf/include:"
562 (or (getenv "CROSS_C_INCLUDE_PATH") "")))
563 #t))
564 (add-after 'build 'build-tiny
565 (lambda* (#:key make-flags #:allow-other-keys)
566 (zero? (apply system* "make" "tiny" make-flags))))
567 ;; The build of the tiny libraries depends on the includes to be
568 ;; available. Since we set CROSS_C_INCLUDE_PATH to the output
569 ;; directory, we have to install the includes first.
570 (add-before 'build-tiny 'install-includes
571 (lambda* (#:key make-flags #:allow-other-keys)
572 (zero? (apply system* "make" "install-includes" make-flags))))
573 (add-after 'install 'install-tiny
574 (lambda* (#:key make-flags #:allow-other-keys)
575 (zero? (apply system* "make" "install-tiny" make-flags)))))))
576 (native-inputs
577 `(("propeller-gcc" ,propeller-gcc)
578 ("propeller-binutils" ,propeller-binutils)
579 ("perl" ,perl)))
580 (home-page "https://github.com/totalspectrum/proplib")
581 (synopsis "C library for the Parallax Propeller")
582 (description "This is a C library for the Parallax Propeller
583micro-controller.")
584 ;; Most of the code is released under the Expat license. Some of the
585 ;; included code is public domain and some changes are BSD licensed.
586 (license license:expat))))
587
eb88fbaf
RW
588(define-public propeller-toolchain
589 (package
590 (name "propeller-toolchain")
591 (version (package-version propeller-gcc))
592 (source #f)
593 (build-system trivial-build-system)
594 (arguments '(#:builder (mkdir %output)))
595 (propagated-inputs
596 `(("binutils" ,propeller-binutils)
597 ("libc" ,proplib)
598 ("gcc" ,propeller-gcc)))
599 (synopsis "Complete GCC tool chain for Propeller micro-controllers")
600 (description "This package provides a complete GCC tool chain for
601Propeller micro-controller development.")
602 (home-page (package-home-page propeller-gcc))
603 (license (package-license propeller-gcc))))
604
150e0a1e
RW
605(define-public openspin
606 (package
607 (name "openspin")
608 (version "1.00.78")
609 (source (origin
610 (method url-fetch)
611 (uri (string-append "https://github.com/parallaxinc/"
612 "OpenSpin/archive/" version ".tar.gz"))
613 (file-name (string-append name "-" version ".tar.gz"))
614 (sha256
615 (base32
616 "1k2dbz1v604g4r2d9qhckg2m8dnhiya760mbsqfsg4waxal87yb7"))))
617 (build-system gnu-build-system)
618 (arguments
619 `(#:tests? #f ; no tests
620 #:phases
621 (modify-phases %standard-phases
622 (delete 'configure)
623 (add-after 'unpack 'remove-timestamp
624 (lambda _
625 (substitute* "SpinSource/openspin.cpp"
626 ((" Compiled on.*$") "\\n\");"))
627 #t))
628 ;; Makefile does not include "install" target
629 (replace 'install
630 (lambda* (#:key outputs #:allow-other-keys)
631 (let ((bin (string-append (assoc-ref outputs "out")
632 "/bin")))
633 (mkdir-p bin)
634 (install-file "build/openspin" bin)
635 #t))))))
636 (home-page "https://github.com/parallaxinc/OpenSpin")
637 (synopsis "Spin/PASM compiler for the Parallax Propeller")
638 (description "OpenSpin is a compiler for the Spin/PASM language of the
639Parallax Propeller. It was ported from Chip Gracey's original x86 assembler
640code.")
641 (license license:expat)))
642
c6b96af7
RW
643(define-public propeller-load
644 (let ((commit "ba9c0a7251cf751d8d292ae19ffa03132097c0c0")
645 (revision "1"))
646 (package
647 (name "propeller-load")
648 (version "3.4.0")
649 (source (origin
650 (method git-fetch)
651 (uri (git-reference
652 (url "https://github.com/dbetz/propeller-load.git")
653 (commit commit)))
654 (file-name (string-append name "-" commit "-checkout"))
655 (sha256
656 (base32
657 "1qv3xaapl9fmj3zn58b60sprp4rnvnlpci8ci0pdrzkw6fhvx3pg"))))
658 (build-system gnu-build-system)
659 (arguments
660 `(#:tests? #f ; no tests
661 #:make-flags
662 (list "OS=linux"
663 (string-append "TARGET=" (assoc-ref %outputs "out")))
664 #:phases
665 (modify-phases %standard-phases
666 (delete 'configure))))
667 (native-inputs
668 `(("openspin" ,openspin)
669 ("propeller-toolchain" ,propeller-toolchain)))
670 (home-page "https://github.com/dbetz/propeller-load")
671 (synopsis "Loader for Parallax Propeller micro-controllers")
672 (description "This package provides the tool @code{propeller-load} to
673upload binaries to a Parallax Propeller micro-controller.")
674 (license license:expat))))
675
0a7860c4
RW
676(define-public spin2cpp
677 (package
678 (name "spin2cpp")
679 (version "3.4.0")
680 (source (origin
681 (method url-fetch)
682 (uri (string-append "https://github.com/totalspectrum/spin2cpp/"
683 "archive/v" version ".tar.gz"))
684 (file-name (string-append name "-" version ".tar.gz"))
685 (sha256
686 (base32
687 "00i8i0dspd5115ggkv5vx2xqb21l6y38wz0bakgby8n3b4k9xnk0"))))
688 (build-system gnu-build-system)
689 (arguments
690 `(#:tests? #f ;; The tests assume that a micro-controller is connected.
691 #:phases
692 (modify-phases %standard-phases
693 (delete 'configure)
694 (add-before 'build 'set-cross-environment-variables
695 (lambda* (#:key inputs #:allow-other-keys)
696 (setenv "CROSS_LIBRARY_PATH"
697 (string-append (assoc-ref inputs "propeller-toolchain")
698 "/propeller-elf/lib"))
699 (setenv "CROSS_C_INCLUDE_PATH"
700 (string-append (assoc-ref inputs "propeller-toolchain")
701 "/propeller-elf/include"))
702 #t))
703 (replace 'install
704 (lambda* (#:key outputs #:allow-other-keys)
705 (let ((bin (string-append (assoc-ref outputs "out")
706 "/bin")))
707 (for-each (lambda (file)
708 (install-file (string-append "build/" file)
709 bin))
710 '("testlex" "spin2cpp" "fastspin")))
711 #t)))))
712 (native-inputs
713 `(("bison" ,bison)
714 ("propeller-load" ,propeller-load)
715 ("propeller-toolchain" ,propeller-toolchain)))
716 (home-page "https://github.com/totalspectrum/spin2cpp")
717 (synopsis "Convert Spin code to C, C++, or PASM code")
718 (description "This is a set of tools for converting the Spin language for
719the Parallax Propeller micro-controller into C or C++ code, into PASM, or even
720directly into an executable binary. The binaries produced use LMM PASM, so
721they are much faster than regular Spin bytecodes (but also quite a bit
722larger).")
723 (license license:expat)))
724
3ebc86d9
RW
725(define-public spinsim
726 (let ((commit "66915a7ad1a3a2cf990a725bb341fab8d11eb620")
727 (revision "1"))
728 (package
729 (name "spinsim")
730 (version (string-append "0.75-" revision "." (string-take commit 9)))
731 (source (origin
732 (method git-fetch)
733 (uri (git-reference
734 (url "https://github.com/parallaxinc/spinsim.git")
735 (commit commit)))
736 (file-name (string-append name "-" commit "-checkout"))
737 (sha256
738 (base32
739 "1n9kdhlxsdx7bz6c80w8dhi96zp633gd6qs0x9i4ii8qv4i7sj5k"))))
740 (build-system gnu-build-system)
741 (arguments
742 `(#:tests? #f ; no tests
743 #:phases
744 (modify-phases %standard-phases
745 (delete 'configure)
746 (replace 'install
747 (lambda* (#:key outputs #:allow-other-keys)
748 (let ((bin (string-append (assoc-ref outputs "out")
749 "/bin")))
750 (install-file "build/spinsim" bin))
751 #t)))))
752 (home-page "https://github.com/parallaxinc/spinsim")
753 (synopsis "Spin simulator")
754 (description "This package provides the tool @code{spinsim}, a simulator
755and simple debugger for Spin programs written for a Parallax Propeller
756micro-controller. Spinsim supports execution from cog memory and hub
757execution, but it does not support multi-tasking. It supports about
758two-thirds of the opcodes in the P2 instruction set.")
759 (license license:expat))))
760
395bbfdb
RW
761(define-public propeller-development-suite
762 (package
763 (name "propeller-development-suite")
764 (version (package-version propeller-gcc))
765 (source #f)
766 (build-system trivial-build-system)
767 (arguments '(#:builder (mkdir %output)))
768 (propagated-inputs
769 `(("toolchain" ,propeller-toolchain)
770 ("openspin" ,openspin)
771 ("propeller-load" ,propeller-load)
772 ("spin2cpp" ,spin2cpp)
773 ("spinsim" ,spinsim)))
774 (synopsis "Complete development suite for Propeller micro-controllers")
775 (description "This meta-package provides a complete environment for the
776development with Parallax Propeller micro-controllers. It includes the GCC
777toolchain, the loader, the Openspin compiler, the Spin2cpp tool, and the Spin
778simulator.")
779 (home-page (package-home-page propeller-gcc))
780 (license (package-license propeller-gcc))))
8ea42482
DM
781
782(define-public binutils-vc4
783 (let ((commit "708acc851880dbeda1dd18aca4fd0a95b2573b36"))
784 (package
785 (name "binutils-vc4")
786 (version (string-append "2.23.51-0." (string-take commit 7)))
787 (source (origin
788 (method git-fetch)
789 (uri (git-reference
790 (url "https://github.com/puppeh/binutils-vc4.git")
791 (commit commit)))
493ae57e 792 (file-name (string-append name "-" version "-checkout"))
8ea42482
DM
793 (sha256
794 (base32
795 "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"))))
796 (build-system gnu-build-system)
797 (arguments
798 `(#:configure-flags '("--target=vc4-elf"
799 "--disable-werror"
800 "--enable-cgen-maint")
801 #:phases
802 (modify-phases %standard-phases
803 (add-after 'unpack 'unpack-cgen
804 (lambda* (#:key inputs #:allow-other-keys)
805 (copy-recursively (string-append (assoc-ref inputs "cgen")
806 "/cgen") "cgen")
807 #t))
808 (add-after 'unpack-cgen 'fix-cgen-guile
809 (lambda _
810 (substitute* "opcodes/Makefile.in"
811 (("guile\\{,-\\}1.8") "guile"))
812 (zero? (system* "which" "guile")))))))
813 (native-inputs
814 `(("cgen"
815 ,(origin
816 (method git-fetch)
817 (uri (git-reference
818 (url "https://github.com/puppeh/cgen.git")
819 (commit "d8e2a9eb70425f180fdd5bfd032884b0855f2032")))
820 (sha256
821 (base32
822 "14b3h2ji740s8zq5vwm4qdcxs4aa4wxi6wb9di3bv1h39x14nyr9"))))
823 ("texinfo" ,texinfo)
575a6f0f 824 ("flex" ,flex-2.6.1) ; A bug in flex prevents building with flex-2.6.3.
8ea42482
DM
825 ("bison" ,bison)
826 ("guile-1.8" ,guile-1.8)
827 ("which" ,base:which)))
828 (synopsis "Binutils for VC4")
829 (description "This package provides @code{binutils} for VideoCore IV,
830the Raspberry Pi chip.")
831 (license license:gpl3+)
832 (home-page "https://github.com/puppeh/vc4-toolchain/"))))
7cf06d62
DM
833
834(define-public gcc-vc4
835 (let ((commit "165f6d0e11d2e76ee799533bb45bd5c92bf60dc2")
7b3318e3 836 (xgcc (cross-gcc "vc4-elf" #:xbinutils binutils-vc4)))
7cf06d62
DM
837 (package (inherit xgcc)
838 (name "gcc-vc4")
839 (source (origin
840 (method git-fetch)
841 (uri (git-reference
842 (url "https://github.com/puppeh/gcc-vc4.git")
843 (commit commit)))
844 (file-name (string-append name
845 "-"
846 (package-version xgcc)
847 "-checkout"))
848 (sha256
849 (base32
850 "13h30qjcwnlz6lfma1d82nnvfmjnhh7abkagip4vly6vm5fpnvf2"))))
851 (native-inputs
852 `(("flex" ,flex)
853 ,@(package-native-inputs xgcc)))
854 (synopsis "GCC for VC4")
855 (description "This package provides @code{gcc} for VideoCore IV,
856the Raspberry Pi chip."))))