Skip to content

Commit

Permalink
Use zlib-clib on Windows, unless pkg-config is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Apr 21, 2024
1 parent e0a7f3f commit 6ce8114
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions zlib/zlib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ flag non-blocking-ffi
flag pkg-config
default: True
manual: False
description: Use @pkg-config(1)@ to locate foreign @zlib@ library.
description: Use @pkg-config@ executable to locate foreign @zlib@ library.

flag bundled-c-zlib
default: False
manual: True
description: Use the bundled zlib C sources.
For GHCJS and WASM this is the default.
description: Use @zlib-clib@ package with C sources instead of a system library.
C sources are used for GHCJS and WASM unconditionally
and on Windows unless @pkg-config@ flag is on.

library
exposed-modules: Codec.Compression.GZip,
Expand Down Expand Up @@ -99,15 +100,21 @@ library
if flag(non-blocking-ffi)
cpp-options: -DNON_BLOCKING_FFI

if flag(bundled-c-zlib) || impl(ghcjs) || os(ghcjs) || arch(wasm32)
build-depends: zlib-clib
-- Cross-platform builds (such as JS and WASM) must have access
-- to C sources, so using zlib-clib unconditionally.
--
-- On Windows zlib is shipped with GHC starting from 7.10
-- at mingw/lib/libz.a. Yet linking against it proves unreliable:
-- while GHC always links against mingw/lib whatever the PATH,
-- there are no guarantees that zlib1.dll will be in PATH afterwards.
-- Thus resorting to zlib-clib again, unless pkg-config is available.
if flag(bundled-c-zlib) || impl(ghcjs) || os(ghcjs) || arch(wasm32) || (!flag(pkg-config) && os(windows))
build-depends: zlib-clib < 2
else
if flag(pkg-config)
-- NB: pkg-config is available on windows as well when using msys2
pkgconfig-depends: zlib
else
-- On Windows zlib is shipped with GHC starting from 7.10
-- at mingw/lib/libz.a
extra-libraries: z

test-suite tests
Expand Down

0 comments on commit 6ce8114

Please sign in to comment.