gnu: calibre: Wrap QTWEBENGINEPROCESS_PATH.
[jackhill/guix/guix.git] / gnu / packages / avr.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2016 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
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)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix utils)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix packages)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system trivial)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages cross-base)
35 #:use-module (gnu packages flashing-tools)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages vim))
38
39 (define-public avr-binutils
40 (package
41 (inherit (cross-binutils "avr"))
42 (name "avr-binutils")))
43
44 (define-public avr-gcc-4.9
45 (let ((xgcc (cross-gcc "avr" #:xgcc gcc-4.9 #:xbinutils avr-binutils)))
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
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)))
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
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")
92 (files '("avr/include")))
93 (search-path-specification
94 (variable "CROSS_LIBRARY_PATH")
95 (files '("avr/lib")))))
96 (native-inputs
97 `(("gcc@5" ,gcc-5)
98 ,@(package-native-inputs xgcc))))))
99
100 (define-public avr-gcc-5
101 (package
102 (inherit avr-gcc-4.9)
103 (version (package-version gcc-5))
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")))))))
108
109 (define (avr-libc avr-gcc)
110 (package
111 (name "avr-libc")
112 (version "2.0.0")
113 (source (origin
114 (method url-fetch)
115 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
116 version ".tar.bz2"))
117 (sha256
118 (base32
119 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
120 (build-system gnu-build-system)
121 (arguments
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 _
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.
132 (unsetenv "C_INCLUDE_PATH")
133 (unsetenv "CPATH")
134 #t)))))
135 (native-inputs `(("avr-binutils" ,avr-binutils)
136 ("avr-gcc" ,avr-gcc)))
137 (home-page "https://www.nongnu.org/avr-libc/")
138 (synopsis "The AVR C Library")
139 (description
140 "AVR Libc is a project whose goal is to provide a high quality C library
141 for use with GCC on Atmel AVR microcontrollers.")
142 (license
143 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
144
145 (define (avr-toolchain avr-gcc)
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)
154 (arguments '(#:builder (begin (mkdir %output) #t)))
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
162 microcontroller development. This includes the GCC AVR cross compiler and
163 avrdude for firmware flashing. The supported programming languages are C and
164 C++.")
165 (home-page (package-home-page avr-libc))
166 (license (package-license avr-gcc)))))
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))
170
171 (define-public microscheme
172 (package
173 (name "microscheme")
174 (version "0.9.3")
175 (source
176 (origin
177 (method git-fetch)
178 (uri (git-reference
179 (url "https://github.com/ryansuchocki/microscheme")
180 (commit (string-append "v" version))))
181 (sha256
182 (base32 "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976"))
183 (file-name (git-file-name name version))))
184 (build-system gnu-build-system)
185 (arguments
186 `(#:parallel-build? #f ; fails to build otherwise
187 #:tests? #f ; no tests
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)
195 ("xxd" ,xxd)))
196 (home-page "https://github.com/ryansuchocki/microscheme/")
197 (synopsis "Scheme subset for Atmel microcontrollers")
198 (description
199 "Microscheme, or @code{(ms)} for short, is a functional programming
200 language for the Arduino, and for Atmel 8-bit AVR microcontrollers in general.
201 Microscheme is a subset of Scheme, in the sense that every valid @code{(ms)}
202 program is also a valid Scheme program (with the exception of Arduino
203 hardware-specific primitives). The @code{(ms)} compiler performs function
204 inlining, and features an aggressive tree-shaker, eliminating unused top-level
205 definitions. Microscheme has a robust @dfn{Foreign Function Interface} (FFI)
206 meaning that C code may be invoked directly from (ms) programs.")
207 (license license:expat)))