[PATCH] gnu: zlib: Add support for MinGW targets.

  • Open
  • quality assurance status badge
Details
3 participants
  • David Thompson
  • Kaelyn
  • Ludovic Courtès
Owner
unassigned
Submitted by
David Thompson
Severity
normal
D
D
David Thompson wrote on 14 Aug 2019 14:58
(address . guix-patches@gnu.org)(name . David Thompson)(address . dthompson2@worcester.edu)
20190814125853.18488-1-dthompson2@worcester.edu
---
gnu/packages/compression.scm | 55 +++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 19 deletions(-)

Toggle diff (69 lines)
diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index 9834fcbe63..092eb4a54a 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -87,26 +87,43 @@
(arguments
`(#:phases
(modify-phases %standard-phases
- (replace 'configure
- (lambda* (#:key outputs #:allow-other-keys)
- ;; Zlib's home-made `configure' fails when passed
- ;; extra flags like `--enable-fast-install', so we need to
- ;; invoke it with just what it understand.
- (let ((out (assoc-ref outputs "out")))
- ;; 'configure' doesn't understand '--host'.
- ,@(if (%current-target-system)
- `((setenv "CHOST" ,(%current-target-system)))
- '())
- (invoke "./configure"
- (string-append "--prefix=" out)))))
+ ,@(if (target-mingw?)
+ `((delete 'configure)
+ (add-before 'install 'set-install-paths
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (setenv "INCLUDE_PATH" (string-append out "/include"))
+ (setenv "LIBRARY_PATH" (string-append out "/lib"))
+ (setenv "BINARY_PATH" (string-append out "/bin"))
+ #t))))
+ `((replace 'configure
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Zlib's home-made `configure' fails when passed
+ ;; extra flags like `--enable-fast-install', so we need to
+ ;; invoke it with just what it understand.
+ (let ((out (assoc-ref outputs "out")))
+ ;; 'configure' doesn't understand '--host'.
+ ,@(if (%current-target-system)
+ `((setenv "CHOST" ,(%current-target-system)))
+ '())
+ (invoke "./configure"
+ (string-append "--prefix=" out)))))))
(add-after 'install 'move-static-library
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out"))
- (static (assoc-ref outputs "static")))
- (with-directory-excursion (string-append out "/lib")
- (install-file "libz.a" (string-append static "/lib"))
- (delete-file "libz.a")
- #t)))))))
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (static (assoc-ref outputs "static")))
+ (with-directory-excursion (string-append out "/lib")
+ (install-file "libz.a" (string-append static "/lib"))
+ (delete-file "libz.a")
+ #t)))))
+ ,@(if (target-mingw?)
+ `(#:make-flags
+ '("-fwin32/Makefile.gcc"
+ "SHARED_MODE=1"
+ ,(string-append "CC=" (%current-target-system) "-gcc")
+ ,(string-append "RC=" (%current-target-system) "-windres")
+ ,(string-append "AR=" (%current-target-system) "-ar")))
+ '())))
(home-page "https://zlib.net/")
(synopsis "Compression library")
(description
--
2.17.1
L
L
Ludovic Courtès wrote on 28 Aug 2019 00:06
(name . David Thompson)(address . dthompson2@worcester.edu)(address . 37027@debbugs.gnu.org)
87a7bumffh.fsf@gnu.org
Hi David,

David Thompson <dthompson2@worcester.edu> skribis:

Toggle quote (4 lines)
> ---
> gnu/packages/compression.scm | 55 +++++++++++++++++++++++-------------
> 1 file changed, 36 insertions(+), 19 deletions(-)

Please add a commit log. :-)

Toggle quote (11 lines)
> + `((delete 'configure)
> + (add-before 'install 'set-install-paths
> + (lambda* (#:key outputs #:allow-other-keys)
> + (let ((out (assoc-ref outputs "out")))
> + (setenv "INCLUDE_PATH" (string-append out "/include"))
> + (setenv "LIBRARY_PATH" (string-append out "/lib"))
> + (setenv "BINARY_PATH" (string-append out "/bin"))
> + #t))))
> + `((replace 'configure
> + (lambda* (#:key outputs #:allow-other-keys)

Minor issue: could you adjust indentation to look like:

(add-before 'x 'y
(lambda* …

? guix.el should take care of that.

Toggle quote (10 lines)
> - (with-directory-excursion (string-append out "/lib")
> - (install-file "libz.a" (string-append static "/lib"))
> - (delete-file "libz.a")
> - #t)))))))
> + (lambda* (#:key outputs #:allow-other-keys)
> + (let ((out (assoc-ref outputs "out"))
> + (static (assoc-ref outputs "static")))
> + (with-directory-excursion (string-append out "/lib")
> + (install-file "libz.a" (string-append static "/lib"))

The ‘with-directory-excursion’ indentation went off here.

Toggle quote (9 lines)
> + ,@(if (target-mingw?)
> + `(#:make-flags
> + '("-fwin32/Makefile.gcc"
> + "SHARED_MODE=1"
> + ,(string-append "CC=" (%current-target-system) "-gcc")
> + ,(string-append "RC=" (%current-target-system) "-windres")
> + ,(string-append "AR=" (%current-target-system) "-ar")))
> + '())))

I wonder if we could have a single ‘if’:

(arguments
(if (target-mingw?)
))

? Thoughts?

Otherwise LGTM, thanks!

Ludo’.
K
K
Kaelyn wrote on 5 Oct 20:00 +0200
[PATCH] gnu: zlib: Add support for MinGW targets.
(name . 37027@debbugs.gnu.org)(address . 37027@debbugs.gnu.org)
6EnI9qh35seWLVyUEcLFiKutBxKRl2TAojoc6d_aZx40pPNPvHzs_3f4paMAa0QwecAy2CwU6uPuKWoC8RB9zfp974oBPKPsZkondLzJJLs=@protonmail.com
Hi,

It looks like mingw cross compilation support for zlib was added about two years ago in commit 0565cde6892c4fcc503a86227e366d3500040076. I believe this issue can be closed now, but am not 100% sure if the extra settings of "CC", "RC", and "AR" in the #:make-flags is necessary (and it looks to be the main functional discrepancy between this patch series and commit 0565cde6892c4fcc503a86227e366d3500040076).

Cheers.
Kaelyn
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 37027@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 37027
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch