diff mbox series

[bug#56504] Mingw support for zlib

Message ID d9ac8a144f4a442d4f9d0d6d996dd8962b0c3a8a.camel@planete-kraus.eu
State Accepted
Headers show
Series [bug#56504] Mingw support for zlib | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Vivien Kraus July 13, 2022, 3:19 p.m. UTC
Le mercredi 13 juillet 2022 à 07:49 +0200, Liliana Marie Prikler a
écrit :
> Am Dienstag, dem 12.07.2022 um 18:45 +0200 schrieb Vivien Kraus:
> > Le mardi 12 juillet 2022 à 08:07 +0200, Liliana Marie Prikler a
> > écrit :
> > > Am Dienstag, dem 12.07.2022 um 01:53 +0200 schrieb Vivien Kraus:
> > > > +                     `((substitute* "win32/Makefile.gcc"
> > > > +                         (("PREFIX =")
> > > > +                          (string-append "PREFIX = "
> > > > ,(%current-
> > > > target-system) "-"))
> > > > +                         (("prefix \\?= /usr/local")
> > > > +                          (string-append "prefix ?= " out))
> > > > +                         (("# BINARY_PATH, INCLUDE_PATH and
> > > > LIBRARY_PATH must be set.")
> > > > +                          "\
> > > > +BINARY_PATH = $(prefix)/bin
> > > > +INCLUDE_PATH = $(prefix)/include
> > > > +LIBRARY_PATH = $(prefix)/lib"))
> > > > +                       (rename-file "win32/Makefile.gcc"
> > > > "Makefile"))
> > > I think these can be conditionally added to #:make-flags
> > I did it for all but prefix, because I have to have the output
> > path.
> > Is there a way to get it from within the make-flags?
> With the gexp-style you'd write #$output, otherwise ,(assoc-ref
> %build-
> outputs "out").
Looking at the "-builder" scheme file that is generated for the
derivation, it looks like what I want is simply %outputs, not %build-
outputs.

> 
> > > > +                     `((invoke "./configure"
> > > > +                               (string-append "--prefix="
> > > > out)))))))
> > > 
> > > > +         ,@(if (and (%current-target-system)
> > > > +                    (string-suffix? "-mingw32" (%current-
> > > > target-
> > > > system)))
> > > > +               `(add-after 'install 'install-mingw-shared
> > > > +                  (lambda* (#:key make-flags #:allow-other-
> > > > keys)
> > > > +                    (apply invoke "make"
> > > > +                           (append make-flags
> > > > +                                   '("install"
> > > > "SHARED_MODE=1")))))
> > > SHARED_MODE might likewise be conditionally added to #:make-
> > > flags.
> > I get both the DLL loader and the DLL in the default output, and
> > the
> > static lib in the static output, so it works.
> Oh, so you mean the static output should be built without
> SHARED_MODE?
No, SHARED_MODE=1 means "please also install the DLL" and SHARED_MODE=0
means "please do not install the DLL". Reading the win32/Makefile.gcc,
nothing special is done if SHARED_MODE=0. It is only used in the
install and uninstall targets. I don’t really understand why you would
want to set SHARED_MODE=0 (even weirder to set it as a default) but I
guess it happens.

Comments

Liliana Marie Prikler July 14, 2022, 6:01 a.m. UTC | #1
Am Mittwoch, dem 13.07.2022 um 17:19 +0200 schrieb Vivien Kraus:
> [...]
> Looking at the "-builder" scheme file that is generated for the
> derivation, it looks like what I want is simply %outputs, not %build-
> outputs.
Yeah, my bad, it's %build-inputs and %outputs respectively.

> 
> > Oh, so you mean the static output should be built without
> > SHARED_MODE?
> No, SHARED_MODE=1 means "please also install the DLL" and
> SHARED_MODE=0 means "please do not install the DLL". Reading the
> win32/Makefile.gcc, nothing special is done if SHARED_MODE=0. 
In that case we could set it via #:make-flags, right?

> It is only used in the install and uninstall targets. I don’t really
> understand why you would want to set SHARED_MODE=0 (even weirder to
> set it as a default) but I guess it happens.
Perhaps the rationale is that users might not actually want the shared
libraries for some bespoke reasons (not that those reasons would apply
to Guix users).

Cheers
Vivien Kraus July 15, 2022, 2:28 p.m. UTC | #2
Le jeudi 14 juillet 2022 à 08:01 +0200, Liliana Marie Prikler a écrit :
> > > Oh, so you mean the static output should be built without
> > > SHARED_MODE?
> > No, SHARED_MODE=1 means "please also install the DLL" and
> > SHARED_MODE=0 means "please do not install the DLL". Reading the
> > win32/Makefile.gcc, nothing special is done if SHARED_MODE=0. 
> In that case we could set it via #:make-flags, right?
I’m not sure I understand. I think that’s what I did, and obviously it
works since the dll is installed in the default output. Could you
explain a bit more the phrase "we could set it"?

Vivien
Liliana Marie Prikler July 15, 2022, 2:30 p.m. UTC | #3
Am Freitag, dem 15.07.2022 um 16:28 +0200 schrieb Vivien Kraus:
> Le jeudi 14 juillet 2022 à 08:01 +0200, Liliana Marie Prikler a
> écrit :
> > > > Oh, so you mean the static output should be built without
> > > > SHARED_MODE?
> > > No, SHARED_MODE=1 means "please also install the DLL" and
> > > SHARED_MODE=0 means "please do not install the DLL". Reading the
> > > win32/Makefile.gcc, nothing special is done if SHARED_MODE=0. 
> > In that case we could set it via #:make-flags, right?
> I’m not sure I understand. I think that’s what I did, and obviously
> it
> works since the dll is installed in the default output. Could you
> explain a bit more the phrase "we could set it"?
> 
> Vivien
My bad; I didn't notice the attachments.  LGTM
Ludovic Courtès July 19, 2022, 9:07 p.m. UTC | #4
Hey Liliana,

Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> skribis:

> Am Freitag, dem 15.07.2022 um 16:28 +0200 schrieb Vivien Kraus:
>> Le jeudi 14 juillet 2022 à 08:01 +0200, Liliana Marie Prikler a
>> écrit :
>> > > > Oh, so you mean the static output should be built without
>> > > > SHARED_MODE?
>> > > No, SHARED_MODE=1 means "please also install the DLL" and
>> > > SHARED_MODE=0 means "please do not install the DLL". Reading the
>> > > win32/Makefile.gcc, nothing special is done if SHARED_MODE=0. 
>> > In that case we could set it via #:make-flags, right?
>> I’m not sure I understand. I think that’s what I did, and obviously
>> it
>> works since the dll is installed in the default output. Could you
>> explain a bit more the phrase "we could set it"?
>> 
>> Vivien
> My bad; I didn't notice the attachments.  LGTM

Please do apply what LGTY, thanks!

Ludo’.
Liliana Marie Prikler July 31, 2022, 11:21 a.m. UTC | #5
Am Dienstag, dem 19.07.2022 um 23:07 +0200 schrieb Ludovic Courtès:
> Please do apply what LGTY, thanks!
Pardon the delays, zlib for mingw is pushed now.
diff mbox series

Patch

From 6991416907cb2b3e8be639c18cecb6bf519da904 Mon Sep 17 00:00:00 2001
From: Vivien Kraus <vivien@planete-kraus.eu>
Date: Sat, 25 Jun 2022 16:33:44 +0200
Subject: [PATCH v3] gnu: zlib: Support mingw cross-compilation.

* gnu/packages/compression.scm (zlib): Only run configure if not mingw.
---
 gnu/packages/compression.scm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index d5bd3abf0f..871f90656c 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -113,7 +113,16 @@  (define-public zlib
     (build-system gnu-build-system)
     (outputs '("out" "static"))
     (arguments
-     `(#:phases
+     `(#:make-flags
+       ,(if (target-mingw?)
+            `(list ,(string-append "PREFIX=" (%current-target-system) "-")
+                   "BINARY_PATH = $(prefix)/bin"
+                   "INCLUDE_PATH = $(prefix)/include"
+                   "LIBRARY_PATH = $(prefix)/lib"
+                   "SHARED_MODE = 1"
+                   (string-append "prefix = " (assoc-ref %outputs "out")))
+            ''())
+       #:phases
        (modify-phases %standard-phases
          (replace 'configure
            (lambda* (#:key outputs #:allow-other-keys)
@@ -125,8 +134,10 @@  (define-public zlib
                ,@(if (%current-target-system)
                      `((setenv "CHOST" ,(%current-target-system)))
                      '())
-               (invoke "./configure"
-                       (string-append "--prefix=" out)))))
+               ,@(if (target-mingw?)
+                     `((rename-file "win32/Makefile.gcc" "Makefile"))
+                     `((invoke "./configure"
+                               (string-append "--prefix=" out)))))))
          (add-after 'install 'move-static-library
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out"))

base-commit: dcf133587ac7d73ba306a314e1a496a7efb9960b
-- 
2.36.1