forked from kjdev/php-ext-zstd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.m4
121 lines (107 loc) · 3.98 KB
/
config.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
dnl config.m4 for extension zstd
dnl Check PHP version:
AC_MSG_CHECKING(PHP version)
if test ! -z "$phpincludedir"; then
PHP_VERSION=`grep 'PHP_VERSION ' $phpincludedir/main/php_version.h | sed -e 's/.*"\([[0-9\.]]*\)".*/\1/g' 2>/dev/null`
elif test ! -z "$PHP_CONFIG"; then
PHP_VERSION=`$PHP_CONFIG --version 2>/dev/null`
fi
if test x"$PHP_VERSION" = "x"; then
AC_MSG_WARN([none])
else
PHP_MAJOR_VERSION=`echo $PHP_VERSION | sed -e 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/g' 2>/dev/null`
PHP_MINOR_VERSION=`echo $PHP_VERSION | sed -e 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/g' 2>/dev/null`
PHP_RELEASE_VERSION=`echo $PHP_VERSION | sed -e 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/g' 2>/dev/null`
AC_MSG_RESULT([$PHP_VERSION])
fi
if test $PHP_MAJOR_VERSION -lt 7; then
AC_MSG_ERROR([need at least PHP 7 or newer])
fi
PHP_ARG_ENABLE(zstd, whether to enable zstd support,
[ --enable-zstd Enable zstd support])
PHP_ARG_WITH(libzstd, whether to use system zstd library,
[ --with-libzstd Use system zstd library], no, no)
if test "$PHP_ZSTD" != "no"; then
if test "$PHP_LIBZSTD" != "no"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libzstd)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzstd; then
if $PKG_CONFIG libzstd --atleast-version 1; then
LIBZSTD_CFLAGS=`$PKG_CONFIG libzstd --cflags`
LIBZSTD_LIBDIR=`$PKG_CONFIG libzstd --libs`
LIBZSTD_VERSON=`$PKG_CONFIG libzstd --modversion`
AC_MSG_RESULT(from pkgconfig: version $LIBZSTD_VERSON)
else
AC_MSG_ERROR(system libzstd is too old)
fi
else
AC_MSG_ERROR(pkg-config not found)
fi
PHP_EVAL_LIBLINE($LIBZSTD_LIBDIR, ZSTD_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBZSTD_CFLAGS)
else
ZSTD_COMMON_SOURCES="
zstd/lib/common/debug.c
zstd/lib/common/entropy_common.c
zstd/lib/common/error_private.c
zstd/lib/common/fse_decompress.c
zstd/lib/common/pool.c
zstd/lib/common/threading.c
zstd/lib/common/xxhash.c
zstd/lib/common/zstd_common.c
"
ZSTD_COMPRESS_SOURCES="
zstd/lib/compress/fse_compress.c
zstd/lib/compress/hist.c
zstd/lib/compress/huf_compress.c
zstd/lib/compress/zstd_compress.c
zstd/lib/compress/zstd_compress_literals.c
zstd/lib/compress/zstd_compress_sequences.c
zstd/lib/compress/zstd_compress_superblock.c
zstd/lib/compress/zstd_double_fast.c
zstd/lib/compress/zstd_fast.c
zstd/lib/compress/zstd_lazy.c
zstd/lib/compress/zstd_ldm.c
zstd/lib/compress/zstd_opt.c
zstd/lib/compress/zstdmt_compress.c
"
ZSTD_DECOMPRESS_SOURCES="
zstd/lib/decompress/huf_decompress.c
zstd/lib/decompress/zstd_ddict.c
zstd/lib/decompress/zstd_decompress.c
zstd/lib/decompress/zstd_decompress_block.c
zstd/lib/decompress/huf_decompress_amd64.S
"
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/zstd/lib/common)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/zstd/lib)
fi
PHP_NEW_EXTENSION(zstd, zstd.c $ZSTD_COMMON_SOURCES $ZSTD_COMPRESS_SOURCES $ZSTD_DECOMPRESS_SOURCES, $ext_shared)
PHP_SUBST(ZSTD_SHARED_LIBADD)
if test "$PHP_LIBZSTD" = "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/zstd/lib/common)
PHP_ADD_BUILD_DIR($ext_builddir/zstd/lib/compress)
PHP_ADD_BUILD_DIR($ext_builddir/zstd/lib/decompress)
fi
ifdef([PHP_INSTALL_HEADERS],
[
PHP_INSTALL_HEADERS([ext/zstd/], [php_zstd.h])
], [
PHP_ADD_MAKEFILE_FRAGMENT
])
fi
dnl APCu
AC_MSG_CHECKING([for APCu includes])
if test -f "$phpincludedir/ext/apcu/apc_serializer.h"; then
apc_inc_path="$phpincludedir"
AC_MSG_RESULT([APCu in $apc_inc_path])
AC_DEFINE(HAVE_APCU_SUPPORT, 1, [Whether to enable APCu support])
else
AC_MSG_RESULT([not found])
fi
dnl coverage
PHP_ARG_ENABLE(coverage, whether to enable coverage support,
[ --enable-coverage Enable coverage support], no, no)
if test "$PHP_COVERAGE" != "no"; then
EXTRA_CFLAGS="--coverage"
PHP_SUBST(EXTRA_CFLAGS)
fi