forked from zabbix/zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zlib.m4
105 lines (92 loc) · 2.43 KB
/
zlib.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# ZLIB_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for zlib.
#
# This macro #defines HAVE_ZLIB_H if required header files are
# found, and sets @ZLIB_LDFLAGS@ and @ZLIB_CFLAGS@ to the necessary
# values.
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([ZLIB_TRY_LINK],
[
found_zlib=$1
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <zlib.h>
]], [[
z_stream defstream;
deflateInit(&defstream, Z_BEST_COMPRESSION);
]])],[found_zlib="yes"],[])
])dnl
AC_DEFUN([ZLIB_CHECK_CONFIG],
[
AC_ARG_WITH([zlib],[
If you want to specify zlib installation directories:
AS_HELP_STRING([--with-zlib@<:@=DIR@:>@], [use zlib from given base install directory (DIR), default is to search through a number of common places for the zlib files.])],
[
test "x$withval" = "xyes" && withval=/usr
ZLIB_CFLAGS="-I$withval/include"
ZLIB_LDFLAGS="-L$withval/lib"
_zlib_dir_set="yes"
]
)
AC_ARG_WITH([zlib-include],
AS_HELP_STRING([--with-zlib-include=DIR],
[use zlib include headers from given path.]
),
[
ZLIB_CFLAGS="-I$withval"
_zlib_dir_set="yes"
]
)
AC_ARG_WITH([zlib-lib],
AS_HELP_STRING([--with-zlib-lib=DIR],
[use zlib libraries from given path.]
),
[
ZLIB_LDFLAGS="-L$withval"
_zlib_dir_set="yes"
]
)
AC_MSG_CHECKING(for zlib support)
ZLIB_LIBS="-lz"
if test -n "$_zlib_dir_set" -o -f /usr/include/zlib.h; then
found_zlib="yes"
elif test -f /usr/local/include/zlib.h; then
ZLIB_CFLAGS="-I/usr/local/include"
ZLIB_LDFLAGS="-L/usr/local/lib"
found_zlib="yes"
elif test -f /usr/pkg/include/zlib.h; then
ZLIB_CFLAGS="-I/usr/pkg/include"
ZLIB_LDFLAGS="-L/usr/pkg/lib"
found_zlib="yes"
else
found_zlib="no"
AC_MSG_RESULT(no)
fi
if test "x$found_zlib" = "xyes"; then
am_save_CFLAGS="$CFLAGS"
am_save_LDFLAGS="$LDFLAGS"
am_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $ZLIB_CFLAGS"
LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS"
LIBS="$LIBS $ZLIB_LIBS"
ZLIB_TRY_LINK([no])
CFLAGS="$am_save_CFLAGS"
LDFLAGS="$am_save_LDFLAGS"
LIBS="$am_save_LIBS"
fi
if test "x$found_zlib" = "xyes"; then
AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the 'zlib' library (-lz)])
AC_MSG_RESULT(yes)
else
ZLIB_CFLAGS=""
ZLIB_LDFLAGS=""
ZLIB_LIBS=""
fi
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LDFLAGS)
AC_SUBST(ZLIB_LIBS)
])dnl