projects/guix·blob python-team · refs

166 lines · 6.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2016 Manolis Fragkiskos Ragkousis <[email protected]>
3;;; Copyright © 2017, 2023 Ricardo Wurmus <[email protected]>
4;;; Copyright © 2016 David Thompson <[email protected]>
5;;; Copyright © 2020 Marius Bakke <[email protected]>
6;;; Copyright © 2020 Arun Isaac <[email protected]>
7;;; Copyright © 2023 Maxim Cournoyer <[email protected]>
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;;; Commentary:
25;;;
26;;; This module defines a procedure that can be used to create a complete
27;;; avr-toolchain package. The procedure must not be used at the top level,
28;;; to avoid cyclic module dependencies caused by the (gnu packages
29;;; cross-base) module referring to top level bindings from (gnu packages
30;;; gcc).
31;;;
32;;; It also contains packages for working with or targeting the AVR system.
33;;;
34
35(define-module (gnu packages avr)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix gexp)
38 #:use-module (guix memoization)
39 #:use-module (guix utils)
40 #:use-module (guix download)
41 #:use-module (guix packages)
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system trivial)
44 #:use-module (gnu packages cross-base)
45 #:use-module (gnu packages flashing-tools)
46 #:use-module (gnu packages gcc)
47 #:export (make-avr-libc
48 make-avr-toolchain))
49
50(define make-avr-binutils
51 (mlambda ()
52 (package
53 (inherit (cross-binutils "avr"))
54 (name "avr-binutils"))))
55
56(define* (make-avr-gcc/implementation #:key (xgcc gcc))
57 "Return a XGCC-base cross-compiler for the AVR target."
58 (let ((xgcc (cross-gcc "avr" #:xgcc xgcc #:xbinutils (make-avr-binutils))))
59 (package
60 (inherit xgcc)
61 (name "avr-gcc")
62 (arguments
63 (substitute-keyword-arguments arguments
64 ((#:phases phases)
65 #~(modify-phases #$phases
66 (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
67 (lambda* (#:key inputs #:allow-other-keys)
68 (let ((gcc (assoc-ref inputs "gcc")))
69 ;; Remove the default compiler from CPLUS_INCLUDE_PATH
70 ;; to prevent header conflict with the GCC from
71 ;; native-inputs.
72 (setenv "CPLUS_INCLUDE_PATH"
73 (string-join
74 (delete (string-append gcc "/include/c++")
75 (string-split (getenv "CPLUS_INCLUDE_PATH")
76 #\:))
77 ":"))
78 (format #t
79 "environment variable `CPLUS_INCLUDE_PATH' \
80changed to ~a~%"
81 (getenv "CPLUS_INCLUDE_PATH")))))))))
82 (native-search-paths
83 (list (search-path-specification
84 (variable "CROSS_C_INCLUDE_PATH")
85 (files '("avr/include")))
86 (search-path-specification
87 (variable "CROSS_CPLUS_INCLUDE_PATH")
88 (files '("avr/include")))
89 (search-path-specification
90 (variable "CROSS_OBJC_INCLUDE_PATH")
91 (files '("avr/include")))
92 (search-path-specification
93 (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
94 (files '("avr/include")))
95 (search-path-specification
96 (variable "CROSS_LIBRARY_PATH")
97 (files '("avr/lib")))))
98 (native-inputs
99 `(("gcc" ,gcc)
100 ,@(package-native-inputs xgcc))))))
101
102(define make-avr-gcc
103 (memoize make-avr-gcc/implementation))
104
105(define* (make-avr-libc/implementation #:key
106 (xbinutils (cross-binutils "avr"))
107 (xgcc (cross-gcc "avr"
108 #:xbinutils xbinutils)))
109 (package
110 (name "avr-libc")
111 (version "2.0.0")
112 (source (origin
113 (method url-fetch)
114 (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
115 version ".tar.bz2"))
116 (sha256
117 (base32
118 "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
119 (build-system gnu-build-system)
120 (arguments
121 '(#:target "avr"
122 #:out-of-source? #t
123 ;; Avoid including itself as this package is a target input and cannot
124 ;; use the normal cross compilation inputs.
125 #:implicit-cross-inputs? #f))
126 (native-inputs `(("cross-binutils" ,xbinutils)
127 ("cross-gcc" ,xgcc)))
128 (home-page "https://www.nongnu.org/avr-libc/")
129 (synopsis "AVR C Library")
130 (description
131 "AVR Libc is a project whose goal is to provide a high quality C library
132for use with GCC on Atmel AVR microcontrollers.")
133 (license
134 (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt"))))
135
136(define make-avr-libc
137 (memoize make-avr-libc/implementation))
138
139(define* (make-avr-toolchain/implementation #:key (xgcc gcc))
140 (let ((avr-binutils (make-avr-binutils))
141 (avr-libc (make-avr-libc #:xgcc (cross-gcc "avr" #:xgcc xgcc)))
142 (avr-gcc (make-avr-gcc #:xgcc xgcc)))
143 ;; avr-libc checks the compiler version and passes "--enable-device-lib"
144 ;; for avr-gcc > 5.1.0. It wouldn't install the library for atmega32u4
145 ;; etc if we didn't use the corret avr-gcc.
146 (package
147 (name "avr-toolchain")
148 (version (package-version avr-gcc))
149 (source #f)
150 (build-system trivial-build-system)
151 (arguments '(#:builder (begin (mkdir %output) #t)))
152 (propagated-inputs
153 `(("avrdude" ,avrdude)
154 ("binutils" ,avr-binutils)
155 ("gcc" ,avr-gcc)
156 ("libc" ,avr-libc)))
157 (synopsis "Complete GCC tool chain for AVR microcontroller development")
158 (description "This package provides a complete GCC tool chain for AVR
159microcontroller development. This includes the GCC AVR cross compiler and
160avrdude for firmware flashing. The supported programming languages are C and
161C++.")
162 (home-page (package-home-page avr-libc))
163 (license (package-license avr-gcc)))))
164
165(define make-avr-toolchain
166 (memoize make-avr-toolchain/implementation))