Skip to content

Commit d49be4d

Browse files
committed
CDRIVER-2292 respect --with-zlib/snappy=system
1 parent 14b679c commit d49be4d

File tree

3 files changed

+69
-49
lines changed

3 files changed

+69
-49
lines changed

build/autotools/CheckSnappy.m4

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
# If --with-snappy=auto, determine if there is a system installed snappy
22
# greater than our required version.
3-
AS_IF([test "x${with_snappy}" = xauto], [
4-
PKG_CHECK_MODULES(SNAPPY, [snappy],
5-
[with_snappy=system],
6-
[
7-
# If we didn't find snappy with pkgconfig, use bundled
8-
# unless we find it manually
9-
with_snappy=bundled
10-
AC_CHECK_LIB([snappy],[snappy_uncompress],
11-
[AC_CHECK_HEADER([snappy-c.h],
12-
[
13-
with_snappy=system
14-
SNAPPY_LIBS=-lsnappy
15-
]
16-
)]
17-
)
18-
]
19-
)
20-
]
21-
)
3+
found_snappy=no
224

23-
AS_IF([test "x${SNAPPY_LIBS}" = "x" -a "x$with_snappy" = "xsystem"],
24-
[AC_MSG_ERROR([Cannot find system installed snappy. try --with-snappy=bundled])])
5+
AS_IF([test "x${with_snappy}" = xauto -o "x${with_snappy}" = xsystem], [
6+
PKG_CHECK_MODULES(SNAPPY, [snappy], [
7+
found_snappy=yes
8+
], [
9+
# If we didn't find snappy with pkgconfig, search manually. If that
10+
# fails and with-snappy=system, fail, or if with-snappy=auto, use
11+
# bundled.
12+
AC_CHECK_LIB([snappy], [snappy_uncompress], [
13+
AC_CHECK_HEADER([snappy-c.h], [
14+
found_snappy=yes
15+
])
16+
])
17+
])
18+
])
19+
20+
AS_IF([test "x${found_snappy}" = xyes], [
21+
with_snappy=system
22+
SNAPPY_LIBS=-lsnappy
23+
], [
24+
# snappy not found
25+
AS_IF([test "x${with_snappy}" = xauto -o "x${with_snappy}" = xbundled], [
26+
with_snappy=bundled
27+
], [
28+
# snappy not found, with-snappy=system
29+
AC_MSG_ERROR([Cannot find system installed snappy. try --with-snappy=bundled])
30+
]
31+
)])
2532

