summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCayetano Santos <csantosb@inventati.org>2024-10-11 21:30:41 +0200
committerCayetano Santos <csantosb@inventati.org>2024-10-11 21:30:41 +0200
commite5f3ea88b070c44467933e9281d1ce5c976cb273 (patch)
tree4000035f83c803823398501765fea8d3aaeba4af
parent3736b80cf569511cc0a13f87cb03411761290dd8 (diff)
gnu: Add gnat.
* guix-science/packages/electronics.scm (gnat): New variable.
-rw-r--r--guix-science/packages/electronics.scm125
1 files changed, 125 insertions, 0 deletions
diff --git a/guix-science/packages/electronics.scm b/guix-science/packages/electronics.scm
new file mode 100644
index 0000000..7f2e190
--- /dev/null
+++ b/guix-science/packages/electronics.scm
@@ -0,0 +1,125 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2024 Cayetano Santos <csantosb@inventati.org>
3;;;
4;;; This file is NOT part of GNU Guix, but is supposed to be used with GNU
5;;; Guix and thus has the same license.
6;;;
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.
11;;;
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.
16;;;
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/>.
19
20(define-module (guix-science packages electronics)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix gexp)
23 #:use-module (gnu packages elf)
24 #:use-module (gnu packages gcc)
25 #:use-module (gnu packages bootstrap)
26 #:use-module (gnu packages llvm)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu))
31
32(define-public gnat
33 (package
34 (name "gnat")
35 (version "14.2.0-1")
36 (source
37 (origin
38 (method url-fetch)
39 (uri (string-append "https://github.com/alire-project/GNAT-FSF-builds/"
40 "releases/download/gnat-14.2.0-1/gnat-x86_64-linux-" version
41 ".tar.gz"))
42 (sha256
43 (base32 "08kpd3d7si73gsm2dfp5lmrhii9k96y972sw39h1sdvhgzpkvfq6"))))
44 (build-system gnu-build-system)
45 (arguments
46 (list
47 ;; Let's not publish or obtain substitutes for that.
48 #:substitutable? #f
49 #:strip-binaries? #f
50 ;; XXX: This would check DT_RUNPATH, but patchelf populate DT_RPATH,
51 ;; not DT_RUNPATH.
52 #:validate-runpath? #f
53 #:phases #~(modify-phases %standard-phases
54 (replace 'unpack
55 (lambda* (#:key inputs #:allow-other-keys)
56 (let ((source (assoc-ref inputs "source")))
57 (invoke "tar" "xvzf" source)
58 (chdir "gnat-x86_64-linux-14.2.0-1"))))
59 (delete 'configure)
60 (delete 'check)
61 (replace 'build
62 (lambda* (#:key inputs #:allow-other-keys)
63 (define libc
64 (assoc-ref inputs "libc"))
65 (define gcc-lib
66 (assoc-ref inputs "gcc:lib"))
67 (define ld.so
68 (search-input-file inputs
69 #$(glibc-dynamic-linker)))
70 (define rpath
71 (string-join (list "$ORIGIN"
72 (string-append #$output "/lib")
73 (string-append #$output "/lib64")
74 (string-append libc "/lib")
75 (string-append gcc-lib "/lib"))
76 ":"))
77
78 ;; patchelf procedure
79 (define (patch-elf file)
80 (make-file-writable file)
81
82 (unless (string-contains file ".so")
83 (unless (string-contains file ".o")
84 (format #t "Setting RPATH on '~a'...~%" file)
85 (invoke "patchelf" "--set-rpath" rpath
86 "--force-rpath" file)))
87
88 (unless (string-contains file ".so")
89 (unless (string-contains file ".o")
90 (format #t "Setting interpreter on '~a'...~%"
91 file)
92 (invoke "patchelf" "--set-interpreter" ld.so file))))
93
94 ;; patch files
95 (for-each (lambda (file)
96 (when (elf-file? file)
97 (patch-elf file)))
98 (find-files "."
99 (lambda (file stat)
100 (eq? 'regular
101 (stat:type stat)))))))
102
103 (replace 'install
104 (lambda* _
105 (let ((bin (string-append #$output "/bin"))
106 (lib (string-append #$output "/lib"))
107 (lib64 (string-append #$output "/lib64"))
108 (libexec (string-append #$output "/libexec"))
109 (x86_64-pc-linux-gnu (string-append #$output
110 "/x86_64-pc-linux-gnu")))
111 (mkdir-p #$output)
112 (copy-recursively "bin" bin)
113 (copy-recursively "lib" lib)
114 (copy-recursively "lib64" lib64)
115 (copy-recursively "libexec" libexec)
116 (copy-recursively "x86_64-pc-linux-gnu"
117 x86_64-pc-linux-gnu)))))))
118 (native-inputs (list patchelf))
119 (inputs `(("gcc:lib" ,gcc-14 "lib")))
120 (home-page "https://github.com/alire-project/GNAT-FSF-builds")
121 (synopsis "Builds of the GNAT Ada compiler from Alire Project")
122 (description
123 "This package gathers GNAT binaries from FSF GCC releases of the Alire
124Project.")
125 (license (list license:expat)))) ; MIT license