1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Theodoros Foradis <theodoros.for@openmailbox.org>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages embedded)
21 #:use-module (guix utils)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix svn-download)
25 #:use-module (guix git-download)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages cross-base)
30 #:use-module (gnu packages flex)
31 #:use-module (gnu packages gcc)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages texinfo))
35 ;; We must not use the released GCC sources here, because the cross-compiler
36 ;; does not produce working binaries. Instead we take the very same SVN
37 ;; revision from the branch that is used for a release of the "GCC ARM
38 ;; embedded" project on launchpad.
39 ;; See https://launchpadlibrarian.net/218827644/release.txt
40 (define-public gcc-arm-none-eabi-4.9
41 (let ((xgcc (cross-gcc "arm-none-eabi"
42 (cross-binutils "arm-none-eabi")))
44 (svn-revision 227977))
45 (package (inherit xgcc)
46 (version (string-append (package-version xgcc) "-"
47 revision "." (number->string svn-revision)))
52 (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/")
53 (revision svn-revision)))
54 (file-name (string-append "gcc-arm-embedded-" version "-checkout"))
57 "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr"))
58 (patches (origin-patches (package-source xgcc)))))
61 ,@(package-native-inputs xgcc)))
63 (substitute-keyword-arguments (package-arguments xgcc)
65 `(modify-phases ,phases
66 (add-after 'unpack 'fix-genmultilib
68 (substitute* "gcc/genmultilib"
69 (("#!/bin/sh") (string-append "#!" (which "sh"))))
71 ((#:configure-flags flags)
72 ;; The configure flags are largely identical to the flags used by the
73 ;; "GCC ARM embedded" project.
74 `(append (list "--enable-multilib"
76 "--with-multilib-list=armv6-m,armv7-m,armv7e-m"
77 "--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm"
79 "--disable-decimal-float"
82 "--disable-libmudflap"
83 "--disable-libquadmath"
85 "--disable-libstdcxx-pch"
90 (delete "--disable-multilib" ,flags)))))
92 (list (search-path-specification
93 (variable "CROSS_C_INCLUDE_PATH")
94 (files '("arm-none-eabi/include")))
95 (search-path-specification
96 (variable "CROSS_CPLUS_INCLUDE_PATH")
97 (files '("arm-none-eabi/include")))
98 (search-path-specification
99 (variable "CROSS_LIBRARY_PATH")
100 (files '("arm-none-eabi/lib"))))))))
102 (define-public gcc-arm-none-eabi-6
104 (inherit gcc-arm-none-eabi-4.9)
105 (version (package-version gcc-6))
106 (source (origin (inherit (package-source gcc-6))
109 (origin-patches (package-source gcc-6))
110 (search-patches "gcc-6-cross-environment-variables.patch"
111 "gcc-6-arm-none-eabi-multilib.patch")))))))
113 (define-public newlib-arm-none-eabi
119 (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
123 "01i7qllwicf05vsvh39qj7qp5fdifpvvky0x95hjq39mbqiksnsl"))))
124 (build-system gnu-build-system)
126 `(#:out-of-source? #t
127 ;; The configure flags are identical to the flags used by the "GCC ARM
128 ;; embedded" project.
129 #:configure-flags '("--target=arm-none-eabi"
130 "--enable-newlib-io-long-long"
131 "--enable-newlib-register-fini"
132 "--disable-newlib-supplied-syscalls"
135 (modify-phases %standard-phases
136 (add-after 'unpack 'fix-references-to-/bin/sh
138 (substitute* '("libgloss/arm/cpu-init/Makefile.in"
139 "libgloss/arm/Makefile.in"
140 "libgloss/libnosys/Makefile.in"
141 "libgloss/Makefile.in")
142 (("/bin/sh") (which "sh")))
145 `(("xbinutils" ,(cross-binutils "arm-none-eabi"))
146 ("xgcc" ,gcc-arm-none-eabi-4.9)
147 ("texinfo" ,texinfo)))
148 (home-page "http://www.sourceware.org/newlib/")
149 (synopsis "C library for use on embedded systems")
150 (description "Newlib is a C library intended for use on embedded
151 systems. It is a conglomeration of several library parts that are easily
152 usable on embedded products.")
153 (license (license:non-copyleft
154 "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
156 (define-public newlib-nano-arm-none-eabi
157 (package (inherit newlib-arm-none-eabi)
160 (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi)
161 ;; The configure flags are identical to the flags used by the "GCC ARM
162 ;; embedded" project. They optimize newlib for use on small embedded
163 ;; systems with limited memory.
164 ((#:configure-flags flags)
165 ''("--target=arm-none-eabi"
167 "--disable-newlib-supplied-syscalls"
168 "--enable-newlib-reent-small"
169 "--disable-newlib-fvwrite-in-streamio"
170 "--disable-newlib-fseek-optimization"
171 "--disable-newlib-wide-orient"
172 "--enable-newlib-nano-malloc"
173 "--disable-newlib-unbuf-stream-opt"
175 "--enable-newlib-global-atexit"
176 "--enable-newlib-nano-formatted-io"
178 (synopsis "Newlib variant for small systems with limited memory")))