diff mbox series

[bug#56504] Mingw support for zlib

Message ID 29fa1e573d51f351796ba22d7344d9738d71c9be.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 12, 2022, 4:45 p.m. UTC
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:
> 
> > +               ,@(if (and (%current-target-system)
> > +                          (string-suffix? "-w64-mingw32"
> > (%current-
> > target-system)))
> I'm pretty sure there's an abbreviation for this like target-mingw?
Precisely! Fixed it, thank you.

> > +                     `((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?

> > +                     `((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.

Thank you for your review!

Vivien

Comments

Liliana Marie Prikler July 13, 2022, 5:49 a.m. UTC | #1
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:
> > 
> > > +               ,@(if (and (%current-target-system)
> > > +                          (string-suffix? "-w64-mingw32"
> > > (%current-
> > > target-system)))
> > I'm pretty sure there's an abbreviation for this like target-mingw?
> Precisely! Fixed it, thank you.
> 
> > > +                     `((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").

> > > +                     `((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?


Cheers
diff mbox series

Patch

From 1ddb567f30f565e951321b80921f27ed7f10f604 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 v2] gnu: zlib: Support mingw cross-compilation.

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

diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index d5bd3abf0f..ea1bc2a03f 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -113,7 +113,15 @@  (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")
+            ''())
+       #:phases
        (modify-phases %standard-phases
          (replace 'configure
            (lambda* (#:key outputs #:allow-other-keys)
@@ -125,8 +133,13 @@  (define-public zlib
                ,@(if (%current-target-system)
                      `((setenv "CHOST" ,(%current-target-system)))
                      '())
-               (invoke "./configure"
-                       (string-append "--prefix=" out)))))
+               ,@(if (target-mingw?)
+                     `((substitute* "win32/Makefile.gcc"
+                         (("prefix \\?= /usr/local")
+                          (string-append "prefix ?= " out)))
+                       (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: f0c8abe85787a0018c0adeb0bc4a6672d46686e4
-- 
2.36.1