gnu: alsa-modular-synth: Build with GCC 5.
[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")
70 (files '("avr/lib"))))))))
71
a17eea4b
DT
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
4d2470b0 78(define (avr-libc avr-gcc)
a5b60e3c
MR
79 (package
80 (name "avr-libc")
3087b707 81 (version "2.0.0")
a5b60e3c
MR
82 (source (origin
83 (method url-fetch)
3087b707
DT
84 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
85 version ".tar.bz2"))
a5b60e3c
MR
86 (sha256
87 (base32
3087b707 88 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
a5b60e3c
MR
89 (build-system gnu-build-system)
90 (arguments
e60972f2
DT
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)
4d2470b0 104 ("avr-gcc" ,avr-gcc)))
340978d7 105 (home-page "https://www.nongnu.org/avr-libc/")
a5b60e3c
MR
106 (synopsis "The AVR C Library")
107 (description
108 "AVR Libc is a project whose goal is to provide a high quality C library
109for use with GCC on Atmel AVR microcontrollers.")
e60972f2
DT
110 (license
111 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
112
9d2bab09 113(define (avr-toolchain avr-gcc)
4d2470b0
DM
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)
e3cfef22 122 (arguments '(#:builder (begin (mkdir %output) #t)))
4d2470b0
DM
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
9d2bab09
DT
130microcontroller development. This includes the GCC AVR cross compiler and
131avrdude for firmware flashing. The supported programming languages are C and
132C++.")
4d2470b0
DM
133 (home-page (package-home-page avr-libc))
134 (license (package-license avr-gcc)))))
9d2bab09
DT
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))
6d2e8334
RW
138
139(define-public microscheme
140 (package
141 (name "microscheme")
2b8ca5fc 142 (version "0.9.3")
a4880a27
TGR
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))))
6d2e8334
RW
152 (build-system gnu-build-system)
153 (arguments
a4880a27
TGR
154 `(#:parallel-build? #f ; fails to build otherwise
155 #:tests? #f ; no tests
6d2e8334
RW
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)
9fc513ad 163 ("xxd" ,xxd)))
43051760 164 (home-page "https://github.com/ryansuchocki/microscheme/")
6d2e8334
RW
165 (synopsis "Scheme subset for Atmel microcontrollers")
166 (description
167 "Microscheme, or @code{(ms)} for short, is a functional programming
168language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general.
169Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)}
170program is also a valid Scheme program (with the exception of Arduino
171hardware-specific primitives). The @code{(ms)} compiler performs function
172inlining, and features an aggressive tree-shaker, eliminating unused top-level
173definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI)
174meaning that C code may be invoked directly from (ms) programs.")
175 (license license:expat)))