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> |
fd96ae4a | 7 | ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com> |
5a3827d4 | 8 | ;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net> |
a5b60e3c MR |
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) | |
42f8504c | 26 | #:use-module ((guix licenses) #:prefix license:) |
09b05fc7 | 27 | #:use-module (guix utils) |
a5b60e3c | 28 | #:use-module (guix download) |
a4880a27 | 29 | #:use-module (guix git-download) |
a5b60e3c MR |
30 | #:use-module (guix packages) |
31 | #:use-module (guix build-system gnu) | |
9d2bab09 | 32 | #:use-module (guix build-system trivial) |
a5b60e3c | 33 | #:use-module (gnu packages) |
148585c2 | 34 | #:use-module (gnu packages compression) |
6d2e8334 | 35 | #:use-module (gnu packages cross-base) |
9d2bab09 | 36 | #:use-module (gnu packages flashing-tools) |
a17eea4b | 37 | #:use-module (gnu packages gcc) |
148585c2 | 38 | #:use-module (gnu packages vim)) |
a5b60e3c | 39 | |
cdc5cfdc DT |
40 | (define-public avr-binutils |
41 | (package | |
42 | (inherit (cross-binutils "avr")) | |
43 | (name "avr-binutils"))) | |
44 | ||
197c1676 AI |
45 | (define avr-gcc |
46 | (let ((xgcc (cross-gcc "avr" #:xgcc gcc #:xbinutils avr-binutils))) | |
09b05fc7 DT |
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 | |
fd96ae4a MB |
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))) | |
09b05fc7 DT |
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 | |
2f3515f7 DM |
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") | |
09b05fc7 DT |
93 | (files '("avr/include"))) |
94 | (search-path-specification | |
95 | (variable "CROSS_LIBRARY_PATH") | |
081f767e RW |
96 | (files '("avr/lib"))))) |
97 | (native-inputs | |
197c1676 | 98 | `(("gcc" ,gcc) |
081f767e | 99 | ,@(package-native-inputs xgcc)))))) |
09b05fc7 | 100 | |
197c1676 | 101 | (define avr-libc |
a5b60e3c MR |
102 | (package |
103 | (name "avr-libc") | |
3087b707 | 104 | (version "2.0.0") |
a5b60e3c MR |
105 | (source (origin |
106 | (method url-fetch) | |
3087b707 DT |
107 | (uri (string-append "mirror://savannah//avr-libc/avr-libc-" |
108 | version ".tar.bz2")) | |
a5b60e3c MR |
109 | (sha256 |
110 | (base32 | |
3087b707 | 111 | "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj")))) |
a5b60e3c MR |
112 | (build-system gnu-build-system) |
113 | (arguments | |
e60972f2 | 114 | '(#:out-of-source? #t |
5a3827d4 | 115 | #:configure-flags '("--host=avr"))) |
e60972f2 | 116 | (native-inputs `(("avr-binutils" ,avr-binutils) |
4d2470b0 | 117 | ("avr-gcc" ,avr-gcc))) |
340978d7 | 118 | (home-page "https://www.nongnu.org/avr-libc/") |
a5b60e3c MR |
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.") | |
e60972f2 DT |
123 | (license |
124 | (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt")))) | |
125 | ||
197c1676 | 126 | (define-public avr-toolchain |
4d2470b0 DM |
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. | |
197c1676 AI |
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 | |
9d2bab09 DT |
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++.") | |
197c1676 AI |
145 | (home-page (package-home-page avr-libc)) |
146 | (license (package-license avr-gcc)))) | |
6d2e8334 RW |
147 | |
148 | (define-public microscheme | |
149 | (package | |
150 | (name "microscheme") | |
2b8ca5fc | 151 | (version "0.9.3") |
a4880a27 TGR |
152 | (source |
153 | (origin | |
154 | (method git-fetch) | |
155 | (uri (git-reference | |
b0e7b699 | 156 | (url "https://github.com/ryansuchocki/microscheme") |
a4880a27 TGR |
157 | (commit (string-append "v" version)))) |
158 | (sha256 | |
159 | (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976")) | |
160 | (file-name (git-file-name name version)))) | |
6d2e8334 RW |
161 | (build-system gnu-build-system) |
162 | (arguments | |
a4880a27 TGR |
163 | `(#:parallel-build? #f ; fails to build otherwise |
164 | #:tests? #f ; no tests | |
6d2e8334 RW |
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) | |
9fc513ad | 172 | ("xxd" ,xxd))) |
43051760 | 173 | (home-page "https://github.com/ryansuchocki/microscheme/") |
6d2e8334 RW |
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))) |