gnu: emacspeak: Fix Tclx and espeak server loading.
[jackhill/guix/guix.git] / gnu / packages / avr.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages avr)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix utils)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix packages)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages cross-base)
36 #:use-module (gnu packages flashing-tools)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages vim))
39
40 (define-public avr-binutils
41 (package
42 (inherit (cross-binutils "avr"))
43 (name "avr-binutils")))
44
45 (define avr-gcc
46 (let ((xgcc (cross-gcc "avr" #:xgcc gcc #:xbinutils avr-binutils)))
47 (package
48 (inherit xgcc)
49 (name "avr-gcc")
50 (arguments
51 (substitute-keyword-arguments (package-arguments xgcc)
52 ((#:phases phases)
53 `(modify-phases ,phases
54 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
55 (lambda* (#:key inputs #:allow-other-keys)
56 (let ((gcc (assoc-ref inputs "gcc")))
57 ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
58 ;; prevent header conflict with the GCC from native-inputs.
59 (setenv "CPLUS_INCLUDE_PATH"
60 (string-join
61 (delete (string-append gcc "/include/c++")
62 (string-split (getenv "CPLUS_INCLUDE_PATH")
63 #\:))
64 ":"))
65 (format #t
66 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
67 (getenv "CPLUS_INCLUDE_PATH"))
68 #t)))
69 ;; Without a working multilib build, the resulting GCC lacks
70 ;; support for nearly every AVR chip.
71 (add-after 'unpack 'fix-genmultilib
72 (lambda _
73 ;; patch-shebang doesn't work here because there are actually
74 ;; several scripts inside this script, each with a #!/bin/sh
75 ;; that needs patching.
76 (substitute* "gcc/genmultilib"
77 (("#!/bin/sh") (string-append "#!" (which "sh"))))
78 #t))))
79 ((#:configure-flags flags)
80 `(delete "--disable-multilib" ,flags))))
81 (native-search-paths
82 (list (search-path-specification
83 (variable "CROSS_C_INCLUDE_PATH")
84 (files '("avr/include")))
85 (search-path-specification
86 (variable "CROSS_CPLUS_INCLUDE_PATH")
87 (files '("avr/include")))
88 (search-path-specification
89 (variable "CROSS_OBJC_INCLUDE_PATH")
90 (files '("avr/include")))
91 (search-path-specification
92 (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
93 (files '("avr/include")))
94 (search-path-specification
95 (variable "CROSS_LIBRARY_PATH")
96 (files '("avr/lib")))))
97 (native-inputs
98 `(("gcc" ,gcc)
99 ,@(package-native-inputs xgcc))))))
100
101 (define avr-libc
102 (package
103 (name "avr-libc")
104 (version "2.0.0")
105 (source (origin
106 (method url-fetch)
107 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
108 version ".tar.bz2"))
109 (sha256
110 (base32
111 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
112 (build-system gnu-build-system)
113 (arguments
114 '(#:out-of-source? #t
115 #:configure-flags '("--host=avr")))
116 (native-inputs `(("avr-binutils" ,avr-binutils)
117 ("avr-gcc" ,avr-gcc)))
118 (home-page "https://www.nongnu.org/avr-libc/")
119 (synopsis "The AVR C Library")
120 (description
121 "AVR Libc is a project whose goal is to provide a high quality C library
122 for use with GCC on Atmel AVR microcontrollers.")
123 (license
124 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
125
126 (define-public avr-toolchain
127 ;; avr-libc checks the compiler version and passes "--enable-device-lib" for avr-gcc > 5.1.0.
128 ;; It wouldn't install the library for atmega32u4 etc if we didn't use the corret avr-gcc.
129 (package
130 (name "avr-toolchain")
131 (version (package-version avr-gcc))
132 (source #f)
133 (build-system trivial-build-system)
134 (arguments '(#:builder (begin (mkdir %output) #t)))
135 (propagated-inputs
136 `(("avrdude" ,avrdude)
137 ("binutils" ,avr-binutils)
138 ("gcc" ,avr-gcc)
139 ("libc" ,avr-libc)))
140 (synopsis "Complete GCC tool chain for AVR microcontroller development")
141 (description "This package provides a complete GCC tool chain for AVR
142 microcontroller development. This includes the GCC AVR cross compiler and
143 avrdude for firmware flashing. The supported programming languages are C and
144 C++.")
145 (home-page (package-home-page avr-libc))
146 (license (package-license avr-gcc))))
147
148 (define-public microscheme
149 (package
150 (name "microscheme")
151 (version "0.9.3")
152 (source
153 (origin
154 (method git-fetch)
155 (uri (git-reference
156 (url "https://github.com/ryansuchocki/microscheme")
157 (commit (string-append "v" version))))
158 (sha256
159 (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976"))
160 (file-name (git-file-name name version))))
161 (build-system gnu-build-system)
162 (arguments
163 `(#:parallel-build? #f ; fails to build otherwise
164 #:tests? #f ; no tests
165 #:phases
166 (modify-phases %standard-phases
167 (delete 'configure))
168 #:make-flags
169 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
170 (native-inputs
171 `(("unzip" ,unzip)
172 ("xxd" ,xxd)))
173 (home-page "https://github.com/ryansuchocki/microscheme/")
174 (synopsis "Scheme subset for Atmel microcontrollers")
175 (description
176 "Microscheme, or @code{(ms)} for short, is a functional programming
177 language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general.
178 Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)}
179 program is also a valid Scheme program (with the exception of Arduino
180 hardware-specific primitives). The @code{(ms)} compiler performs function
181 inlining, and features an aggressive tree-shaker, eliminating unused top-level
182 definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI)
183 meaning that C code may be invoked directly from (ms) programs.")
184 (license license:expat)))