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