forked from amphp/ext-uv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.m4
149 lines (129 loc) · 4.67 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
PHP_ARG_WITH(uv, Whether to include "uv" support,
[ --with-uv[=DIR] Include "uv" support])
PHP_ARG_ENABLE(uv-debug, for uv debug support,
[ --enable-uv-debug Enable enable uv debug support], no, no)
PHP_ARG_ENABLE(libuv-static, for uv debug support,
[ --enable-libuv-static Link LibUV staticly], yes, no)
PHP_ARG_ENABLE(dtrace, Whether to enable the "dtrace" debug,
[ --enable-dtrace Enable "dtrace" support], no, no)
AC_MSG_CHECKING([for supported PHP version])
if test -z "$PHP_VERSION"; then
if test -z "$PHP_CONFIG"; then
AC_MSG_ERROR([php-config not found])
fi
PHP_UV_FOUND_PHP_VERSION=`$PHP_CONFIG --version`
else
PHP_UV_FOUND_PHP_VERSION="$PHP_VERSION"
fi
if test "$PHP_UV_FOUND_PHP_VERSION" -lt "80000"; then
AC_MSG_ERROR([not supported. PHP version 8.0.0+ required (found $PHP_UV_FOUND_PHP_VERSION)])
else
AC_MSG_RESULT([supported ($PHP_UV_FOUND_PHP_VERSION)])
fi
if test -z "$PHP_DEBUG"; then
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging symbols],[
PHP_DEBUG=$enableval
],[ PHP_DEBUG=no
])
fi
if test "$PHP_UV_DEBUG" != "no"; then
CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -DPHP_UV_DEBUG=1"
AC_DEFINE(PHP_UV_DEBUG, 1, [Enable uv debug support])
fi
CFLAGS="$CFLAGS -std=gnu17"
if test "$PHP_DTRACE" != "no"; then
dnl TODO: we should move this line to Makefile.frag or somewhere.
case $host in
*darwin*)
dtrace -h -s phpuv_dtrace.d
UV_SHARED_DEPENDENCIES=phpuv_dtrace.h
PHP_ADD_LIBRARY(dtrace, UV_SHARED_LIBADD)
AC_DEFINE(PHP_UV_DTRACE, 1, [Enable uv dtrace support])
PHP_SUBST(UV_SHARED_DEPENDENCIES)
PHP_ADD_MAKEFILE_FRAGMENT
;;
*linux*)
echo "dtrace does not support this machine. currently OSX only"
esac
fi
if test $PHP_UV != "no"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libuv)
if test "$PHP_LIBUV_STATIC" == "yes" && test $PHP_UV == "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libuv-static; then
if $PKG_CONFIG libuv --atleast-version 1.0.0; then
LIBUV_INCLINE=`$PKG_CONFIG libuv-static --cflags`
LIBUV_LIBLINE=`$PKG_CONFIG libuv-static --libs`
LIBUV_VERSION=`$PKG_CONFIG libuv-static --modversion`
AC_MSG_RESULT(from pkgconfig: found version $LIBUV_VERSION)
AC_DEFINE(HAVE_UVLIB,1,[ ])
else
AC_MSG_ERROR(system libuv must be upgraded to version >= 1.0.0)
fi
PHP_EVAL_LIBLINE($LIBUV_LIBLINE, UV_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBUV_INCLINE)
elif test $PHP_UV == "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libuv; then
if $PKG_CONFIG libuv --atleast-version 1.0.0; then
LIBUV_INCLINE=`$PKG_CONFIG libuv --cflags`
LIBUV_LIBLINE=`$PKG_CONFIG libuv --libs`
LIBUV_VERSION=`$PKG_CONFIG libuv --modversion`
AC_MSG_RESULT(from pkgconfig: found version $LIBUV_VERSION)
AC_DEFINE(HAVE_UVLIB,1,[ ])
else
AC_MSG_ERROR(system libuv must be upgraded to version >= 1.0.0)
fi
PHP_EVAL_LIBLINE($LIBUV_LIBLINE, UV_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBUV_INCLINE)
else
SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="/include/uv.h"
if test -r $PHP_UV/$SEARCH_FOR; then # path given as parameter
UV_DIR=$PHP_UV
AC_MSG_RESULT(from option: found in $UV_DIR)
else # search default path list
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
UV_DIR=$i
AC_MSG_RESULT(from default path: found in $i)
fi
done
fi
PHP_ADD_INCLUDE($UV_DIR/include)
PHP_CHECK_LIBRARY(uv, uv_version,
[
PHP_ADD_LIBRARY_WITH_PATH(uv, $UV_DIR/$PHP_LIBDIR, UV_SHARED_LIBADD)
AC_DEFINE(HAVE_UVLIB,1,[ ])
],[
AC_MSG_ERROR([wrong uv library version or library not found])
],[
-L$UV_DIR/$PHP_LIBDIR -lm -luv
])
case $host in
*linux*)
CFLAGS="$CFLAGS -lrt"
esac
fi
PHP_SUBST([CFLAGS])
PHP_SUBST(UV_SHARED_LIBADD)
UV_SRC="\
src/php_uv_cb.c \
"
UV_LOCKS_SOURCES="\
src/locks/php_uv_mutex.c \
src/locks/php_uv_rwlock.c \
src/locks/php_uv_semaphore.c \
"
UV_FILE_SOURCES="\
src/fs/php_uv_pipe.c \
src/fs/php_uv_fs.c \
src/fs/php_uv_fs_common.c \
src/fs/php_uv_fs_poll.c \
src/fs/php_uv_fs_event.c \
src/fs/php_uv_stream.c \
src/fs/php_uv_poll.c \
"
PHP_NEW_EXTENSION(uv, $UV_LOCKS_SOURCES $UV_SRC $UV_FILE_SOURCES php_uv.c uv.c, $ext_shared)
PHP_ADD_INCLUDE(./include)
PHP_INSTALL_HEADERS([ext/uv], [php_uv.h])
PHP_ADD_EXTENSION_DEP(uv, sockets, false)
fi