Paste number 337262: Free Pascal Compiler for Guix

Paste number 337262: Free Pascal Compiler for Guix
Pasted by: kei
When:5 years, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+788E
Channel:None
Paste contents:
Raw Source | XML | Display As
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Kei Kebreau <kei@openmailbox.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages pascal)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages xml))

(define fpc-bootstrap-x86_64-3.0.0
  (origin
    (method url-fetch)
    (uri
     "mirror://sourceforge/freepascal/Linux/3.0.0/fpc-3.0.0.x86_64-linux.tar")
    (sha256
     (base32
      "1m2xx3nda45cb3zidbjgdr8kddd19zk0khvp7xxdlclszkqscln9"))))

(define fpc-bootstrap-i386-3.0.0
  (origin
    (method url-fetch)
    (uri
     "mirror://sourceforge/freepascal/Linux/3.0.0/fpc-3.0.0.i386-linux.tar")
    (sha256
     (base32
      "0h3f1dgs1zsx7vvk9kg67anjvgw5sslfbmjblif7ishbcp3k3g5k"))))

(define-public fpc
  (let ((arch (if (string-prefix? "x86_64" (or (%current-target-system)
                                               (%current-system)))
                  "x86_64"
                  "i386")))
    (package
      (name "fpc")
      (version "3.0.0")
      (source (origin
                (method url-fetch)
                (uri (string-append "mirror://sourceforge/freepascal/Source/"
                                    version "fpcbuild-" version ".tar.gz"))
                (sha256
                 (base32
                  "1v40bjp0kvsi8y0mndqvvhnsqjfssl2w6wpfww51j4rxblfkp4fm"))))
      (build-system gnu-build-system)
      (supported-systems '("i686-linux" "x86_64-linux"))
      (inputs
       `(("expat" ,expat)
         ("glibc" ,glibc)
         ("ncurses" ,ncurses)
         ("zlib" ,zlib)))
      (native-inputs
       ;; FPC is built with FPC, so we need bootstrap binaries.
       `(("fpc-binary"
          ,(if (string= arch "x86_64")
               fpc-bootstrap-x86_64-3.0.0
               fpc-bootstrap-i386-3.0.0))))
      (arguments
       `(#:tests? #f ; no tests available
         #:phases
         (let ((fpc-bootstrap-path
                (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin")))
           (modify-phases %standard-phases
             (add-after 'unpack 'unpack-bin
               (lambda* (#:key inputs #:allow-other-keys)
                 (mkdir-p fpc-bootstrap-path)
                 (with-directory-excursion fpc-bootstrap-path
                   (copy-file (assoc-ref inputs "fpc-binary")
                              "fpc-bin.tar")
                   (zero? (system* "tar" "xvf" "fpc-bin.tar")))))
             (add-after 'unpack-bin 'install-bin
               (lambda* (#:key inputs #:allow-other-keys)
                 (with-directory-excursion
                     (string-append fpc-bootstrap-path "/fpc-3.0.0."
                                    ,arch "-linux")
                   (let ((binary-tarball
                          (string-append "binary." ,arch "-linux.tar"))
                         (compiler-tarball
                          (string-append "base." ,arch "-linux.tar.gz"))
                         (fpcmake-tarball
                          (string-append "utils-fpcm." ,arch "-linux.tar.gz")))
                     (and
                      ;; Only the base compiler, fpcmake, and runtime library
                      ;; are needed.
                      (zero? (system* "tar" "xvf" binary-tarball
                                      compiler-tarball
                                      fpcmake-tarball))
                      (zero? (system* "tar" "xvf" compiler-tarball "-C.."))
                      (zero? (system* "tar" "xvf" fpcmake-tarball "-C..")))))))
             (delete 'configure)
             (replace 'build
               (lambda _
                 (let* ((fpc-bin (string-append fpc-bootstrap-path "/bin"))
                        (fpc (string-append fpc-bin "/fpc"))
                        (fpcmake (string-append fpc-bin "/fpcmake")))
                   ;; The fpc binary needs to run the ppc[arch] binary (which
                   ;; does the actual compiling) in this directory.
                   (setenv "PATH"
                          (string-append (getenv "PATH") ":"
                                         fpc-bootstrap-path
                                         "/lib/fpc/" ,version))
                   (and
                    ;; -T[target operating system]
                    (zero? (system* fpcmake
                                    (string-append "-T" ,arch "-linux")))
                    (zero? (system* "make" "build" "NOGDB=1"
                                    (string-append "FPC=" fpc)))))))))))
      (home-page "http://www.freepascal.org")
      (synopsis "The Free Pascal Compiler")
      (description
       "Free Pascal is a professional Object Pascal compiler.  It supports the
Turbo Pascal 7.0, Delphi, and Mac Pascal dialects.  Free Pascal also supports
many useful extensions to the Pascal programming language.")
      ;; The majority of the software included is licensed under the GPLv2
      ;; or later.  For more licensing details, see the appropriate files in
      ;; the install/doc directory of the source distribution.
      (license license:gpl2+))))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.