Commit | Line | Data |
---|---|---|
fae995d3 DH |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2017 Kei Kebreau <address@hidden> | |
46daff38 | 3 | ;;; Copyright © 2020 Eric Bavier <bavier@posteo.net> |
fae995d3 DH |
4 | ;;; |
5 | ;;; This file is part of GNU Guix. | |
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 (gnu packages pascal) | |
21 | #:use-module ((guix licenses) #:prefix license:) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix download) | |
6d69886d | 24 | #:use-module (guix utils) |
fae995d3 DH |
25 | #:use-module (guix build-system gnu) |
26 | #:use-module (gnu packages) | |
27 | #:use-module (gnu packages base) | |
28 | #:use-module (gnu packages bootstrap) | |
29 | #:use-module (gnu packages commencement) | |
30 | #:use-module (gnu packages compression) | |
31 | #:use-module (gnu packages gcc) | |
32 | #:use-module (gnu packages ncurses) | |
6d69886d | 33 | #:use-module (gnu packages perl) |
fae995d3 DH |
34 | #:use-module (gnu packages xml) |
35 | #:use-module (ice-9 match)) | |
36 | ||
37 | (define fpc-bootstrap-i386-3.0.4 | |
38 | (origin | |
39 | (method url-fetch) | |
40 | (uri | |
41 | "mirror://sourceforge/freepascal/Linux/3.0.4/fpc-3.0.4.i386-linux.tar") | |
42 | (sha256 | |
43 | (base32 | |
44 | "05xfgxa6vb0y2ryfsgn21m2kwaxhci6l2zxa3akvlnqminjsjvda")))) | |
45 | ||
46 | (define fpc-bootstrap-x86_64-3.0.4 | |
47 | (origin | |
48 | (method url-fetch) | |
49 | (uri | |
50 | "mirror://sourceforge/freepascal/Linux/3.0.4/fpc-3.0.4.x86_64-linux.tar") | |
51 | (sha256 | |
52 | (base32 | |
53 | "0xzxh689iyjfmkqkhcqg9plrjmdx82hbyywyyc7jm0n92fpmp5ky")))) | |
54 | ||
55 | (define-public fpc | |
56 | (package | |
57 | (name "fpc") | |
46daff38 | 58 | (version "3.2.0") ; Update release date below! |
fae995d3 DH |
59 | (source (origin |
60 | (method url-fetch) | |
61 | (uri (string-append "mirror://sourceforge/freepascal/Source/" | |
62 | version "/fpcbuild-" version ".tar.gz")) | |
63 | (file-name (string-append name "-" version ".tar.gz")) | |
64 | (sha256 | |
65 | (base32 | |
66 | "0f38glyn3ffmqww432snhx2b8wyrq0yj1njkp4zh56lqrvm19fgr")) | |
67 | (patches (search-patches "fpc-reproducibility.patch")) | |
68 | (modules '((guix build utils))) | |
69 | (snippet | |
70 | '(begin | |
71 | (rename-file "install/doc" "install-doc") | |
72 | (rename-file "install/man" "install-man") | |
73 | ;; Contains executables--some of them created by | |
74 | ;; closed-source compilers. | |
75 | (delete-file-recursively "install") | |
76 | (mkdir-p "install") | |
77 | (rename-file "install-doc" "install/doc") | |
78 | (rename-file "install-man" "install/man") | |
79 | (delete-file "fpcsrc/tests/utils/dosbox/exitcode.exe") | |
80 | #t)))) | |
81 | (build-system gnu-build-system) | |
82 | (supported-systems '("i686-linux" "x86_64-linux")) | |
83 | (inputs | |
84 | `(("expat" ,expat) | |
85 | ("glibc" ,glibc) | |
86 | ("ld-wrapper" ,ld-wrapper) | |
87 | ("ncurses" ,ncurses) | |
88 | ("zlib" ,zlib))) | |
89 | (native-inputs | |
90 | ;; FPC is built with FPC, so we need bootstrap binaries. | |
91 | `(("fpc-binary" | |
92 | ,(match (or (%current-target-system) | |
93 | (%current-system)) | |
94 | ("i686-linux" fpc-bootstrap-i386-3.0.4) | |
95 | ;("powerpc64le-linux" fpc-bootstrap-ppc64le-3.0.4) | |
96 | ;("powerpc-linux" fpc-bootstrap-ppc-3.0.4) | |
97 | ("x86_64-linux" fpc-bootstrap-x86_64-3.0.4) | |
98 | (_ fpc-bootstrap-x86_64-3.0.4))))) | |
99 | (arguments | |
100 | `(#:tests? #f ; no tests available | |
101 | #:phases | |
102 | (let ((fpc-bootstrap-path | |
103 | (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin")) | |
104 | (arch ,(match (or (%current-target-system) | |
105 | (%current-system)) | |
106 | ("i686-linux" "i386") | |
107 | ("x86_64-linux" "x86_64") | |
108 | (_ "unknown")))) | |
109 | (modify-phases %standard-phases | |
110 | (add-after 'unpack 'unpack-bin | |
111 | (lambda* (#:key inputs #:allow-other-keys) | |
112 | (mkdir-p fpc-bootstrap-path) | |
113 | (with-directory-excursion fpc-bootstrap-path | |
114 | (invoke "tar" "xvf" (assoc-ref inputs "fpc-binary"))))) | |
115 | (add-after 'unpack-bin 'install-bin | |
116 | (lambda* (#:key inputs #:allow-other-keys) | |
117 | (with-directory-excursion | |
118 | (string-append fpc-bootstrap-path "/fpc-3.0.4." | |
119 | arch "-linux") | |
120 | (let ((binary-tarball | |
121 | (string-append "binary." arch "-linux.tar")) | |
122 | (compiler-tarball | |
123 | (string-append "base." arch "-linux.tar.gz")) | |
124 | (fpcmake-tarball | |
125 | (string-append "utils-fpcm." arch "-linux.tar.gz"))) | |
126 | ;; Only the base compiler and fpcmake are needed. | |
127 | (invoke "tar" "xvf" binary-tarball compiler-tarball | |
128 | fpcmake-tarball) | |
129 | (invoke "tar" "xvf" compiler-tarball "-C..") | |
130 | (invoke "tar" "xvf" fpcmake-tarball "-C.."))))) | |
131 | (add-after 'patch-source-shebangs 'patch-inline-shebangs | |
132 | (lambda _ | |
133 | (substitute* "fpcsrc/compiler/cscript.pas" | |
134 | (("#!/bin/sh") (string-append "#!" (which "sh")))) | |
135 | #t)) | |
46daff38 EB |
136 | (add-before 'build 'patch-release-date |
137 | (lambda _ ; reproducibility | |
138 | (substitute* (list "fpcdocs/prog.tex" | |
139 | "fpcsrc/packages/amunits/examples/sortdemo.pas" | |
140 | "fpcsrc/packages/libogcfpc/src/ogc/libversion.inc" | |
141 | "fpcsrc/utils/fpcres/fpcjres.pas" | |
142 | "fpcsrc/utils/fpcres/fpcres.pas" | |
143 | "fpcsrc/utils/fpcm/fpcmmain.pp" | |
144 | "fpcsrc/utils/fpcreslipo/fpcreslipo.pp" | |
145 | "fpcsrc/compiler/version.pas") | |
146 | (("\\{\\$I(NCLUDE)? %DATE%\\}") "'2020/06/19'")) | |
147 | #t)) | |
fae995d3 DH |
148 | (replace 'configure |
149 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
150 | (substitute* "fpcsrc/compiler/systems/t_linux.pas" | |
151 | ;; Point to the current glibc dynamic linker. | |
152 | (("/lib/ld-linux.so.2") | |
153 | (string-append (assoc-ref inputs "libc") | |
154 | ,(glibc-dynamic-linker))) | |
155 | (("/lib64/ld-linux-x86-64.so.2") | |
156 | (string-append (assoc-ref inputs "libc") | |
157 | ,(glibc-dynamic-linker))) | |
158 | ; TODO: /lib/ld-linux-armhf.so.3 | |
159 | ; TODO: /lib/ld-linux-aarch64.so.1 | |
160 | ; TODO: /lib64/ld64.so.2 | |
161 | ;; Add glibc to ld's search path. | |
162 | (("if \\(isdll\\) then") | |
163 | (string-append | |
164 | "Add('SEARCH_DIR(\"" | |
165 | (assoc-ref inputs "libc") "/lib" | |
166 | "\")');\n" | |
167 | "if (isdll) then"))) | |
168 | (substitute* "fpcsrc/compiler/options.pas" | |
169 | (("exepath\\+'../etc/'") | |
170 | (string-append "'" (assoc-ref outputs "out") "/etc'"))) | |
171 | #t)) | |
172 | (replace 'build | |
173 | (lambda* (#:key inputs #:allow-other-keys) | |
174 | (let* ((fpc-bin (string-append fpc-bootstrap-path "/bin")) | |
175 | (fpc (string-append fpc-bin "/fpc")) | |
176 | (fpcmake (string-append fpc-bin "/fpcmake"))) | |
177 | ;; The fpc binary needs to run the ppc[arch] binary (which | |
178 | ;; does the actual compiling) in this directory. | |
179 | (setenv "PATH" | |
180 | (string-append (getenv "PATH") ":" | |
181 | fpc-bootstrap-path | |
182 | "/lib/fpc/3.0.4")) | |
183 | (setenv "FPC" fpc) | |
184 | ;; Specify target operating system using "-T" option | |
185 | (invoke fpcmake (string-append "-T" arch "-linux")) | |
186 | (invoke "make" "build" "NOGDB=1")))) | |
187 | (replace 'install | |
188 | (lambda* (#:key outputs #:allow-other-keys) | |
189 | (let* ((out (assoc-ref outputs "out")) | |
190 | ;; This is the suffix of the ppc[arch] binary. | |
191 | (suffix (if (string= arch "x86_64") | |
192 | "x64" | |
193 | "386")) | |
194 | (ppc (string-append "ppc" suffix))) | |
195 | (invoke "make" "install" "NOGDB=1" | |
196 | (string-append "INSTALL_PREFIX=" out)) | |
197 | ;; Remove files that fail RUNPATH validation. | |
198 | ;; TODO: Fix it instead. | |
199 | (delete-file (string-append out "/lib/libpas2jslib.so")) | |
200 | ;; Add a symlink to the ppc[arch] binary so fpc works. | |
201 | (symlink (string-append out "/lib/fpc/" ,version "/" ppc) | |
202 | (string-append out "/bin/" ppc)) | |
203 | ;; Install the example configuration file. | |
204 | (mkdir (string-append out "/etc")) | |
205 | (invoke | |
206 | (string-append out "/lib/fpc/" ,version "/samplecfg") | |
207 | (string-append out "/lib/fpc/" ,version) | |
208 | (string-append out "/etc"))))) | |
209 | (add-after 'install 'wrap | |
210 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
211 | (let* ((out (assoc-ref outputs "out")) | |
212 | (fpc (string-append out "/bin/fpc")) | |
213 | (ld (assoc-ref inputs "ld-wrapper")) | |
214 | (glibc (assoc-ref inputs "glibc"))) | |
215 | (wrap-program fpc | |
216 | `("PATH" ":" prefix (,(string-append ld "/bin"))) | |
217 | `("LIBRARY_PATH" ":" prefix (,(string-append glibc "/lib")))) | |
218 | #t))))))) | |
219 | ;; fpc invokes gcc, so make sure LIBRARY_PATH et.al are set. | |
220 | ;(native-search-paths (package-native-search-paths gcc)) | |
ef7eaeed | 221 | (home-page "https://www.freepascal.org") |
fae995d3 DH |
222 | (synopsis "The Free Pascal Compiler") |
223 | (description | |
224 | "Free Pascal is a professional Object Pascal compiler. It supports the | |
225 | Turbo Pascal 7.0, Delphi, and Mac Pascal dialects. Free Pascal also supports | |
226 | many useful extensions to the Pascal programming language.") | |
227 | ;; The majority of the software included is licensed under the GPLv2 | |
228 | ;; or later. For more licensing details, see the appropriate files in | |
229 | ;; the install/doc directory of the source distribution. | |
230 | (license license:gpl2+))) | |
6d69886d DM |
231 | |
232 | (define-public p2c | |
233 | (package | |
234 | (name "p2c") | |
235 | (version "2.01") | |
236 | (source (origin | |
237 | (method url-fetch) | |
238 | (uri (string-append "https://alum.mit.edu/www/toms/p2c/p2c-" | |
239 | version ".tar.gz")) | |
240 | (sha256 | |
241 | (base32 | |
242 | "03x72lv6jrvikbrpz4kfq1xp61l2jw5ki6capib71lxs65zndajn")))) | |
243 | (build-system gnu-build-system) | |
244 | (arguments | |
245 | `(#:make-flags | |
246 | (let ((out (assoc-ref %outputs "out"))) | |
247 | (list (string-append "CC=" ,(cc-for-target)) | |
248 | (string-append "HOMEDIR=" out "/lib/p2c") | |
249 | (string-append "INCDIR=" out "/include/p2c") | |
250 | (string-append "BINDIR=" out "/bin") | |
251 | (string-append "LIBDIR=" out "/lib") | |
252 | (string-append "MANDIR=" out "/share/man/man1") | |
253 | "MANFILE=p2c.man.inst")) | |
254 | #:test-target "test" | |
255 | #:phases | |
256 | (modify-phases %standard-phases | |
257 | (delete 'configure) | |
258 | (add-before 'build 'mkdir | |
259 | (lambda* (#:key outputs #:allow-other-keys) | |
260 | (let ((out (assoc-ref outputs "out"))) | |
261 | (mkdir-p (string-append out "/share/man")) | |
262 | (mkdir-p (string-append out "/lib")) | |
263 | (mkdir-p (string-append out "/bin")) | |
264 | (mkdir-p (string-append out "/include"))) | |
265 | #t)) | |
266 | (add-before 'build 'chdir | |
267 | (lambda* (#:key make-flags #:allow-other-keys) | |
268 | (chdir "src") | |
269 | #t))))) | |
270 | (native-inputs | |
271 | `(("perl" ,perl) | |
272 | ("which" ,which))) | |
273 | (synopsis "p2c converts Pascal programs to C programs--which you can then | |
274 | compile using gcc") | |
275 | (description "This package provides @command{p2c}, a program to convert | |
276 | Pascal source code to C source code, and @command{p2cc}, a compiler for | |
277 | Pascal programs.") | |
278 | (home-page "http://users.fred.net/tds/lab/p2c/") | |
279 | (license license:gpl2+))) |