-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathbuild-extensions.sh
More file actions
executable file
·231 lines (203 loc) · 7.26 KB
/
build-extensions.sh
File metadata and controls
executable file
·231 lines (203 loc) · 7.26 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/bash
set -eux
# We can't match for "shared" only, as zend_test is built shared. Match something explicitly.
SHARED_BUILD=$(if php -i | grep -q enable-pcntl=shared; then echo 1; else echo 0; fi)
PHP_VERSION_ID=$(php -r 'echo PHP_MAJOR_VERSION . PHP_MINOR_VERSION;')
PHP_ZTS=$(php -r 'echo PHP_ZTS;')
EXTENSION_DIR=$(php-config --extension-dir)
# This make `pecl install` use all available cores
export MAKEFLAGS="-s -j $(nproc)"
XDEBUG_VERSIONS=(-3.1.2)
if [[ $PHP_VERSION_ID -le 70 ]]; then
XDEBUG_VERSIONS=(-2.7.2)
elif [[ $PHP_VERSION_ID -le 74 ]]; then
XDEBUG_VERSIONS=(-2.9.2 -2.9.5)
elif [[ $PHP_VERSION_ID -le 80 ]]; then
XDEBUG_VERSIONS=(-3.0.0)
elif [[ $PHP_VERSION_ID -le 81 ]]; then
XDEBUG_VERSIONS=(-3.1.0)
elif [[ $PHP_VERSION_ID -le 82 ]]; then
XDEBUG_VERSIONS=(-3.2.2)
elif [[ $PHP_VERSION_ID -le 83 ]]; then
XDEBUG_VERSIONS=(-3.3.2)
else
XDEBUG_VERSIONS=(-3.4.0)
fi
MONGODB_VERSION=
if [[ $PHP_VERSION_ID -le 70 ]]; then
MONGODB_VERSION=-1.9.2
elif [[ $PHP_VERSION_ID -le 71 ]]; then
MONGODB_VERSION=-1.11.1
elif [[ $PHP_VERSION_ID -le 73 ]]; then
MONGODB_VERSION=-1.16.2
elif [[ $PHP_VERSION_ID -le 80 ]]; then
MONGODB_VERSION=-1.20.1
fi
AMQP_VERSION=
if [[ $PHP_VERSION_ID -le 73 ]]; then
AMQP_VERSION=-1.11.0
else
AMQP_VERSION=-2.1.2
fi
AST_VERSION=
if [[ $PHP_VERSION_ID -le 71 ]]; then
AST_VERSION=-1.0.16
fi
MEMCACHE_VERSION=
if [[ $PHP_VERSION_ID -le 74 ]]; then
MEMCACHE_VERSION=-4.0.5.2
fi
SQLSRV_VERSION=
if [[ $PHP_VERSION_ID -le 70 ]]; then
SQLSRV_VERSION=-5.3.0
elif [[ $PHP_VERSION_ID -le 71 ]]; then
SQLSRV_VERSION=-5.6.1
elif [[ $PHP_VERSION_ID -le 74 ]]; then
SQLSRV_VERSION=-5.8.0
elif [[ $PHP_VERSION_ID -le 80 ]]; then
SQLSRV_VERSION=-5.11.0
elif [[ $PHP_VERSION_ID -le 82 ]]; then
SQLSRV_VERSION=-5.12.0
fi
HOST_ARCH=$(if [[ $(file $(readlink -f $(which php))) == *aarch64* ]]; then echo "aarch64"; else echo "x86_64"; fi)
export PKG_CONFIG=/usr/bin/$HOST_ARCH-linux-gnu-pkg-config
# export CC=$HOST_ARCH-linux-gnu-gcc
# export CXX=$HOST_ARCH-linux-gnu-g++
iniDir=$(php -i | awk -F"=> " '/Scan this dir for additional .ini files/ {print $2}');
if [[ $SHARED_BUILD -ne 0 ]]; then
# curl defines ldap_connect itself and it'll conflict otherwise with newer ldap versions
sudo sed -i 's/ldap_connect/__ldap_connect/' /usr/include/ldap.h
# Build curl versions
CURL_VERSIONS="7.72.0 7.77.0"
for curlVer in ${CURL_VERSIONS}; do
echo "Build curl ${curlVer}..."
cd /tmp
curl -L -o curl.tar.gz https://curl.se/download/curl-${curlVer}.tar.gz
tar -xf curl.tar.gz && rm curl.tar.gz
cd curl-${curlVer}
./configure --with-openssl --prefix=/opt/curl/${curlVer}
make -j "$((`nproc`+1))"
make install
done
# Build core extensions as shared libraries.
# We intentionally do not run 'make install' here so that we can test the
# scenario where headers are not installed for the shared library.
# ext/curl
cd ${PHP_SRC_DIR}/ext/curl
phpize
./configure
make -j "$((`nproc`+1))"
mv ./modules/*.so $EXTENSION_DIR
make clean
for curlVer in ${CURL_VERSIONS}; do
PKG_CONFIG_PATH=/opt/curl/${curlVer}/lib/pkgconfig/
./configure
make -j "$((`nproc`+1))"
mv ./modules/curl.so $EXTENSION_DIR/curl-${curlVer}.so
make clean
done
phpize --clean
# ext/pdo
cd ${PHP_SRC_DIR}/ext/pdo
phpize
./configure
make -j "$((`nproc`+1))"
mv ./modules/*.so $(php-config --extension-dir)
make clean;
phpize --clean
# TODO Add ext/pdo_mysql, ext/pdo_pgsql, and ext/pdo_sqlite
else
pecl channel-update pecl.php.net;
yes '' | pecl install apcu; echo "extension=apcu.so" >> ${iniDir}/apcu.ini;
pecl install ast$AST_VERSION; echo "extension=ast.so" >> ${iniDir}/ast.ini;
if [[ $PHP_VERSION_ID -ge 71 && $PHP_VERSION_ID -le 80 ]]; then
yes '' | CFLAGS="-Wno-incompatible-function-pointer-types" pecl install mcrypt$(if [[ $PHP_VERSION_ID -le 71 ]]; then echo -1.0.0; fi); echo "extension=mcrypt.so" >> ${iniDir}/mcrypt.ini;
fi
if [[ $PHP_VERSION_ID -lt 85 ]]; then
pecl install amqp$AMQP_VERSION; echo "extension=amqp.so" >> "${iniDir}/amqp.ini"
yes 'no' | pecl install memcached; echo "extension=memcached.so" >> ${iniDir}/memcached.ini;
yes '' | pecl install memcache$MEMCACHE_VERSION; echo "extension=memcache.so" >> ${iniDir}/memcache.ini;
pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini;
# Xdebug is disabled by default
for VERSION in "${XDEBUG_VERSIONS[@]}"; do
pecl install xdebug$VERSION;
cd $(php-config --extension-dir);
mv xdebug.so xdebug$VERSION.so;
done
else
cd /tmp
# memcached master version
git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
phpize && ./configure && make -j"$(nproc)" && make install && echo "extension=memcached.so" >> ${iniDir}/memcached.ini;
cd ..
# memcache master version
git clone https://github.com/websupport-sk/pecl-memcache.git
cd pecl-memcache
phpize && ./configure && make -j"$(nproc)" && make install && echo "extension=memcache.so" >> ${iniDir}/memcache.ini;
cd ..
pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini;
# Xdebug master version (disabled by default)
git clone https://github.com/xdebug/xdebug.git
cd xdebug
phpize && ./configure && make -j"$(nproc)" && make install;
cd ..
fi
pecl install rdkafka; echo "extension=rdkafka.so" >> ${iniDir}/rdkafka.ini;
pecl install sqlsrv$SQLSRV_VERSION;
echo "zend_extension=opcache.so" >> ${iniDir}/../php-apache2handler.ini;
# ext-parallel needs PHP 8 ZTS
if [[ $PHP_VERSION_ID -ge 80 && $PHP_ZTS -eq 1 ]]; then
pecl install parallel;
echo "extension=parallel" >> ${iniDir}/parallel.ini;
fi
# ext-swoole needs PHP 8
if [[ $PHP_VERSION_ID -ge 80 && $PHP_VERSION_ID -lt 85 ]]; then
pushd /tmp
if [[ $PHP_VERSION_ID -ge 83 ]]; then
pecl download swoole-6.0.0RC1;
tar xzf swoole-6.0.0RC1.tgz
cd swoole-6.0.0RC1
else
pecl download swoole-5.1.6;
tar xzf swoole-5.1.6.tgz
cd swoole-5.1.6
fi
phpize
./configure --host=$HOST_ARCH-linux-gnu
make -j "$((`nproc`+1))"
make install
popd
fi
# ext-grpc is needed for google spanner
if [[ $PHP_VERSION_ID -ge 80 && $PHP_VERSION_ID -lt 85 ]]; then
pecl install grpc-1.78.0;
# avoid installing it by default, it seems to stall some testsuites.
fi
# We don't install any redis.so to inis, but allow selection at runtime.
if [[ $PHP_VERSION_ID -lt 80 ]]; then
pecl install redis-3.1.6
mv $EXTENSION_DIR/redis.so $EXTENSION_DIR/redis-3.1.6.so
pecl install redis-4.3.0
mv $EXTENSION_DIR/redis.so $EXTENSION_DIR/redis-4.3.0.so
fi
if [[ $PHP_VERSION_ID -le 83 ]]; then
pecl install redis-5.3.7
# Redis 6.0.0 dropped support for PHP 7.1 and below
if [[ $PHP_VERSION_ID -gt 71 ]]; then
mv $EXTENSION_DIR/redis.so $EXTENSION_DIR/redis-5.3.7.so
pecl install redis-6.0.2
else
ln -s $EXTENSION_DIR/redis.so $EXTENSION_DIR/redis-5.3.7.so
fi
fi
if [[ $PHP_VERSION_ID -ge 84 ]]; then
if [[ $PHP_VERSION_ID -ge 85 ]]; then
git clone https://github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make -j"$(nproc)" && make install
else
pecl install redis-6.1.0
fi
fi
fi