gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / avr.scm
CommitLineData
a5b60e3c 1;;; GNU Guix --- Functional package management for GNU
cdc5cfdc 2;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
6a34e2ae 3;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
cdc5cfdc 4;;; Copyright © 2016 David Thompson <davet@gnu.org>
2b8ca5fc 5;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
a4880a27 6;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
a5b60e3c
MR
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)
42f8504c 24 #:use-module ((guix licenses) #:prefix license:)
09b05fc7 25 #:use-module (guix utils)
a5b60e3c 26 #:use-module (guix download)
a4880a27 27 #:use-module (guix git-download)
a5b60e3c
MR
28 #:use-module (guix packages)
29 #:use-module (guix build-system gnu)
9d2bab09 30 #:use-module (guix build-system trivial)
a5b60e3c 31 #:use-module (gnu packages)
148585c2 32 #:use-module (gnu packages compression)
6d2e8334 33 #:use-module (gnu packages cross-base)
9d2bab09 34 #:use-module (gnu packages flashing-tools)
a17eea4b 35 #:use-module (gnu packages gcc)
148585c2 36 #:use-module (gnu packages vim))
a5b60e3c 37
cdc5cfdc
DT
38(define-public avr-binutils
39 (package
40 (inherit (cross-binutils "avr"))
41 (name "avr-binutils")))
42
09b05fc7 43(define-public avr-gcc-4.9
6a34e2ae 44 (let ((xgcc (cross-gcc "avr" #:xgcc gcc-4.9 #:xbinutils avr-binutils)))
09b05fc7
DT
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")
081f767e
RW
70 (files '("avr/lib")))))
71 (native-inputs
72 `(("gcc" ,gcc-5)
73 ,@(package-native-inputs xgcc))))))
09b05fc7 74
a17eea4b
DT
75(define-public avr-gcc-5
76 (package
77 (inherit avr-gcc-4.9)
78 (version (package-version gcc-5))
79 (source (package-source gcc-5))))
80
4d2470b0 81(define (avr-libc avr-gcc)
a5b60e3c
MR
82 (package
83 (name "avr-libc")
3087b707 84 (version "2.0.0")
a5b60e3c
MR
85 (source (origin
86 (method url-fetch)
3087b707
DT
87 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
88 version ".tar.bz2"))
a5b60e3c
MR
89 (sha256
90 (base32
3087b707 91 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
a5b60e3c
MR
92 (build-system gnu-build-system)
93 (arguments
e60972f2
DT
94 '(#:out-of-source? #t
95 #:configure-flags '("--host=avr")
96 #:phases
97 (modify-phases %standard-phases
98 (add-before 'unpack 'fix-cpath
99 (lambda _
923b2b5a
RW
100 ;; C_INCLUDE_PATH and CPATH pose issues for cross-building,
101 ;; leading to failures when building avr-libc on 64-bit systems.
102 ;; Simply unsetting them allows the build to succeed because it
103 ;; doesn't try to use any of the native system's headers.
e60972f2 104 (unsetenv "C_INCLUDE_PATH")
923b2b5a 105 (unsetenv "CPATH")
e60972f2
DT
106 #t)))))
107 (native-inputs `(("avr-binutils" ,avr-binutils)
4d2470b0 108 ("avr-gcc" ,avr-gcc)))
340978d7 109 (home-page "https://www.nongnu.org/avr-libc/")
a5b60e3c
MR
110 (synopsis "The AVR C Library")
111 (description
112 "AVR Libc is a project whose goal is to provide a high quality C library
113for use with GCC on Atmel AVR microcontrollers.")
e60972f2
DT
114 (license
115 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
116
9d2bab09 117(define (avr-toolchain avr-gcc)
4d2470b0
DM
118 ;; avr-libc checks the compiler version and passes "--enable-device-lib" for avr-gcc > 5.1.0.
119 ;; It wouldn't install the library for atmega32u4 etc if we didn't use the corret avr-gcc.
120 (let ((avr-libc (avr-libc avr-gcc)))
121 (package
122 (name "avr-toolchain")
123 (version (package-version avr-gcc))
124 (source #f)
125 (build-system trivial-build-system)
e3cfef22 126 (arguments '(#:builder (begin (mkdir %output) #t)))
4d2470b0
DM
127 (propagated-inputs
128 `(("avrdude" ,avrdude)
129 ("binutils" ,avr-binutils)
130 ("gcc" ,avr-gcc)
131 ("libc" ,avr-libc)))
132 (synopsis "Complete GCC tool chain for AVR microcontroller development")
133 (description "This package provides a complete GCC tool chain for AVR
9d2bab09
DT
134microcontroller development. This includes the GCC AVR cross compiler and
135avrdude for firmware flashing. The supported programming languages are C and
136C++.")
4d2470b0
DM
137 (home-page (package-home-page avr-libc))
138 (license (package-license avr-gcc)))))
9d2bab09
DT
139
140(define-public avr-toolchain-4.9 (avr-toolchain avr-gcc-4.9))
141(define-public avr-toolchain-5 (avr-toolchain avr-gcc-5))
6d2e8334
RW
142
143(define-public microscheme
144 (package
145 (name "microscheme")
2b8ca5fc 146 (version "0.9.3")
a4880a27
TGR
147 (source
148 (origin
149 (method git-fetch)
150 (uri (git-reference
151 (url "https://github.com/ryansuchocki/microscheme.git")
152 (commit (string-append "v" version))))
153 (sha256
154 (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976"))
155 (file-name (git-file-name name version))))
6d2e8334
RW
156 (build-system gnu-build-system)
157 (arguments
a4880a27
TGR
158 `(#:parallel-build? #f ; fails to build otherwise
159 #:tests? #f ; no tests
6d2e8334
RW
160 #:phases
161 (modify-phases %standard-phases
162 (delete 'configure))
163 #:make-flags
164 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
165 (native-inputs
166 `(("unzip" ,unzip)
9fc513ad 167 ("xxd" ,xxd)))
43051760 168 (home-page "https://github.com/ryansuchocki/microscheme/")
6d2e8334
RW
169 (synopsis "Scheme subset for Atmel microcontrollers")
170 (description
171 "Microscheme, or @code{(ms)} for short, is a functional programming
172language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general.
173Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)}
174program is also a valid Scheme program (with the exception of Arduino
175hardware-specific primitives). The @code{(ms)} compiler performs function
176inlining, and features an aggressive tree-shaker, eliminating unused top-level
177definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI)
178meaning that C code may be invoked directly from (ms) programs.")
179 (license license:expat)))