board/csky: fixup gdb instructions in readme.txt
[buildroot-gz.git] / package / php / php.mk
blobf59a4e878178eab71f2fbaceef6d995b1c17e286
1 ################################################################################
3 # php
5 ################################################################################
7 PHP_VERSION = 7.1.3
8 PHP_SITE = http://www.php.net/distributions
9 PHP_SOURCE = php-$(PHP_VERSION).tar.xz
10 PHP_INSTALL_STAGING = YES
11 PHP_INSTALL_STAGING_OPTS = INSTALL_ROOT=$(STAGING_DIR) install
12 PHP_INSTALL_TARGET_OPTS = INSTALL_ROOT=$(TARGET_DIR) install
13 PHP_DEPENDENCIES = host-pkgconf
14 PHP_LICENSE = PHP
15 PHP_LICENSE_FILES = LICENSE
16 PHP_CONF_OPTS = \
17 --mandir=/usr/share/man \
18 --infodir=/usr/share/info \
19 --disable-all \
20 --without-pear \
21 --with-config-file-path=/etc \
22 --disable-phpdbg \
23 --disable-rpath
24 PHP_CONF_ENV = \
25 ac_cv_func_strcasestr=yes \
26 EXTRA_LIBS="$(PHP_EXTRA_LIBS)"
28 ifeq ($(BR2_STATIC_LIBS),y)
29 PHP_CONF_ENV += LIBS="$(PHP_STATIC_LIBS)"
30 endif
32 ifeq ($(BR2_STATIC_LIBS)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
33 PHP_STATIC_LIBS += -lpthread
34 endif
36 ifeq ($(call qstrip,$(BR2_TARGET_LOCALTIME)),)
37 PHP_LOCALTIME = UTC
38 else
39 # Not q-stripping this value, as we need quotes in the php.ini file
40 PHP_LOCALTIME = $(BR2_TARGET_LOCALTIME)
41 endif
43 # PHP can't be AUTORECONFed the standard way unfortunately
44 PHP_DEPENDENCIES += host-autoconf host-automake host-libtool
45 define PHP_BUILDCONF
46 cd $(@D) ; $(TARGET_MAKE_ENV) ./buildconf --force
47 endef
48 PHP_PRE_CONFIGURE_HOOKS += PHP_BUILDCONF
50 ifeq ($(BR2_ENDIAN),"BIG")
51 PHP_CONF_ENV += ac_cv_c_bigendian_php=yes
52 else
53 PHP_CONF_ENV += ac_cv_c_bigendian_php=no
54 endif
55 PHP_CONFIG_SCRIPTS = php-config
57 PHP_CFLAGS = $(TARGET_CFLAGS)
59 # The OPcache extension isn't cross-compile friendly
60 # Throw some defines here to avoid patching heavily
61 ifeq ($(BR2_PACKAGE_PHP_EXT_OPCACHE),y)
62 PHP_CONF_OPTS += --enable-opcache
63 PHP_CONF_ENV += ac_cv_func_mprotect=yes
64 PHP_CFLAGS += \
65 -DHAVE_SHM_IPC \
66 -DHAVE_SHM_MMAP_ANON \
67 -DHAVE_SHM_MMAP_ZERO \
68 -DHAVE_SHM_MMAP_POSIX \
69 -DHAVE_SHM_MMAP_FILE
70 endif
72 # We need to force dl "detection"
73 ifeq ($(BR2_STATIC_LIBS),)
74 PHP_CONF_ENV += ac_cv_func_dlopen=yes ac_cv_lib_dl_dlopen=yes
75 PHP_EXTRA_LIBS += -ldl
76 else
77 PHP_CONF_ENV += ac_cv_func_dlopen=no ac_cv_lib_dl_dlopen=no
78 endif
80 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CLI),--enable-cli,--disable-cli)
81 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CGI),--enable-cgi,--disable-cgi)
82 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_FPM),--enable-fpm,--disable-fpm)
84 ifeq ($(BR2_PACKAGE_PHP_SAPI_APACHE),y)
85 PHP_DEPENDENCIES += apache
86 PHP_CONF_OPTS += --with-apxs2=$(STAGING_DIR)/usr/bin/apxs
88 # Enable thread safety option if Apache MPM is event or worker
89 ifeq ($(BR2_PACKAGE_APACHE_MPM_EVENT)$(BR2_PACKAGE_APACHE_MPM_WORKER),y)
90 PHP_CONF_OPTS += --enable-maintainer-zts
91 endif
92 endif
94 ### Extensions
95 PHP_CONF_OPTS += \
96 $(if $(BR2_PACKAGE_PHP_EXT_SOCKETS),--enable-sockets) \
97 $(if $(BR2_PACKAGE_PHP_EXT_POSIX),--enable-posix) \
98 $(if $(BR2_PACKAGE_PHP_EXT_SESSION),--enable-session) \
99 $(if $(BR2_PACKAGE_PHP_EXT_HASH),--enable-hash) \
100 $(if $(BR2_PACKAGE_PHP_EXT_DOM),--enable-dom) \
101 $(if $(BR2_PACKAGE_PHP_EXT_SIMPLEXML),--enable-simplexml) \
102 $(if $(BR2_PACKAGE_PHP_EXT_SOAP),--enable-soap) \
103 $(if $(BR2_PACKAGE_PHP_EXT_XML),--enable-xml) \
104 $(if $(BR2_PACKAGE_PHP_EXT_XMLREADER),--enable-xmlreader) \
105 $(if $(BR2_PACKAGE_PHP_EXT_XMLWRITER),--enable-xmlwriter) \
106 $(if $(BR2_PACKAGE_PHP_EXT_EXIF),--enable-exif) \
107 $(if $(BR2_PACKAGE_PHP_EXT_FTP),--enable-ftp) \
108 $(if $(BR2_PACKAGE_PHP_EXT_JSON),--enable-json) \
109 $(if $(BR2_PACKAGE_PHP_EXT_TOKENIZER),--enable-tokenizer) \
110 $(if $(BR2_PACKAGE_PHP_EXT_PCNTL),--enable-pcntl) \
111 $(if $(BR2_PACKAGE_PHP_EXT_SHMOP),--enable-shmop) \
112 $(if $(BR2_PACKAGE_PHP_EXT_SYSVMSG),--enable-sysvmsg) \
113 $(if $(BR2_PACKAGE_PHP_EXT_SYSVSEM),--enable-sysvsem) \
114 $(if $(BR2_PACKAGE_PHP_EXT_SYSVSHM),--enable-sysvshm) \
115 $(if $(BR2_PACKAGE_PHP_EXT_ZIP),--enable-zip) \
116 $(if $(BR2_PACKAGE_PHP_EXT_CTYPE),--enable-ctype) \
117 $(if $(BR2_PACKAGE_PHP_EXT_FILTER),--enable-filter) \
118 $(if $(BR2_PACKAGE_PHP_EXT_CALENDAR),--enable-calendar) \
119 $(if $(BR2_PACKAGE_PHP_EXT_FILEINFO),--enable-fileinfo) \
120 $(if $(BR2_PACKAGE_PHP_EXT_BCMATH),--enable-bcmath) \
121 $(if $(BR2_PACKAGE_PHP_EXT_MBSTRING),--enable-mbstring) \
122 $(if $(BR2_PACKAGE_PHP_EXT_PHAR),--enable-phar)
124 ifeq ($(BR2_PACKAGE_PHP_EXT_MCRYPT),y)
125 PHP_CONF_OPTS += --with-mcrypt=$(STAGING_DIR)/usr
126 PHP_DEPENDENCIES += libmcrypt
127 endif
129 ifeq ($(BR2_PACKAGE_PHP_EXT_OPENSSL),y)
130 PHP_CONF_OPTS += --with-openssl=$(STAGING_DIR)/usr
131 PHP_DEPENDENCIES += openssl
132 # openssl needs zlib, but the configure script forgets to link against
133 # it causing detection failures with static linking
134 PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs openssl`
135 endif
137 ifeq ($(BR2_PACKAGE_PHP_EXT_LIBXML2),y)
138 PHP_CONF_ENV += php_cv_libxml_build_works=yes
139 PHP_CONF_OPTS += --enable-libxml --with-libxml-dir=${STAGING_DIR}/usr
140 PHP_DEPENDENCIES += libxml2
141 endif
143 ifeq ($(BR2_PACKAGE_PHP_EXT_WDDX),y)
144 PHP_CONF_OPTS += --enable-wddx --with-libexpat-dir=$(STAGING_DIR)/usr
145 PHP_DEPENDENCIES += expat
146 endif
148 ifeq ($(BR2_PACKAGE_PHP_EXT_XMLRPC),y)
149 PHP_CONF_OPTS += \
150 --with-xmlrpc \
151 $(if $(BR2_PACKAGE_LIBICONV),--with-iconv-dir=$(STAGING_DIR)/usr)
152 PHP_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv)
153 endif
155 ifneq ($(BR2_PACKAGE_PHP_EXT_ZLIB)$(BR2_PACKAGE_PHP_EXT_ZIP),)
156 PHP_CONF_OPTS += --with-zlib=$(STAGING_DIR)/usr
157 PHP_DEPENDENCIES += zlib
158 endif
160 ifeq ($(BR2_PACKAGE_PHP_EXT_GETTEXT),y)
161 PHP_CONF_OPTS += --with-gettext=$(STAGING_DIR)/usr
162 PHP_DEPENDENCIES += $(if $(BR2_NEEDS_GETTEXT),gettext)
163 endif
165 ifeq ($(BR2_PACKAGE_PHP_EXT_ICONV),y)
166 ifeq ($(BR2_PACKAGE_LIBICONV),y)
167 PHP_CONF_OPTS += --with-iconv=$(STAGING_DIR)/usr
168 PHP_DEPENDENCIES += libiconv
169 else
170 PHP_CONF_OPTS += --with-iconv
171 endif
172 endif
174 ifeq ($(BR2_PACKAGE_PHP_EXT_INTL),y)
175 PHP_CONF_OPTS += --enable-intl --with-icu-dir=$(STAGING_DIR)/usr
176 PHP_DEPENDENCIES += icu
177 # The intl module is implemented in C++, but PHP fails to use
178 # g++ as the compiler for the final link. As a workaround,
179 # tell it to link libstdc++.
180 PHP_EXTRA_LIBS += -lstdc++
181 endif
183 ifeq ($(BR2_PACKAGE_PHP_EXT_GMP),y)
184 PHP_CONF_OPTS += --with-gmp=$(STAGING_DIR)/usr
185 PHP_DEPENDENCIES += gmp
186 endif
188 ifeq ($(BR2_PACKAGE_PHP_EXT_READLINE),y)
189 PHP_CONF_OPTS += --with-readline=$(STAGING_DIR)/usr
190 PHP_DEPENDENCIES += readline
191 endif
193 ### Native SQL extensions
194 ifeq ($(BR2_PACKAGE_PHP_EXT_MYSQLI),y)
195 PHP_CONF_OPTS += --with-mysqli
196 endif
197 ifeq ($(BR2_PACKAGE_PHP_EXT_SQLITE),y)
198 PHP_CONF_OPTS += --with-sqlite3=$(STAGING_DIR)/usr
199 PHP_DEPENDENCIES += sqlite
200 PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs sqlite3`
201 endif
203 ### PDO
204 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO),y)
205 PHP_CONF_OPTS += --enable-pdo
206 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_SQLITE),y)
207 PHP_CONF_OPTS += --with-pdo-sqlite=$(STAGING_DIR)/usr
208 PHP_DEPENDENCIES += sqlite
209 PHP_CFLAGS += -DSQLITE_OMIT_LOAD_EXTENSION
210 endif
211 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),y)
212 PHP_CONF_OPTS += --with-pdo-mysql
213 endif
214 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_POSTGRESQL),y)
215 PHP_CONF_OPTS += --with-pdo-pgsql=$(STAGING_DIR)/usr
216 PHP_DEPENDENCIES += postgresql
217 endif
218 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_UNIXODBC),y)
219 PHP_CONF_OPTS += --with-pdo-odbc=unixODBC,$(STAGING_DIR)/usr
220 PHP_DEPENDENCIES += unixodbc
221 endif
222 endif
224 ifneq ($(BR2_PACKAGE_PHP_EXT_MYSQLI)$(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),)
225 # Set default MySQL unix socket to what the MySQL server is using by default
226 PHP_CONF_OPTS += --with-mysql-sock=$(MYSQL_SOCKET)
227 endif
229 define PHP_DISABLE_PCRE_JIT
230 $(SED) '/^#define SUPPORT_JIT/d' $(@D)/ext/pcre/pcrelib/config.h
231 endef
233 ### Use external PCRE if it's available
234 ifeq ($(BR2_PACKAGE_PCRE),y)
235 PHP_CONF_OPTS += --with-pcre-regex=$(STAGING_DIR)/usr
236 PHP_DEPENDENCIES += pcre
237 else
238 # The bundled pcre library is not configurable through ./configure options,
239 # and by default is configured to be thread-safe, so it wants pthreads. So
240 # we must explicitly tell it when we don't have threads.
241 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),)
242 PHP_CFLAGS += -DSLJIT_SINGLE_THREADED=1
243 endif
244 # check ext/pcre/pcrelib/sljit/sljitConfigInternal.h for supported archs
245 ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb)$(BR2_aarch64)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),)
246 PHP_POST_CONFIGURE_HOOKS += PHP_DISABLE_PCRE_JIT
247 endif
248 endif
250 ifeq ($(BR2_PACKAGE_PHP_EXT_CURL),y)
251 PHP_CONF_OPTS += --with-curl=$(STAGING_DIR)/usr
252 PHP_DEPENDENCIES += libcurl
253 endif
255 ifeq ($(BR2_PACKAGE_PHP_EXT_XSL),y)
256 PHP_CONF_OPTS += --with-xsl=$(STAGING_DIR)/usr
257 PHP_DEPENDENCIES += libxslt
258 endif
260 ifeq ($(BR2_PACKAGE_PHP_EXT_BZIP2),y)
261 PHP_CONF_OPTS += --with-bz2=$(STAGING_DIR)/usr
262 PHP_DEPENDENCIES += bzip2
263 endif
265 ### DBA
266 ifeq ($(BR2_PACKAGE_PHP_EXT_DBA),y)
267 PHP_CONF_OPTS += --enable-dba
268 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_CDB),y)
269 PHP_CONF_OPTS += --without-cdb
270 endif
271 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_FLAT),y)
272 PHP_CONF_OPTS += --without-flatfile
273 endif
274 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_INI),y)
275 PHP_CONF_OPTS += --without-inifile
276 endif
277 ifeq ($(BR2_PACKAGE_PHP_EXT_DBA_DB4),y)
278 PHP_CONF_OPTS += --with-db4=$(STAGING_DIR)/usr
279 PHP_DEPENDENCIES += berkeleydb
280 endif
281 endif
283 ifeq ($(BR2_PACKAGE_PHP_EXT_SNMP),y)
284 PHP_CONF_OPTS += --with-snmp=$(STAGING_DIR)/usr
285 PHP_DEPENDENCIES += netsnmp
286 endif
288 ifeq ($(BR2_PACKAGE_PHP_EXT_GD),y)
289 PHP_CONF_OPTS += \
290 --with-gd \
291 --with-jpeg-dir=$(STAGING_DIR)/usr \
292 --with-png-dir=$(STAGING_DIR)/usr \
293 --with-zlib-dir=$(STAGING_DIR)/usr \
294 --with-freetype-dir=$(STAGING_DIR)/usr
295 PHP_DEPENDENCIES += jpeg libpng freetype
296 endif
298 ifeq ($(BR2_PACKAGE_PHP_SAPI_FPM),y)
299 define PHP_INSTALL_INIT_SYSV
300 $(INSTALL) -D -m 0755 $(@D)/sapi/fpm/init.d.php-fpm \
301 $(TARGET_DIR)/etc/init.d/S49php-fpm
302 endef
304 define PHP_INSTALL_INIT_SYSTEMD
305 $(INSTALL) -D -m 0644 $(@D)/sapi/fpm/php-fpm.service \
306 $(TARGET_DIR)/usr/lib/systemd/system/php-fpm.service
307 mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
308 ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
309 $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
310 endef
312 define PHP_INSTALL_FPM_CONF
313 $(INSTALL) -D -m 0644 package/php/php-fpm.conf \
314 $(TARGET_DIR)/etc/php-fpm.conf
315 rm -f $(TARGET_DIR)/etc/php-fpm.conf.default
316 # remove unused sample status page /usr/php/php/fpm/status.html
317 rm -rf $(TARGET_DIR)/usr/php
318 endef
320 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FPM_CONF
321 endif
323 define PHP_EXTENSIONS_FIXUP
324 $(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
325 $(STAGING_DIR)/usr/bin/phpize
326 $(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
327 $(STAGING_DIR)/usr/bin/php-config
328 endef
330 PHP_POST_INSTALL_TARGET_HOOKS += PHP_EXTENSIONS_FIXUP
332 define PHP_INSTALL_FIXUP
333 rm -rf $(TARGET_DIR)/usr/lib/php/build
334 rm -f $(TARGET_DIR)/usr/bin/phpize
335 $(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
336 $(TARGET_DIR)/etc/php.ini
337 $(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
338 $(TARGET_DIR)/etc/php.ini
339 $(if $(BR2_PACKAGE_PHP_EXT_OPCACHE),
340 $(SED) '/;extension=php_xsl.dll/azend_extension=opcache.so' \
341 $(TARGET_DIR)/etc/php.ini)
342 endef
344 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FIXUP
346 PHP_CONF_ENV += CFLAGS="$(PHP_CFLAGS)"
348 $(eval $(autotools-package))