1 ################################################################################
5 ################################################################################
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
15 PHP_LICENSE_FILES
= LICENSE
17 --mandir=/usr
/share
/man \
18 --infodir=/usr
/share
/info \
21 --with-config-file-path
=/etc \
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)"
32 ifeq ($(BR2_STATIC_LIBS
)$(BR2_TOOLCHAIN_HAS_THREADS
),yy
)
33 PHP_STATIC_LIBS
+= -lpthread
36 ifeq ($(call qstrip
,$(BR2_TARGET_LOCALTIME
)),)
39 # Not q-stripping this value, as we need quotes in the php.ini file
40 PHP_LOCALTIME
= $(BR2_TARGET_LOCALTIME
)
43 # PHP can't be AUTORECONFed the standard way unfortunately
44 PHP_DEPENDENCIES
+= host-autoconf host-automake host-libtool
46 cd
$(@D
) ; $(TARGET_MAKE_ENV
) .
/buildconf
--force
48 PHP_PRE_CONFIGURE_HOOKS
+= PHP_BUILDCONF
50 ifeq ($(BR2_ENDIAN
),"BIG")
51 PHP_CONF_ENV
+= ac_cv_c_bigendian_php
=yes
53 PHP_CONF_ENV
+= ac_cv_c_bigendian_php
=no
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
66 -DHAVE_SHM_MMAP_ANON \
67 -DHAVE_SHM_MMAP_ZERO \
68 -DHAVE_SHM_MMAP_POSIX \
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
77 PHP_CONF_ENV
+= ac_cv_func_dlopen
=no ac_cv_lib_dl_dlopen
=no
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
)
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
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`
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
133 ifeq ($(BR2_PACKAGE_PHP_EXT_WDDX
),y
)
134 PHP_CONF_OPTS
+= --enable-wddx
--with-libexpat-dir
=$(STAGING_DIR
)/usr
135 PHP_DEPENDENCIES
+= expat
138 ifeq ($(BR2_PACKAGE_PHP_EXT_XMLRPC
),y
)
141 $(if
$(BR2_PACKAGE_LIBICONV
),--with-iconv-dir
=$(STAGING_DIR
)/usr
)
142 PHP_DEPENDENCIES
+= $(if
$(BR2_PACKAGE_LIBICONV
),libiconv
)
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
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
)
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
160 PHP_CONF_OPTS
+= --with-iconv
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
++
173 ifeq ($(BR2_PACKAGE_PHP_EXT_GMP
),y
)
174 PHP_CONF_OPTS
+= --with-gmp
=$(STAGING_DIR
)/usr
175 PHP_DEPENDENCIES
+= gmp
178 ifeq ($(BR2_PACKAGE_PHP_EXT_READLINE
),y
)
179 PHP_CONF_OPTS
+= --with-readline
=$(STAGING_DIR
)/usr
180 PHP_DEPENDENCIES
+= readline
183 ### Native SQL extensions
184 ifeq ($(BR2_PACKAGE_PHP_EXT_MYSQLI
),y
)
185 PHP_CONF_OPTS
+= --with-mysqli
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`
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
201 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_MYSQL
),y
)
202 PHP_CONF_OPTS
+= --with-pdo-mysql
204 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_POSTGRESQL
),y
)
205 PHP_CONF_OPTS
+= --with-pdo-pgsql
=$(STAGING_DIR
)/usr
206 PHP_DEPENDENCIES
+= postgresql
208 ifeq ($(BR2_PACKAGE_PHP_EXT_PDO_UNIXODBC
),y
)
209 PHP_CONF_OPTS
+= --with-pdo-odbc
=unixODBC
,$(STAGING_DIR
)/usr
210 PHP_DEPENDENCIES
+= unixodbc
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
)
219 define PHP_DISABLE_PCRE_JIT
220 $(SED
) '/^#define SUPPORT_JIT/d' $(@D
)/ext
/pcre
/pcrelib
/config.h
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
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
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
240 ifeq ($(BR2_PACKAGE_PHP_EXT_CURL
),y
)
241 PHP_CONF_OPTS
+= --with-curl
=$(STAGING_DIR
)/usr
242 PHP_DEPENDENCIES
+= libcurl
245 ifeq ($(BR2_PACKAGE_PHP_EXT_XSL
),y
)
246 PHP_CONF_OPTS
+= --with-xsl
=$(STAGING_DIR
)/usr
247 PHP_DEPENDENCIES
+= libxslt
250 ifeq ($(BR2_PACKAGE_PHP_EXT_BZIP2
),y
)
251 PHP_CONF_OPTS
+= --with-bz2
=$(STAGING_DIR
)/usr
252 PHP_DEPENDENCIES
+= bzip2
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
261 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_FLAT
),y
)
262 PHP_CONF_OPTS
+= --without-flatfile
264 ifneq ($(BR2_PACKAGE_PHP_EXT_DBA_INI
),y
)
265 PHP_CONF_OPTS
+= --without-inifile
267 ifeq ($(BR2_PACKAGE_PHP_EXT_DBA_DB4
),y
)
268 PHP_CONF_OPTS
+= --with-db4
=$(STAGING_DIR
)/usr
269 PHP_DEPENDENCIES
+= berkeleydb
273 ifeq ($(BR2_PACKAGE_PHP_EXT_SNMP
),y
)
274 PHP_CONF_OPTS
+= --with-snmp
=$(STAGING_DIR
)/usr
275 PHP_DEPENDENCIES
+= netsnmp
278 ifeq ($(BR2_PACKAGE_PHP_EXT_GD
),y
)
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
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
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
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
310 PHP_POST_INSTALL_TARGET_HOOKS
+= PHP_INSTALL_FPM_CONF
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
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
)
334 PHP_POST_INSTALL_TARGET_HOOKS
+= PHP_INSTALL_FIXUP
336 PHP_CONF_ENV
+= CFLAGS
="$(PHP_CFLAGS)"
338 $(eval
$(autotools-package
))