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