| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 |
|
| 24 | (define-module (gnu packages pascal)
|
| 25 | #:use-module ((guix licenses) #:prefix license:)
|
| 26 | #:use-module (guix packages)
|
| 27 | #:use-module (guix download)
|
| 28 | #:use-module (guix git-download)
|
| 29 | #:use-module (guix gexp)
|
| 30 | #:use-module (guix utils)
|
| 31 | #:use-module (guix build-system gnu)
|
| 32 | #:use-module (gnu packages)
|
| 33 | #:use-module (gnu packages base)
|
| 34 | #:use-module (gnu packages bootstrap)
|
| 35 | #:use-module (gnu packages compression)
|
| 36 | #:use-module (gnu packages gcc)
|
| 37 | #:use-module (gnu packages glib)
|
| 38 | #:use-module (gnu packages gtk)
|
| 39 | #:use-module (gnu packages ncurses)
|
| 40 | #:use-module (gnu packages perl)
|
| 41 | #:use-module (gnu packages pkg-config)
|
| 42 | #:use-module (gnu packages qt)
|
| 43 | #:use-module (gnu packages xml)
|
| 44 | #:use-module (gnu packages xorg)
|
| 45 | #:use-module (ice-9 match))
|
| 46 |
|
| 47 | (define %fpc-version "3.2.2")
|
| 48 | (define %fpc-release-date "2021/05/19")
|
| 49 |
|
| 50 | |
| 51 | (define fpc-bootstrap-aarch64
|
| 52 | (origin
|
| 53 | (method url-fetch)
|
| 54 | (uri (string-append "mirror://sourceforge/freepascal/Linux/"
|
| 55 | %fpc-version "/fpc-" %fpc-version ".aarch64-linux.tar"))
|
| 56 | (sha256
|
| 57 | (base32
|
| 58 | "0lalar6qk04acb2j8p6654hlz0yj6zdab046zi82zf5mnvwp155k"))))
|
| 59 |
|
| 60 | (define fpc-bootstrap-i386
|
| 61 | (origin
|
| 62 | (method url-fetch)
|
| 63 | (uri (string-append "mirror://sourceforge/freepascal/Linux/"
|
| 64 | %fpc-version "/fpc-" %fpc-version ".i386-linux.tar"))
|
| 65 | (sha256
|
| 66 | (base32
|
| 67 | "0n4r85dsr86zlk7r4hbd4nj14sda6rwgdgzxg4gj4q981fn80agn"))))
|
| 68 |
|
| 69 | (define fpc-bootstrap-powerpc
|
| 70 | (origin
|
| 71 | (method url-fetch)
|
| 72 | (uri (string-append "mirror://sourceforge/freepascal/Linux/"
|
| 73 | %fpc-version "/fpc-" %fpc-version ".powerpc-linux.tar"))
|
| 74 | (sha256
|
| 75 | (base32
|
| 76 | "1zhdypm99bzs5706g4nxwajiadv82jwd87cr300lrivy1rzj5h4a"))))
|
| 77 |
|
| 78 | (define fpc-bootstrap-powerpc64le
|
| 79 | (origin
|
| 80 | (method url-fetch)
|
| 81 | (uri (string-append "mirror://sourceforge/freepascal/Linux/"
|
| 82 | %fpc-version "/fpc-" %fpc-version ".powerpc64le-linux.tar"))
|
| 83 | (sha256
|
| 84 | (base32
|
| 85 | "12p3lmi1vn7agpw4pipp6ra8r85319sjcvbzh7z6kangmry7vic3"))))
|
| 86 |
|
| 87 | (define fpc-bootstrap-x86_64
|
| 88 | (origin
|
| 89 | (method url-fetch)
|
| 90 | (uri (string-append "mirror://sourceforge/freepascal/Linux/"
|
| 91 | %fpc-version "/fpc-" %fpc-version ".x86_64-linux.tar"))
|
| 92 | (sha256
|
| 93 | (base32
|
| 94 | "10qywczzz4qlcmmzxb7axnvwniq76ky130vd8iv6ljskll4c7njs"))))
|
| 95 |
|
| 96 | (define-public fpc
|
| 97 | (package
|
| 98 | (name "fpc")
|
| 99 | (version %fpc-version)
|
| 100 | (source (origin
|
| 101 | (method url-fetch)
|
| 102 | (uri (string-append "mirror://sourceforge/freepascal/Source/"
|
| 103 | version "/fpcbuild-" version ".tar.gz"))
|
| 104 | (file-name (string-append name "-" version ".tar.gz"))
|
| 105 | (sha256
|
| 106 | (base32
|
| 107 | "07qna2pvlpa7j0i2wdixjxpizdvffv51nbr1waczk0xv8cq9kvw5"))
|
| 108 | (patches (search-patches "fpc-reproducibility.patch"
|
| 109 | "fpc-glibc-2.34-compat.patch"))
|
| 110 | (modules '((guix build utils)))
|
| 111 | (snippet
|
| 112 | '(begin
|
| 113 | (rename-file "install/doc" "install-doc")
|
| 114 | (rename-file "install/man" "install-man")
|
| 115 | |
| 116 | |
| 117 | (delete-file-recursively "install")
|
| 118 | (mkdir-p "install")
|
| 119 | (rename-file "install-doc" "install/doc")
|
| 120 | (rename-file "install-man" "install/man")
|
| 121 | (delete-file "fpcsrc/tests/utils/dosbox/exitcode.exe")))))
|
| 122 | (build-system gnu-build-system)
|
| 123 | (supported-systems '("i686-linux" "x86_64-linux"
|
| 124 | "powerpc-linux" "powerpc64le-linux"
|
| 125 | "aarch64-linux"))
|
| 126 | (inputs
|
| 127 | (list expat glibc ncurses zlib))
|
| 128 | (native-inputs
|
| 129 | |
| 130 | `(("fpc-binary" ,(match (or (%current-target-system)
|
| 131 | (%current-system))
|
| 132 | ("aarch64-linux" fpc-bootstrap-aarch64)
|
| 133 | ("i686-linux" fpc-bootstrap-i386)
|
| 134 | ("powerpc-linux" fpc-bootstrap-powerpc)
|
| 135 | ("powerpc64le-linux" fpc-bootstrap-powerpc64le)
|
| 136 | ("x86_64-linux" fpc-bootstrap-x86_64)
|
| 137 | |
| 138 | |
| 139 | (_ fpc-bootstrap-x86_64)))))
|
| 140 | (arguments
|
| 141 | `(#:tests? #f |
| 142 | #:phases
|
| 143 | (let ((fpc-bootstrap-path
|
| 144 | (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin"))
|
| 145 | (arch ,(cond
|
| 146 | ((target-aarch64?) "aarch64")
|
| 147 | ((target-x86-32?) "i386")
|
| 148 | ((target-ppc32?) "powerpc")
|
| 149 | ((target-ppc64le?) "powerpc64")
|
| 150 | ((target-x86-64?) "x86_64")
|
| 151 | (else "unknown"))))
|
| 152 | (modify-phases %standard-phases
|
| 153 | (add-after 'unpack 'unpack-bin
|
| 154 | (lambda* (#:key inputs #:allow-other-keys)
|
| 155 | (mkdir-p fpc-bootstrap-path)
|
| 156 | (with-directory-excursion fpc-bootstrap-path
|
| 157 | (invoke "tar" "xvf" (assoc-ref inputs "fpc-binary")))))
|
| 158 | (add-after 'unpack-bin 'install-bin
|
| 159 | (lambda* (#:key inputs #:allow-other-keys)
|
| 160 | (with-directory-excursion
|
| 161 | (string-append fpc-bootstrap-path "/fpc-" ,version "."
|
| 162 | arch "-linux")
|
| 163 | (let ((binary-tarball
|
| 164 | (string-append "binary." arch "-linux.tar"))
|
| 165 | (compiler-tarball
|
| 166 | (string-append "base." arch "-linux.tar.gz"))
|
| 167 | (fpcmake-tarball
|
| 168 | (string-append "utils-fpcm." arch "-linux.tar.gz")))
|
| 169 | |
| 170 | (invoke "tar" "xvf" binary-tarball compiler-tarball
|
| 171 | fpcmake-tarball)
|
| 172 | (invoke "tar" "xvf" compiler-tarball "-C..")
|
| 173 | (invoke "tar" "xvf" fpcmake-tarball "-C..")))))
|
| 174 | (add-after 'patch-source-shebangs 'patch-inline-shebangs
|
| 175 | (lambda _
|
| 176 | (substitute* "fpcsrc/compiler/cscript.pas"
|
| 177 | (("#!/bin/sh") (string-append "#!" (which "sh"))))))
|
| 178 | (add-before 'build 'patch-release-date
|
| 179 | (lambda _ |
| 180 | (substitute* (list "fpcdocs/prog.tex"
|
| 181 | "fpcsrc/packages/amunits/examples/sortdemo.pas"
|
| 182 | "fpcsrc/packages/libogcfpc/src/ogc/libversion.inc"
|
| 183 | "fpcsrc/utils/fpcres/fpcjres.pas"
|
| 184 | "fpcsrc/utils/fpcres/fpcres.pas"
|
| 185 | "fpcsrc/utils/fpcm/fpcmmain.pp"
|
| 186 | "fpcsrc/utils/fpcreslipo/fpcreslipo.pp"
|
| 187 | "fpcsrc/compiler/version.pas")
|
| 188 | (("\\{\\$I(NCLUDE)? %DATE%\\}")
|
| 189 | (format #f "'~a'" ,%fpc-release-date)))))
|
| 190 | (replace 'configure
|
| 191 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 192 | (substitute* "fpcsrc/compiler/systems/t_linux.pas"
|
| 193 | |
| 194 | (("/lib/ld-linux.so.2")
|
| 195 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 196 | (("/lib64/ld-linux-x86-64.so.2")
|
| 197 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 198 | (("/lib/ld.so.1")
|
| 199 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 200 | (("/lib64/ld64.so.[12]")
|
| 201 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 202 | (("/lib/ld-linux(-armhf)?.so.3")
|
| 203 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 204 | (("/lib/ld-linux-aarch64.so.1")
|
| 205 | (search-input-file inputs ,(glibc-dynamic-linker)))
|
| 206 | |
| 207 | (("if \\(isdll\\) then")
|
| 208 | (string-append
|
| 209 | "Add('SEARCH_DIR(\""
|
| 210 | (assoc-ref inputs "libc") "/lib"
|
| 211 | "\")');\n"
|
| 212 | "if (isdll) then")))
|
| 213 | (substitute* "fpcsrc/compiler/options.pas"
|
| 214 | (("exepath\\+'../etc/'")
|
| 215 | (string-append "'" (assoc-ref outputs "out") "/etc'")))))
|
| 216 | (replace 'build
|
| 217 | (lambda* (#:key inputs #:allow-other-keys)
|
| 218 | (let* ((fpc-bin (string-append fpc-bootstrap-path "/bin"))
|
| 219 | (fpc (string-append fpc-bin "/fpc"))
|
| 220 | (fpcmake (string-append fpc-bin "/fpcmake")))
|
| 221 | |
| 222 | |
| 223 | (setenv "PATH"
|
| 224 | (string-append (getenv "PATH") ":"
|
| 225 | fpc-bootstrap-path
|
| 226 | "/lib/fpc/" ,version))
|
| 227 | (setenv "FPC" fpc)
|
| 228 | |
| 229 | (invoke fpcmake (string-append "-T" arch "-linux"))
|
| 230 | (invoke "make" "build" "NOGDB=1"))))
|
| 231 | (replace 'install
|
| 232 | (lambda* (#:key outputs #:allow-other-keys)
|
| 233 | (let* ((out (assoc-ref outputs "out"))
|
| 234 | |
| 235 | (suffix ,(cond
|
| 236 | ((target-aarch64?) "a64")
|
| 237 | ((target-x86-32?) "386")
|
| 238 | ((target-ppc32?) "ppc")
|
| 239 | ((target-ppc64le?) "ppc64")
|
| 240 | ((target-x86-64?) "x64")
|
| 241 | (else "")))
|
| 242 | (ppc (string-append "ppc" suffix)))
|
| 243 | (invoke "make" "install" "NOGDB=1"
|
| 244 | (string-append "INSTALL_PREFIX=" out))
|
| 245 | |
| 246 | |
| 247 | (delete-file (string-append out "/lib/libpas2jslib.so"))
|
| 248 | |
| 249 | (symlink (string-append out "/lib/fpc/" ,version "/" ppc)
|
| 250 | (string-append out "/bin/" ppc))
|
| 251 | |
| 252 | (mkdir (string-append out "/etc"))
|
| 253 | (invoke
|
| 254 | (string-append out "/lib/fpc/" ,version "/samplecfg")
|
| 255 | (string-append out "/lib/fpc/" ,version)
|
| 256 | (string-append out "/etc")))))
|
| 257 | (add-after 'install 'wrap
|
| 258 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 259 | (let* ((out (assoc-ref outputs "out"))
|
| 260 | (fpc (string-append out "/bin/fpc"))
|
| 261 | (ld (assoc-ref inputs "ld-wrapper"))
|
| 262 | (glibc (assoc-ref inputs "glibc")))
|
| 263 | (wrap-program fpc
|
| 264 | `("PATH" ":" prefix (,(string-append ld "/bin")))
|
| 265 | `("LIBRARY_PATH" ":" prefix
|
| 266 | (,(string-append glibc "/lib")))))))))))
|
| 267 | |
| 268 | |
| 269 | (home-page "https://www.freepascal.org")
|
| 270 | (synopsis "The Free Pascal Compiler")
|
| 271 | (description
|
| 272 | "Free Pascal is a professional Object Pascal compiler. It supports the
|
| 273 | Turbo Pascal 7.0, Delphi, and Mac Pascal dialects. Free Pascal also supports
|
| 274 | many useful extensions to the Pascal programming language.")
|
| 275 | |
| 276 | |
| 277 | |
| 278 | (license license:gpl2+)))
|
| 279 |
|
| 280 | (define-public p2c
|
| 281 | (package
|
| 282 | (name "p2c")
|
| 283 | (version "2.02")
|
| 284 | (source (origin
|
| 285 | (method url-fetch)
|
| 286 | (uri (string-append "http://users.fred.net/tds/lab/p2c/p2c-"
|
| 287 | version ".zip"))
|
| 288 | (sha256
|
| 289 | (base32
|
| 290 | "17q6s0vbz298pks80bxf4r6gm8kwbrml1q3vfs6g6yj75sqj58xs"))))
|
| 291 | (build-system gnu-build-system)
|
| 292 | (arguments
|
| 293 | (list
|
| 294 | #:make-flags
|
| 295 | #~(list (string-append "CC=" #$(cc-for-target))
|
| 296 | "CFLAGS=-Wno-implicit-function-declaration"
|
| 297 | (string-append "HOMEDIR=" #$output "/lib/p2c")
|
| 298 | (string-append "INCDIR=" #$output "/include/p2c")
|
| 299 | (string-append "BINDIR=" #$output "/bin")
|
| 300 | (string-append "LIBDIR=" #$output "/lib")
|
| 301 | (string-append "MANDIR=" #$output "/share/man/man1")
|
| 302 | "MANFILE=p2c.man.inst")
|
| 303 | #:test-target "test"
|
| 304 | #:phases
|
| 305 | #~(modify-phases %standard-phases
|
| 306 | (delete 'configure)
|
| 307 | (add-before 'build 'mkdir
|
| 308 | (lambda _
|
| 309 | (mkdir-p (string-append #$output "/share/man"))
|
| 310 | (mkdir-p (string-append #$output "/lib"))
|
| 311 | (mkdir-p (string-append #$output "/bin"))
|
| 312 | (mkdir-p (string-append #$output "/include"))))
|
| 313 | (add-before 'build 'chdir
|
| 314 | (lambda _ (chdir "src"))))))
|
| 315 | (native-inputs
|
| 316 | (list perl unzip which))
|
| 317 | (synopsis "Convert Pascal programs to C programs")
|
| 318 | (description "This package provides @command{p2c}, a program to convert
|
| 319 | Pascal source code to C source code, and @command{p2cc}, a compiler for
|
| 320 | Pascal programs.")
|
| 321 | (home-page "http://users.fred.net/tds/lab/p2c/")
|
| 322 | (license license:gpl2+)))
|
| 323 |
|
| 324 | (define-public lazarus
|
| 325 | (package
|
| 326 | (name "lazarus")
|
| 327 | (version "4.6")
|
| 328 | (source (origin
|
| 329 | (method git-fetch)
|
| 330 | (uri (git-reference
|
| 331 | (url
|
| 332 | "https://gitlab.com/freepascal.org/lazarus/lazarus.git")
|
| 333 | (commit (string-append "lazarus_"
|
| 334 | (string-join (string-split version
|
| 335 | #\.)
|
| 336 | "_")))))
|
| 337 | (file-name (string-append name "-" version "-checkout"))
|
| 338 | (sha256
|
| 339 | (base32
|
| 340 | "1mkimvd5hiwlsxpjwqnhd7lwb0x2icnf9ks09wza7j5xaq7xjswy"))))
|
| 341 | (build-system gnu-build-system)
|
| 342 | (arguments
|
| 343 | (list #:tests? #f |
| 344 | #:make-flags #~(list (string-append "INSTALL_PREFIX="
|
| 345 | #$output)
|
| 346 | "LCL_PLATFORM=qt6")
|
| 347 | #:phases
|
| 348 | #~(modify-phases %standard-phases
|
| 349 | (delete 'configure)
|
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | (add-before 'build 'build-qt6pas
|
| 355 | (lambda _
|
| 356 | (with-directory-excursion "lcl/interfaces/qt6/cbindings"
|
| 357 | (invoke "qmake6" "Qt6Pas.pro"
|
| 358 | (string-append "PREFIX=" #$output))
|
| 359 | (invoke "make" "-j"
|
| 360 | (number->string (parallel-job-count))))))
|
| 361 | (replace 'build
|
| 362 | (lambda* (#:key inputs make-flags #:allow-other-keys)
|
| 363 | (let* ((qt6pas-build
|
| 364 | (string-append (getcwd)
|
| 365 | "/lcl/interfaces/qt6/cbindings"))
|
| 366 | (qt6pas-runtime
|
| 367 | (string-append #$output "/lib"))
|
| 368 | (input-libs
|
| 369 | (map (lambda (x)
|
| 370 | (string-append (assoc-ref inputs x) "/lib"))
|
| 371 | '("qtbase" "libx11")))
|
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | (fpc-args
|
| 377 | (append (map (lambda (d)
|
| 378 | (string-append "-Fl" d))
|
| 379 | (cons qt6pas-build input-libs))
|
| 380 | (map (lambda (d)
|
| 381 | (string-append "-k-rpath=" d))
|
| 382 | (cons qt6pas-runtime input-libs)))))
|
| 383 | (setenv "LAZARUS_LIBPATHS"
|
| 384 | (string-join fpc-args " "))
|
| 385 | (setenv "MAKEFLAGS"
|
| 386 | (string-append "LHELP_OPT="
|
| 387 | (string-join fpc-args "\\ "))))
|
| 388 | (apply invoke "make" "bigide" make-flags)))
|
| 389 | (add-after 'install 'wrap-qt
|
| 390 | (lambda* (#:key inputs #:allow-other-keys)
|
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | (let ((plugin-path
|
| 397 | (string-join
|
| 398 | (map (lambda (i)
|
| 399 | (string-append (assoc-ref inputs i)
|
| 400 | "/lib/qt6/plugins"))
|
| 401 | '("qtbase" "qtsvg" "qtwayland"))
|
| 402 | ":")))
|
| 403 | (for-each
|
| 404 | (lambda (prog)
|
| 405 | (wrap-program (string-append #$output "/bin/" prog)
|
| 406 | `("QT_PLUGIN_PATH" ":" prefix (,plugin-path))))
|
| 407 | '("lazarus-ide" "startlazarus")))))
|
| 408 | (add-after 'install 'install-qt6pas
|
| 409 | (lambda _
|
| 410 | |
| 411 | |
| 412 | |
| 413 | (let ((src "lcl/interfaces/qt6/cbindings")
|
| 414 | (dst (string-append #$output "/lib")))
|
| 415 | (mkdir-p dst)
|
| 416 | (for-each
|
| 417 | (lambda (f)
|
| 418 | (let ((sf (string-append src "/" f))
|
| 419 | (df (string-append dst "/" f)))
|
| 420 | (if (eq? 'symlink (stat:type (lstat sf)))
|
| 421 | (symlink (readlink sf) df)
|
| 422 | (copy-file sf df))))
|
| 423 | '("libQt6Pas.so"
|
| 424 | "libQt6Pas.so.6"
|
| 425 | "libQt6Pas.so.6.2"
|
| 426 | "libQt6Pas.so.6.2.10"))))))))
|
| 427 | (native-inputs (list fpc pkg-config qtbase qttools))
|
| 428 | (inputs (list qtbase qtsvg qtwayland libx11))
|
| 429 | (synopsis "Integrated development environment for Pascal")
|
| 430 | (description "This package provides an integrated development environment
|
| 431 | for Pascal.")
|
| 432 | (home-page "https://www.lazarus-ide.org/")
|
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | (license (list license:gpl2+ license:lgpl2.0+))))
|