Subject: Re: [bug#62424] [PATCH] gnu: Add lazarus.

From: "(" <[email-masked]>
Date: Wed, 29 Mar 2023 20:26:00 +0100

Heya,

Adding on to what Maxim said:

On Thu Mar 23, 2023 at 10:16 AM GMT,  wrote:
> +    (arguments
> +     `(#:tests? #f ; No tests exist
> +       #:phases
> +       (modify-phases %standard-phases
> +        (delete 'configure)
> +        (replace 'build
> +          (lambda* (#:key inputs outputs #:allow-other-keys)
> +            ;; RUNPATH -k-rpath=
> +            ;; -Xr<x> rlink-path
> +            (let* ((libdirs
> +                    (map (lambda (x)
> +                           (assoc-ref inputs x))
> +                         '("glib" "gdk-pixbuf" "gtk+" "libx11"
> +                           "libx11" "pango" "cairo" "atk")))
> +                   (libs (append
> +                          (map (lambda (name)
> +                                 (string-append "-Fl" name "/lib"))
> +                               libdirs)
> +                          (map (lambda (name)
> +                                 (string-append "-k-rpath=" name "/lib"))
> +                               libdirs))))
> +              (setenv "LAZARUS_LIBPATHS"
> +                      (string-append ;"-XD "
> +                                     (string-join libs " ")))
> +              (setenv "MAKEFLAGS"
> +                      (string-append "LHELP_OPT="
> +                                     (string-join libs "\\ "))))
> +            (setenv "INSTALL_PREFIX" (assoc-ref outputs "out"))
> +            (invoke "make" "bigide"))))))

Please make sure you use the new-ish LIST/GEXP style for ARGUMENTS; also, much
of your modified BUILD phase could be replaced by modifying #:MAKE-FLAGS, and
LIBS could be generated in a much simpler way with FOLD from (SRFI SRFI-1):

---
> +    (arguments
> +     (list #:tests? #f ;no tests
> +           #:make-flags
> +           #~(begin
> +               (use-modules (srfi srfi-1))
> +               (let* ((lib-dirs
> +                       (list #$@(map this-package-input
> +                                     '("glib" "gdk-pixbuf" "gtk+"
> +                                       "libx11" "pango" "cairo" "atk"))))
> +                      (lib-flags
> +                       (fold (lambda (pkg flags)
> +                               (cons* (string-append "-Fl" pkg "/lib")
> +                                      (string-append "-k-rpath=" pkg "/lib")
> +                                      flags))
> +                             lib-dirs)))
> +                 (list (string-append "LAZARUS_LIBPATHS="
> +                                      (string-join lib-flags))
> +                       (string-append "LHELP_OPT="
> +                                      (string-join lib-flags "\\ "))
> +                       (string-append "INSTALL_PREFIX=" #$output))))
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (delete 'configure)
> +               (replace 'build
> +                 (lambda _
> +                   (invoke "make" "bigide"))))))
---

Note that I have not tested that this modification actually works, but I'd be
surprised if it didn't.

    -- (