2633
# If we are using the bundled snappy, recurse into its configure.
2734
AS_IF([test "x${with_snappy}" = xbundled],[
@@ -83,7 +90,7 @@ AS_IF([test "x${with_snappy}" = xbundled],[
8390
SNAPPY_CFLAGS="-Isrc/snappy-1.1.3"
8491
])
8592

86-
if test "x$with_snappy" != "xno"; then
93+
if test "x${with_snappy}" != "xno"; then
8794
AC_SUBST(MONGOC_ENABLE_COMPRESSION_SNAPPY, 1)
8895
else
8996
AC_SUBST(MONGOC_ENABLE_COMPRESSION_SNAPPY, 0)

build/autotools/CheckZlib.m4

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
# If --with-zlib=auto, determine if there is a system installed zlib
2-
AS_IF([test "x${with_zlib}" = xauto], [
3-
PKG_CHECK_MODULES(ZLIB, [zlib],
4-
[with_zlib=system],
5-
[
6-
# If we didn't find zlib with pkgconfig, use bundled
7-
# unless we find it manually
8-
with_zlib=bundled
9-
AC_CHECK_LIB([zlib],[compress2],
10-
[AC_CHECK_HEADER([zlib-c.h],
11-
[
12-
with_zlib=system
13-
ZLIB_LIBS=-lz
14-
]
15-
)]
16-
)
17-
]
18-
)
2+
# greater than our required version.
3+
found_zlib=no
4+
5+
AS_IF([test "x${with_zlib}" = xauto -o "x${with_zlib}" = xsystem], [
6+
PKG_CHECK_MODULES(zlib, [zlib], [
7+
found_zlib=yes
8+
], [
9+
# If we didn't find zlib with pkgconfig, search manually. If that
10+
# fails and with-zlib=system, fail, or if with-zlib=auto, use
11+
# bundled.
12+
AC_CHECK_LIB([zlib], [compress2], [
13+
AC_CHECK_HEADER([zlib.h], [
14+
found_zlib=yes
15+
])
16+
])
17+
])
18+
], [
19+
AS_IF([test "x${with_zlib}" != xbundled], [
20+
AC_MSG_ERROR([Invalid --with-zlib option: must be system, bundled, or auto.])
21+
])
22+
])
23+
24+
AS_IF([test "x${found_zlib}" = "xyes"], [
25+
with_zlib=system
26+
ZLIB_LIBS=-lz
27+
], [
28+
# zlib not found
29+
AS_IF([test "x${with_zlib}" = xauto -o "x${with_zlib}" = xbundled], [
30+
with_zlib=bundled
31+
], [
32+
# zlib not found, with-zlib=system
33+
AC_MSG_ERROR([Cannot find system installed zlib. try --with-zlib=bundled])
1934
]
20-
)
35+
)])
2136

22-
AS_IF([test "x${ZLIB_LIBS}" = "x" -a "x$with_zlib" = "xsystem"],
23-
[AC_MSG_ERROR([Cannot find system installed zlib. try --with-zlib=bundled])])
2437

2538
# If we are using the bundled zlib, recurse into its configure.
2639
AS_IF([test "x${with_zlib}" = xbundled],[
@@ -30,7 +43,7 @@ AS_IF([test "x${with_zlib}" = xbundled],[
3043
ZLIB_CFLAGS="-Isrc/zlib-1.2.11"
3144
])
3245

33-
if test "x$with_zlib" != "xno"; then
46+
if test "x${with_zlib}" != "xno"; then
3447
AC_SUBST(MONGOC_ENABLE_COMPRESSION_ZLIB, 1)
3548
else
3649
AC_SUBST(MONGOC_ENABLE_COMPRESSION_ZLIB, 0)

build/autotools/ReadCommandLineArguments.m4

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,24 @@ AC_ARG_WITH(libbson,
8686
[use system installed libbson or bundled libbson. default=auto]),
8787
[],
8888
[with_libbson=auto])
89-
AS_IF([test "x$with_libbson" != xbundled && test "x$with_libbson" != xsystem],
90-
[with_libbson=auto])
89+
AS_IF([test "x$with_libbson" != xbundled -a "x$with_libbson" != xsystem -a "x$with_libbson" != xauto],
90+
[AC_MSG_ERROR([Invalid --with-libbson option: must be system, bundled, or auto])])
9191

9292
AC_ARG_WITH(snappy,
9393
AC_HELP_STRING([--with-snappy=@<:@auto/system/bundled/no@:>@],
9494
[use system installed snappy or bundled snappy. default=auto]),
9595
[],
9696
[with_snappy=auto])
97-
AS_IF([test "x$with_snappy" != xbundled && test "x$with_snappy" != xsystem && test "x$with_snappy" != xno],
98-
[with_snappy=auto])
97+
AS_IF([test "x$with_snappy" != xbundled -a "x$with_snappy" != xsystem -a "x$with_snappy" != xauto -a "x$with_snappy" != xno],
98+
[AC_MSG_ERROR([Invalid --with-snappy option: must be system, bundled, auto, no])])
9999

100100
AC_ARG_WITH(zlib,
101101
AC_HELP_STRING([--with-zlib=@<:@auto/system/bundled/no@:>@],
102102
[use system installed zlib or bundled zlib. default=auto]),
103103
[],
104104
[with_zlib=auto])
105-
AS_IF([test "x$with_zlib" != xbundled && test "x$with_zlib" != xsystem && test "x$with_zlib" != xno],
106-
[with_zlib=auto])
105+
AS_IF([test "x$with_zlib" != xbundled -a "x$with_zlib" != xsystem -a "x$with_zlib" != xauto -a "x$with_zlib" != xno],
106+
[AC_MSG_ERROR([Invalid --with-zlib option: must be system, bundled, auto, no])])
107107

108108
AC_ARG_ENABLE([html-docs],
109109
[AS_HELP_STRING([--enable-html-docs=@<:@yes/no@:>@],

0 commit comments

Comments
 (0)