Commit | Line | Data |
---|---|---|
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 | |
2f3515f7 DM |
66 | (variable "CROSS_C_INCLUDE_PATH") |
67 | (files '("avr/include"))) | |
68 | (search-path-specification | |
69 | (variable "CROSS_CPLUS_INCLUDE_PATH") | |
70 | (files '("avr/include"))) | |
71 | (search-path-specification | |
72 | (variable "CROSS_OBJC_INCLUDE_PATH") | |
73 | (files '("avr/include"))) | |
74 | (search-path-specification | |
75 | (variable "CROSS_OBJCPLUS_INCLUDE_PATH") | |
09b05fc7 DT |
76 | (files '("avr/include"))) |
77 | (search-path-specification | |
78 | (variable "CROSS_LIBRARY_PATH") | |
081f767e RW |
79 | (files '("avr/lib"))))) |
80 | (native-inputs | |
81 | `(("gcc" ,gcc-5) | |
82 | ,@(package-native-inputs xgcc)))))) | |
09b05fc7 | 83 | |
a17eea4b DT |
84 | (define-public avr-gcc-5 |
85 | (package | |
86 | (inherit avr-gcc-4.9) | |
87 | (version (package-version gcc-5)) | |
2f3515f7 DM |
88 | (source (origin |
89 | (inherit (package-source gcc-5)) | |
90 | (patches (append (origin-patches (package-source gcc-5)) | |
91 | (search-patches "gcc-cross-environment-variables.patch"))))))) | |
a17eea4b | 92 | |
4d2470b0 | 93 | (define (avr-libc avr-gcc) |
a5b60e3c MR |
94 | (package |
95 | (name "avr-libc") | |
3087b707 | 96 | (version "2.0.0") |
a5b60e3c MR |
97 | (source (origin |
98 | (method url-fetch) | |
3087b707 DT |
99 | (uri (string-append "mirror://savannah//avr-libc/avr-libc-" |
100 | version ".tar.bz2")) | |
a5b60e3c MR |
101 | (sha256 |
102 | (base32 | |
3087b707 | 103 | "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj")))) |
a5b60e3c MR |
104 | (build-system gnu-build-system) |
105 | (arguments | |
e60972f2 DT |
106 | '(#:out-of-source? #t |
107 | #:configure-flags '("--host=avr") | |
108 | #:phases | |
109 | (modify-phases %standard-phases | |
110 | (add-before 'unpack 'fix-cpath | |
111 | (lambda _ | |
923b2b5a RW |
112 | ;; C_INCLUDE_PATH and CPATH pose issues for cross-building, |
113 | ;; leading to failures when building avr-libc on 64-bit systems. | |
114 | ;; Simply unsetting them allows the build to succeed because it | |
115 | ;; doesn't try to use any of the native system's headers. | |
e60972f2 | 116 | (unsetenv "C_INCLUDE_PATH") |
923b2b5a | 117 | (unsetenv "CPATH") |
e60972f2 DT |
118 | #t))))) |
119 | (native-inputs `(("avr-binutils" ,avr-binutils) | |
4d2470b0 | 120 | ("avr-gcc" ,avr-gcc))) |
340978d7 | 121 | (home-page "https://www.nongnu.org/avr-libc/") |
a5b60e3c MR |
122 | (synopsis "The AVR C Library") |
123 | (description | |
124 | "AVR Libc is a project whose goal is to provide a high quality C library | |
125 | for use with GCC on Atmel AVR microcontrollers.") | |
e60972f2 DT |
126 | (license |
127 | (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt")))) | |
128 | ||
9d2bab09 | 129 | (define (avr-toolchain avr-gcc) |
4d2470b0 DM |
130 | ;; avr-libc checks the compiler version and passes "--enable-device-lib" for avr-gcc > 5.1.0. |
131 | ;; It wouldn't install the library for atmega32u4 etc if we didn't use the corret avr-gcc. | |
132 | (let ((avr-libc (avr-libc avr-gcc))) | |
133 | (package | |
134 | (name "avr-toolchain") | |
135 | (version (package-version avr-gcc)) | |
136 | (source #f) | |
137 | (build-system trivial-build-system) | |
e3cfef22 | 138 | (arguments '(#:builder (begin (mkdir %output) #t))) |
4d2470b0 DM |
139 | (propagated-inputs |
140 | `(("avrdude" ,avrdude) | |
141 | ("binutils" ,avr-binutils) | |
142 | ("gcc" ,avr-gcc) | |
143 | ("libc" ,avr-libc))) | |
144 | (synopsis "Complete GCC tool chain for AVR microcontroller development") | |
145 | (description "This package provides a complete GCC tool chain for AVR | |
9d2bab09 DT |
146 | microcontroller development. This includes the GCC AVR cross compiler and |
147 | avrdude for firmware flashing. The supported programming languages are C and | |
148 | C++.") | |
4d2470b0 DM |
149 | (home-page (package-home-page avr-libc)) |
150 | (license (package-license avr-gcc))))) | |
9d2bab09 DT |
151 | |
152 | (define-public avr-toolchain-4.9 (avr-toolchain avr-gcc-4.9)) | |
153 | (define-public avr-toolchain-5 (avr-toolchain avr-gcc-5)) | |
6d2e8334 RW |
154 | |
155 | (define-public microscheme | |
156 | (package | |
157 | (name "microscheme") | |
2b8ca5fc | 158 | (version "0.9.3") |
a4880a27 TGR |
159 | (source |
160 | (origin | |
161 | (method git-fetch) | |
162 | (uri (git-reference | |
163 | (url "https://github.com/ryansuchocki/microscheme.git") | |
164 | (commit (string-append "v" version)))) | |
165 | (sha256 | |
166 | (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976")) | |
167 | (file-name (git-file-name name version)))) | |
6d2e8334 RW |
168 | (build-system gnu-build-system) |
169 | (arguments | |
a4880a27 TGR |
170 | `(#:parallel-build? #f ; fails to build otherwise |
171 | #:tests? #f ; no tests | |
6d2e8334 RW |
172 | #:phases |
173 | (modify-phases %standard-phases | |
174 | (delete 'configure)) | |
175 | #:make-flags | |
176 | (list (string-append "PREFIX=" (assoc-ref %outputs "out"))))) | |
177 | (native-inputs | |
178 | `(("unzip" ,unzip) | |
9fc513ad | 179 | ("xxd" ,xxd))) |
43051760 | 180 | (home-page "https://github.com/ryansuchocki/microscheme/") |
6d2e8334 RW |
181 | (synopsis "Scheme subset for Atmel microcontrollers") |
182 | (description | |
183 | "Microscheme, or @code{(ms)} for short, is a functional programming | |
184 | language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general. | |
185 | Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)} | |
186 | program is also a valid Scheme program (with the exception of Arduino | |
187 | hardware-specific primitives). The @code{(ms)} compiler performs function | |
188 | inlining, and features an aggressive tree-shaker, eliminating unused top-level | |
189 | definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI) | |
190 | meaning that C code may be invoked directly from (ms) programs.") | |
191 | (license license:expat))) |