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 7df81e6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 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,22 @@ 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 as part of GHC's mingw/lib directory,
-- which GHC always includes in its linker search path. However,
-- there is no guarantee that zlib1.dll (the corresponding shared library)
-- will be available on the user's PATH at runtime, making it risky to depend upon
-- (see https://github.com/haskell/zlib/issues/65 for what can go wrong).
-- Thus, we resort to zlib-clib 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 7df81e6

Please sign in to comment.