| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 |
|
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 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 | |
| 70 | |
| 71 | |
| 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' \
|
| 80 | changed 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 | |
| 124 | |
| 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
|
| 132 | for 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 | |
| 144 | |
| 145 | |
| 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
|
| 159 | microcontroller development. This includes the GCC AVR cross compiler and
|
| 160 | avrdude for firmware flashing. The supported programming languages are C and
|
| 161 | C++.")
|
| 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))
|