website: update Free Electrons logo
[buildroot-gz.git] / package / php / php.mk
blobf925ec1eba3bbd9094a65873e55afe5075fd6cb1
1 ################################################################################
3 # php
5 ################################################################################
7 PHP_VERSION = 7.0.12
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_CLI),,--disable-cli)
81 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_CGI),,--disable-cgi)
82 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_FPM),--enable-fpm,--disable-fpm)
84 ### Extensions
85 PHP_CONF_OPTS += \
86 $(if $(BR2_PACKAGE_PHP_EXT_SOCKETS),--enable-sockets) \
87 $(if $(BR2_PACKAGE_PHP_EXT_POSIX),--enable-posix) \
88 $(if $(BR2_PACKAGE_PHP_EXT_SESSION),--enable-session) \
89 $(if $(BR2_PACKAGE_PHP_EXT_HASH),--enable-hash) \
90 $(if $(BR2_PACKAGE_PHP_EXT_DOM),--enable-dom) \
91 $(if $(BR2_PACKAGE_PHP_EXT_SIMPLEXML),--enable-simplexml) \
92 $(if $(BR2_PACKAGE_PHP_EXT_SOAP),--enable-soap) \
93 $(if $(BR2_PACKAGE_PHP_EXT_XML),--enable-xml) \
94 $(if $(BR2_PACKAGE_PHP_EXT_XMLREADER),--enable-xmlreader) \
95 $(if $(BR2_PACKAGE_PHP_EXT_XMLWRITER),--enable-xmlwriter) \
96 $(if $(BR2_PACKAGE_PHP_EXT_EXIF),--enable-exif) \
97 $(if $(BR2_PACKAGE_PHP_EXT_FTP),--enable-ftp) \
98 $(if $(BR2_PACKAGE_PHP_EXT_JSON),--enable-json) \
99 $(if $(BR2_PACKAGE_PHP_EXT_TOKENIZER),--enable-tokenizer) \
100 $(if $(BR2_PACKAGE_PHP_EXT_PCNTL),--enable-pcntl) \
101 $(if $(BR2_PACKAGE_PHP_EXT_SHMOP),--enable-shmop) \
102 $(if $(BR2_PACKAGE_PHP_EXT_SYSVMSG),--enable-sysvmsg) \
103 $(if $(BR2_PACKAGE_PHP_EXT_SYSVSEM),--enable-sysvsem) \
104 $(if $(BR2_PACKAGE_PHP_EXT_SYSVSHM),--enable-sysvshm) \
105 $(if $(BR2_PACKAGE_PHP_EXT_ZIP),--enable-zip) \
106 $(if $(BR2_PACKAGE_PHP_EXT_CTYPE),--enable-ctype) \
107 $(if $(BR2_PACKAGE_PHP_EXT_FILTER),--enable-filter) \
108 $(if $(BR2_PACKAGE_PHP_EXT_CALENDAR),--enable-calendar) \
109 $(if $(BR2_PACKAGE_PHP_EXT_FILEINFO),--enable-fileinfo) \
110 $(if $(BR2_PACKAGE_PHP_EXT_BCMATH),--enable-bcmath) \
111 $(if $(BR2_PACKAGE_PHP_EXT_MBSTRING),--enable-mbstring) \
112 $(if $(BR2_PACKAGE_PHP_EXT_PHAR),--enable-phar)
114 ifeq ($(BR2_PACKAGE_PHP_EXT_MCRYPT),y)
115 PHP_CONF_OPTS += --with-mcrypt=$(STAGING_DIR)/usr
116 PHP_DEPENDENCIES += libmcrypt
117 endif
119 ifeq ($(BR2_PACKAGE_PHP_EXT_OPENSSL),y)
120 PHP_CONF_OPTS += --with-openssl=$(STAGING_DIR)/usr
121 PHP_DEPENDENCIES += openssl
122 # openssl needs zlib, but the configure script forgets to link against
123 # it causing detection failures with static linking
124 PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs openssl`
125 endif
127 ifeq ($(BR2_PACKAGE_PHP_EXT_LIBXML2),y)
128 PHP_CONF_ENV += php_cv_libxml_build_works=yes
129 PHP_CONF_OPTS += --enable-libxml --with-libxml-dir=${STAGING_DIR}/usr
130 PHP_DEPENDENCIES += libxml2
131 endif
133 ifeq ($(BR2_PACKAGE_PHP_EXT_WDDX),y)
134 PHP_CONF_OPTS += --enable-wddx --with-libexpat-dir=$(STAGING_DIR)/usr
135 PHP_DEPENDENCIES += expat
136 endif
138 ifeq ($(BR2_PACKAGE_PHP_EXT_XMLRPC),y)
139 PHP_CONF_OPTS += \
140 --with-xmlrpc \
141 $(if $(BR2_PACKAGE_LIBICONV),--with-iconv-dir=$(STAGING_DIR)/usr)
142 PHP_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv)
143 endif
145 ifneq ($(BR2_PACKAGE_PHP_EXT_ZLIB)$(BR2_PACKAGE_PHP_EXT_ZIP),)
146 PHP_CONF_OPTS += --with-zlib=$(STAGING_DIR)/usr
147 PHP_DEPENDENCIES += zlib
148 endif
150 ifeq ($(BR2_PACKAGE_PHP_EXT_GETTEXT),y)
151 PHP_CONF_OPTS += --with-gettext=$(STAGING_DIR)/usr
152 PHP_DEPENDENCIES += $(if $(BR2_NEEDS_GETTEXT),gettext)
153 endif
155 ifeq ($(BR2_PACKAGE_PHP_EXT_ICONV),y)
156 ifeq ($(BR2_PACKAGE_LIBICONV),y)
157 PHP_CONF_OPTS += --with-iconv=$(STAGING_DIR)/usr
158 PHP_DEPENDENCIES += libiconv
159 else
160 PHP_CONF_OPTS += --with-iconv
161 endif
162 endif
164 ifeq ($(BR2_PACKAGE_PHP_EXT_INTL),y)
165 PHP_CONF_OPTS += --enable-intl --with-icu-dir=$(STAGING_DIR)/usr
166 PHP_DEPENDENCIES += icu
167 # The intl module is implemented in C++, but PHP fails to use
168 # g++ as the compiler for the final link. As a workaround,
169 # tell it to link libstdc++.
170 PHP_EXTRA_LIBS += -lstdc++
171 endif
173 ifeq ($(BR2_PACKAGE_PHP_EXT_GMP),y)
174 PHP_CONF_OPTS += --with-gmp=$(STAGING_DIR)/usr
175 PHP_DEPENDENCIES += gmp
176 endif
178 ifeq ($(BR2_PACKAGE_PHP_EXT_READLINE),y)
179 PHP_CONF_OPTS += --with-readline=$(STAGING_DIR)/usr
180 PHP_DEPENDENCIES += readline
181 endif
183 ### Native SQL extensions
184 ifeq ($(BR2_PACKAGE_PHP_EXT_MYSQLI),y)
185 PHP_CONF_OPTS += --with-mysqli
186 endif
187 ifeq ($(BR2_PACKAGE_PHP_EXT_SQLITE),y)
188 PHP_CONF_OPTS += --with-sqlite3=$(STAGING_DIR)/usr
189 PHP_DEPENDENCIES += sqlite
190 PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs sqlite3`
191 endif
193 ### PDO
194 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO),y)
195 PHP_CONF_OPTS += --enable-pdo
196 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_SQLITE),y)
197 PHP_CONF_OPTS += --with-pdo-sqlite=$(STAGING_DIR)/usr
198 PHP_DEPENDENCIES += sqlite
199 PHP_CFLAGS += -DSQLITE_OMIT_LOAD_EXTENSION
200 endif
201 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),y)
202 PHP_CONF_OPTS += --with-pdo-mysql
203 endif
204 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_POSTGRESQL),y)
205 PHP_CONF_OPTS += --with-pdo-pgsql=$(STAGING_DIR)/usr
206 PHP_DEPENDENCIES += postgresql
207 endif
208 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_UNIXODBC),y)
209 PHP_CONF_OPTS += --with-pdo-odbc=unixODBC,$(STAGING_DIR)/usr
210 PHP_DEPENDENCIES += unixodbc
211 endif
212 endif
214 ifneq ($(BR2_PACKAGE_PHP_EXT_MYSQLI)$(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),)
215 # Set default MySQL unix socket to what the MySQL server is using by default
216 PHP_CONF_OPTS += --with-mysql-sock=$(MYSQL_SOCKET)
217 endif
219 define PHP_DISABLE_PCRE_JIT
220 $(SED) '/^#define SUPPORT_JIT/d' $(@D)/ext/pcre/pcrelib/config.h
221 endef
223 ### Use external PCRE if it's available
224 ifeq ($(BR2_PACKAGE_PCRE),y)
225 PHP_CONF_OPTS += --with-pcre-regex=$(STAGING_DIR)/usr
226 PHP_DEPENDENCIES += pcre
227 else
228 # The bundled pcre library is not configurable through ./configure options,
229 # and by default is configured to be thread-safe, so it wants pthreads. So
230 # we must explicitly tell it when we don't have threads.
231 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),)
232 PHP_CFLAGS += -DSLJIT_SINGLE_THREADED=1
233 endif
234 # check ext/pcre/pcrelib/sljit/sljitConfigInternal.h for supported archs
235 ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb)$(BR2_aarch64)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),)
236 PHP_POST_CONFIGURE_HOOKS += PHP_DISABLE_PCRE_JIT
237 endif
238 endif
240 ifeq ($(BR2_PACKAGE_PHP_EXT_CURL),y)
241 PHP_CONF_OPTS += --with-curl=$(STAGING_DIR)/usr
242 PHP_DEPENDENCIES += libcurl
243 endif
245 ifeq ($(BR2_PACKAGE_PHP_EXT_XSL),y)
246 PHP_CONF_OPTS += --with-xsl=$(STAGING_DIR)/usr
247 PHP_DEPENDENCIES += libxslt
248 endif
250 ifeq ($(BR2_PACKAGE_PHP_EXT_BZIP2),y)
251 PHP_CONF_OPTS += --with-bz2=$(STAGING_DIR)/usr
252 PHP_DEPENDENCIES += bzip2
253 endif
255 ### DBA
256 ifeq ($(BR2_PACKAGE_PHP_EXT_DBA),y)
257 PHP_CONF_OPTS += --enable-dba
258 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_CDB),y)
259 PHP_CONF_OPTS += --without-cdb
260 endif
261 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_FLAT),y)
262 PHP_CONF_OPTS += --without-flatfile
263 endif
264 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_INI),y)
265 PHP_CONF_OPTS += --without-inifile
266 endif
267 ifeq ($(BR2_PACKAGE_PHP_EXT_DBA_DB4),y)
268 PHP_CONF_OPTS += --with-db4=$(STAGING_DIR)/usr
269 PHP_DEPENDENCIES += berkeleydb
270 endif
271 endif
273 ifeq ($(BR2_PACKAGE_PHP_EXT_SNMP),y)
274 PHP_CONF_OPTS += --with-snmp=$(STAGING_DIR)/usr
275 PHP_DEPENDENCIES += netsnmp
276 endif
278 ifeq ($(BR2_PACKAGE_PHP_EXT_GD),y)
279 PHP_CONF_OPTS += \
280 --with-gd \
281 --with-jpeg-dir=$(STAGING_DIR)/usr \
282 --with-png-dir=$(STAGING_DIR)/usr \
283 --with-zlib-dir=$(STAGING_DIR)/usr \
284 --with-freetype-dir=$(STAGING_DIR)/usr
285 PHP_DEPENDENCIES += jpeg libpng freetype
286 endif
288 ifeq ($(BR2_PACKAGE_PHP_FPM),y)
289 define PHP_INSTALL_INIT_SYSV
290 $(INSTALL) -D -m 0755 $(@D)/sapi/fpm/init.d.php-fpm \
291 $(TARGET_DIR)/etc/init.d/S49php-fpm
292 endef
294 define PHP_INSTALL_INIT_SYSTEMD
295 $(INSTALL) -D -m 0644 $(@D)/sapi/fpm/php-fpm.service \
296 $(TARGET_DIR)/usr/lib/systemd/system/php-fpm.service
297 mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
298 ln -fs ../../../../usr/lib/systemd/system/php-fpm.service \
299 $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/php-fpm.service
300 endef
302 define PHP_INSTALL_FPM_CONF
303 $(INSTALL) -D -m 0644 package/php/php-fpm.conf \
304 $(TARGET_DIR)/etc/php-fpm.conf
305 rm -f $(TARGET_DIR)/etc/php-fpm.conf.default
306 # remove unused sample status page /usr/php/php/fpm/status.html
307 rm -rf $(TARGET_DIR)/usr/php
308 endef
310 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FPM_CONF
311 endif
313 define PHP_EXTENSIONS_FIXUP
314 $(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
315 $(STAGING_DIR)/usr/bin/phpize
316 $(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
317 $(STAGING_DIR)/usr/bin/php-config
318 endef
320 PHP_POST_INSTALL_TARGET_HOOKS += PHP_EXTENSIONS_FIXUP
322 define PHP_INSTALL_FIXUP
323 rm -rf $(TARGET_DIR)/usr/lib/php/build
324 rm -f $(TARGET_DIR)/usr/bin/phpize
325 $(INSTALL) -D -m 0755 $(PHP_DIR)/php.ini-production \
326 $(TARGET_DIR)/etc/php.ini
327 $(SED) 's%;date.timezone =.*%date.timezone = $(PHP_LOCALTIME)%' \
328 $(TARGET_DIR)/etc/php.ini
329 $(if $(BR2_PACKAGE_PHP_EXT_OPCACHE),
330 $(SED) '/;extension=php_xsl.dll/azend_extension=opcache.so' \
331 $(TARGET_DIR)/etc/php.ini)
332 endef
334 PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FIXUP
336 PHP_CONF_ENV += CFLAGS="$(PHP_CFLAGS)"
338 $(eval $(autotools-package))