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