Skip to content

Commit 25d1c24

Browse files
authored
Merge pull request #16 from ljli/zlib-pkg-config
Add flag to depend on zlib via pkg-config
2 parents a34b3bd + c465919 commit 25d1c24

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

zlib.cabal

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ flag non-blocking-ffi
4545
prevents other Haskell threads running. Enabling this flag
4646
avoids this unfairness, but with greater overall cost.
4747

48+
flag pkg-config
49+
default: False
50+
manual: True
51+
description: Use @pkg-config(1)@ to locate foreign @zlib@ library.
52+
4853
library
4954
exposed-modules: Codec.Compression.GZip,
5055
Codec.Compression.Zlib,
@@ -68,18 +73,23 @@ library
6873
ghc-options: -Wall -fwarn-tabs
6974
if flag(non-blocking-ffi)
7075
cpp-options: -DNON_BLOCKING_FFI
71-
if !os(windows)
72-
-- Normally we use the the standard system zlib:
73-
extra-libraries: z
76+
if flag(pkg-config)
77+
-- NB: pkg-config is available on windows as well when using msys2
78+
pkgconfig-depends: zlib
7479
else
75-
-- However for the benefit of users of Windows (which does not have zlib
76-
-- by default) we bundle a complete copy of the C sources of zlib-1.2.8
77-
c-sources: cbits/adler32.c cbits/compress.c cbits/crc32.c
80+
-- don't use pkg-config
81+
if !os(windows)
82+
-- Normally we use the the standard system zlib.
83+
extra-libraries: z
84+
else
85+
-- However for the benefit of users of Windows (which does not have zlib
86+
-- by default) we bundle a complete copy of the C sources of zlib-1.2.8
87+
c-sources: cbits/adler32.c cbits/compress.c cbits/crc32.c
7888
cbits/deflate.c cbits/infback.c
7989
cbits/inffast.c cbits/inflate.c cbits/inftrees.c
8090
cbits/trees.c cbits/uncompr.c cbits/zutil.c
81-
include-dirs: cbits
82-
install-includes: zlib.h zconf.h
91+
include-dirs: cbits
92+
install-includes: zlib.h zconf.h
8393

8494
test-suite tests
8595
type: exitcode-stdio-1.0

0 commit comments

Comments
 (0)