[package] php5: add missing dependency on libsqlite3/libpthread (#7224)
[packages.git] / lang / php5 / Makefile
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=php
11 PKG_VERSION:=5.3.4
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:=http://www.php.net/distributions/
16 PKG_MD5SUM:=2c069d8f690933e3bf6a8741ed818150
17
18 PKG_FIXUP:=libtool no-autoreconf
19 PKG_BUILD_PARALLEL:=1 
20
21 include $(INCLUDE_DIR)/package.mk
22 include $(INCLUDE_DIR)/nls.mk
23
24 define Package/php5/Default
25   SUBMENU:=PHP
26   SECTION:=lang
27   CATEGORY:=Languages
28   TITLE:=PHP5 Hypertext preprocessor
29   URL:=http://www.php.net/
30 endef
31
32 define Package/php5/Default/description
33   PHP is a widely-used general-purpose scripting language that is especially 
34   suited for Web development and can be embedded into HTML.
35 endef
36
37 define Package/php5/config
38         config PHP5_APC
39                 bool "PHP5 APC support"
40                 depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
41
42         config PHP5_FILTER
43                 bool "PHP5 Filter support"
44                 depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
45
46         config PHP5_LIBXML
47                 bool "PHP5 LIBXML support"
48                 depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
49 endef
50
51 define Package/php5
52   $(call Package/php5/Default)
53   DEPENDS:=+libpcre +zlib
54   ifneq ($(CONFIG_PHP5_LIBXML),)
55     DEPENDS+= +libxml2
56   endif
57   ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite3)$(CONFIG_PACKAGE_php5-mod-pdo-sqlite),)
58     DEPENDS+= +libsqlite3 +libpthread
59   endif
60 endef
61
62 define Package/php5/description
63   $(call Package/php5/Default/description)
64   This package contains only the PHP config file. You must actually choose 
65   your PHP flavour (cli, cgi or fastcgi).
66 endef
67
68 define Package/php5-cli
69   $(call Package/php5/Default)
70   DEPENDS:=php5
71   TITLE+= (CLI)
72 endef
73
74 define Package/php5-cli/description
75   (call Package/php5/Default/description)
76   This package contains the CLI version of the PHP5 interpreter.
77 endef
78
79 define Package/php5-cgi
80   $(call Package/php5/Default)
81   DEPENDS:=php5
82   TITLE+= (CGI & FastCGI)
83 endef
84
85 define Package/php5-cgi/description
86   $(call Package/php5/Default/description)
87   This package contains the CGI version of the PHP5 interpreter.
88 endef
89
90 define Package/php5-fastcgi
91   $(call Package/php5/Default)
92   DEPENDS:=php5 +php5-cgi
93   TITLE:=FastCGI startup script
94 endef
95
96 define Package/php5-cgi/description
97    As FastCGI support is now a core feature the php5-fastcgi package now depends
98    on the php5-cgi package, containing just the startup script.
99 endef
100
101 CONFIGURE_VARS += \
102         ac_cv_c_bigendian_php=$(if $(CONFIG_BIG_ENDIAN),yes,no)
103
104 PKG_CONFIGURE_OPTS:= \
105         --enable-shared \
106         --disable-static \
107         --disable-rpath \
108         --disable-debug \
109         --without-pear \
110         \
111         --with-config-file-path=/etc \
112         --with-config-file-scan-dir=/etc/php5 \
113         --enable-magic-quotes \
114         --disable-short-tags \
115         \
116         --without-gettext \
117         --disable-simplexml \
118         --with-zlib="$(STAGING_DIR)/usr" \
119           --with-zlib-dir="$(STAGING_DIR)/usr" \
120         --with-pcre-regex="$(STAGING_DIR)/usr" \
121         --disable-phar
122
123 ifneq ($(SDK),)
124   PKG_BUILD_DEPENDS+=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libsqlite2 libpthread libsqlite3 libpcre libxml2
125 # force PKG_CONFIGURE_{LIBS,OPTS} below when built in the SDK
126   CONFIG_PACKAGE_php5-cli:=m
127   CONFIG_PACKAGE_php5-cgi:=m
128   CONFIG_PACKAGE_php5-fastcgi:=m
129   CONFIG_PACKAGE_php5-mod-curl:=m
130   CONFIG_PACKAGE_php5-mod-gd:=m
131   CONFIG_PACKAGE_php5-mod-gmp:=m
132   CONFIG_PACKAGE_php5-mod-ldap:=m
133   CONFIG_PACKAGE_php5-mod-mysql:=m
134   CONFIG_PACKAGE_php5-mod-pgsql:=m
135   CONFIG_PACKAGE_php5-mod-sqlite:=m
136   CONFIG_PACKAGE_php5-mod-sqlite3:=m
137   CONFIG_PACKAGE_php5-mod-xml:=m
138 endif
139
140 ifneq ($(CONFIG_PACKAGE_php5-mod-ctype),)
141   PKG_CONFIGURE_OPTS+= --enable-ctype=shared
142 else
143   PKG_CONFIGURE_OPTS+= --disable-ctype
144 endif
145
146 ifneq ($(CONFIG_PACKAGE_php5-mod-curl),)
147   PKG_CONFIGURE_OPTS+= --with-curl=shared,"$(STAGING_DIR)/usr"
148 else
149   PKG_CONFIGURE_OPTS+= --without-curl
150 endif
151
152 ifneq ($(CONFIG_PACKAGE_php5-mod-fileinfo),)
153   PKG_CONFIGURE_OPTS+= --enable-fileinfo=shared
154 else
155   PKG_CONFIGURE_OPTS+= --disable-fileinfo
156 endif
157
158 ifneq ($(CONFIG_PACKAGE_php5-mod-dom),)
159   PKG_CONFIGURE_OPTS+= --enable-dom=shared
160 else
161   PKG_CONFIGURE_OPTS+= --disable-dom
162 endif
163
164 ifneq ($(CONFIG_PACKAGE_php5-mod-exif),)
165   PKG_CONFIGURE_OPTS+= --enable-exif=shared
166 else
167   PKG_CONFIGURE_OPTS+= --disable-exif
168 endif
169
170 ifneq ($(CONFIG_PACKAGE_php5-mod-ftp),)
171   PKG_CONFIGURE_OPTS+= --enable-ftp=shared
172 else
173   PKG_CONFIGURE_OPTS+= --disable-ftp
174 endif
175
176 ifneq ($(CONFIG_PACKAGE_php5-mod-gd),)
177   PKG_CONFIGURE_OPTS+= --with-gd=shared,"$(STAGING_DIR)/usr" \
178         --without-freetype-dir \
179         --with-jpeg-dir="$(STAGING_DIR)/usr" \
180         --with-png-dir="$(STAGING_DIR)/usr" \
181         --without-xpm-dir \
182         --without-t1lib \
183         --enable-gd-native-ttf \
184         --disable-gd-jis-conv
185 else
186   PKG_CONFIGURE_OPTS+= --without-gd
187 endif
188
189 ifneq ($(CONFIG_PACKAGE_php5-mod-gmp),)
190   PKG_CONFIGURE_OPTS+= --with-gmp=shared,"$(STAGING_DIR)/usr"
191 else
192   PKG_CONFIGURE_OPTS+= --without-gmp
193 endif
194
195 ifneq ($(CONFIG_PACKAGE_php5-mod-hash),)
196   PKG_CONFIGURE_OPTS+= --enable-hash=shared
197 else
198   PKG_CONFIGURE_OPTS+= --disable-hash
199 endif
200
201 ifneq ($(CONFIG_PACKAGE_php5-mod-iconv),)
202   PKG_CONFIGURE_OPTS+= --with-iconv=shared,"$(ICONV_PREFIX)"
203 else
204   PKG_CONFIGURE_OPTS+= --without-iconv
205 endif
206
207 ifneq ($(CONFIG_PACKAGE_php5-mod-json),)
208   PKG_CONFIGURE_OPTS+= --enable-json=shared
209 else
210   PKG_CONFIGURE_OPTS+= --disable-json
211 endif
212
213 ifneq ($(CONFIG_PACKAGE_php5-mod-ldap),)
214   PKG_CONFIGURE_OPTS+= --with-ldap=shared,"$(STAGING_DIR)/usr" \
215         --with-ldap-sasl="$(STAGING_DIR)/usr"
216 else
217   PKG_CONFIGURE_OPTS+= --without-ldap
218 endif
219
220 ifneq ($(CONFIG_PACKAGE_php5-mod-mbstring),)
221   PKG_CONFIGURE_OPTS+= --enable-mbstring=shared --enable-mbregex
222 else
223   PKG_CONFIGURE_OPTS+= --disable-mbstring
224 endif
225
226 ifneq ($(CONFIG_PACKAGE_php5-mod-mcrypt),)
227   PKG_CONFIGURE_OPTS+=  --with-mcrypt=shared,"$(STAGING_DIR)/usr"
228 else
229   PKG_CONFIGURE_OPTS+= --without-mcrypt
230 endif
231
232 ifneq ($(CONFIG_PACKAGE_php5-mod-mysql),)
233   PKG_CONFIGURE_OPTS+= --with-mysql=shared,"$(STAGING_DIR)/usr"
234 else
235   PKG_CONFIGURE_OPTS+= --without-mysql
236 endif
237
238 ifneq ($(CONFIG_PACKAGE_php5-mod-openssl),)
239   PKG_CONFIGURE_OPTS+= --with-openssl=shared,"$(STAGING_DIR)/usr"
240   PKG_CONFIGURE_OPTS+= --with-kerberos=no
241   PKG_CONFIGURE_OPTS+= --with-openssl-dir="$(STAGING_DIR)/usr"
242 else
243   PKG_CONFIGURE_OPTS+= --without-openssl
244 endif
245
246 ifneq ($(CONFIG_PACKAGE_php5-mod-pcntl),)
247   PKG_CONFIGURE_OPTS+= --enable-pcntl=shared
248 else
249   PKG_CONFIGURE_OPTS+= --disable-pcntl
250 endif
251
252 ifneq ($(CONFIG_PACKAGE_php5-mod-pdo),)
253   PKG_CONFIGURE_OPTS+= --enable-pdo=shared
254   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-mysql),)
255     PKG_CONFIGURE_OPTS+= --with-pdo-mysql=shared,"$(STAGING_DIR)/usr"
256   else
257     PKG_CONFIGURE_OPTS+= --without-pdo-mysql
258   endif
259   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-pgsql),)
260     PKG_CONFIGURE_OPTS+= --with-pdo-pgsql=shared,"$(STAGING_DIR)/usr"
261   else
262     PKG_CONFIGURE_OPTS+= --without-pdo-pgsql
263   endif
264   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-sqlite),)
265     PKG_CONFIGURE_OPTS+= --with-pdo-sqlite=shared,"$(STAGING_DIR)/usr"
266     PKG_CONFIGURE_LIBS+= -lsqlite3 -lpthread
267   else
268     PKG_CONFIGURE_OPTS+= --without-pdo-sqlite
269   endif
270 else
271   PKG_CONFIGURE_OPTS+= --disable-pdo
272 endif
273
274 ifneq ($(CONFIG_PACKAGE_php5-mod-pgsql),)
275   PKG_CONFIGURE_OPTS+= --with-pgsql=shared,"$(STAGING_DIR)/usr"
276 else
277   PKG_CONFIGURE_OPTS+= --without-pgsql
278 endif
279
280 ifneq ($(CONFIG_PACKAGE_php5-mod-session),)
281   PKG_CONFIGURE_OPTS+= --enable-session=shared
282 else
283   PKG_CONFIGURE_OPTS+= --disable-session
284 endif
285
286 ifneq ($(CONFIG_PACKAGE_php5-mod-soap),)
287   PKG_CONFIGURE_OPTS+= --enable-soap=shared
288 else
289   PKG_CONFIGURE_OPTS+= --disable-soap
290 endif
291
292 ifneq ($(CONFIG_PACKAGE_php5-mod-sockets),)
293   PKG_CONFIGURE_OPTS+= --enable-sockets=shared
294 else
295   PKG_CONFIGURE_OPTS+= --disable-sockets
296 endif
297
298 ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite),)
299   PKG_CONFIGURE_OPTS+= --with-sqlite=shared,"$(STAGING_DIR)/usr"
300 else
301   PKG_CONFIGURE_OPTS+= --without-sqlite
302 endif
303
304 ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite3),)
305   PKG_CONFIGURE_OPTS+= --with-sqlite3=shared,"$(STAGING_DIR)/usr"
306   PKG_CONFIGURE_LIBS+= -lsqlite3 -lpthread
307 else
308   PKG_CONFIGURE_OPTS+= --without-sqlite3
309 endif
310
311 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvmsg),)
312   PKG_CONFIGURE_OPTS+= --enable-sysvmsg=shared
313 else
314   PKG_CONFIGURE_OPTS+= --disable-sysvmsg
315 endif
316
317 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvsem),)
318   PKG_CONFIGURE_OPTS+= --enable-sysvsem=shared
319 else
320   PKG_CONFIGURE_OPTS+= --disable-sysvsem
321 endif
322
323 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvshm),)
324   PKG_CONFIGURE_OPTS+= --enable-sysvshm=shared
325 else
326   PKG_CONFIGURE_OPTS+= --disable-sysvshm
327 endif
328
329 ifneq ($(CONFIG_PACKAGE_php5-mod-tokenizer),)
330   PKG_CONFIGURE_OPTS+= --enable-tokenizer=shared
331 else
332   PKG_CONFIGURE_OPTS+= --disable-tokenizer
333 endif
334
335 ifneq ($(CONFIG_PACKAGE_php5-mod-xml),)
336   PKG_CONFIGURE_OPTS+= --enable-xml=shared,"$(STAGING_DIR)/usr"
337   ifneq ($(CONFIG_PHP5_LIBXML),)
338     PKG_CONFIGURE_OPTS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
339   else
340     PKG_CONFIGURE_OPTS+= --with-libexpat-dir="$(STAGING_DIR)/usr"
341   endif
342 else
343   PKG_CONFIGURE_OPTS+= --disable-xml
344 endif
345
346 ifneq ($(CONFIG_PACKAGE_php5-mod-xmlreader),)
347   PKG_CONFIGURE_OPTS+= --enable-xmlreader=shared,"$(STAGING_DIR)/usr"
348 else
349   PKG_CONFIGURE_OPTS+= --disable-xmlreader
350 endif
351
352 ifneq ($(CONFIG_PACKAGE_php5-mod-xmlwriter),)
353   PKG_CONFIGURE_OPTS+= --enable-xmlwriter=shared,"$(STAGING_DIR)/usr"
354 else
355   PKG_CONFIGURE_OPTS+= --disable-xmlwriter
356 endif
357
358 ifneq ($(CONFIG_PHP5_APC),)
359   PKG_CONFIGURE_OPTS+= --enable-apc --disable-apc-mmap --disable-apc-pthreadmutex
360   PKG_CONFIGURE_LIBS+= -lrt
361 else
362   PKG_CONFIGURE_OPTS+= --disable-apc
363 endif
364
365 ifneq ($(CONFIG_PHP5_FILTER),)
366   PKG_CONFIGURE_OPTS+= --enable-filter
367 else
368   PKG_CONFIGURE_OPTS+= --disable-filter
369 endif
370
371 ifneq ($(CONFIG_PHP5_LIBXML),)
372   PKG_CONFIGURE_OPTS+= --enable-libxml
373   PKG_CONFIGURE_OPTS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
374 else
375   PKG_CONFIGURE_OPTS+= --disable-libxml
376 endif
377
378
379 define Build/Configure
380 endef
381
382 ifneq ($(CONFIG_PACKAGE_php5-cli),)
383   define Build/Compile/php5-cli
384         -$(MAKE) -C $(PKG_BUILD_DIR) clean
385         $(call Build/Configure/Default, \
386                 $(PKG_CONFIGURE_OPTS) \
387                 --enable-cli \
388                 --disable-cgi \
389                 , \
390                 LIBS="$(PKG_CONFIGURE_LIBS)" \
391                 php_cv_cc_rpath="no" \
392                 iconv_impl_name="gnu_libiconv" \
393                 ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \
394         )
395         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
396         mv $(PKG_BUILD_DIR)/sapi/cli/php $(PKG_BUILD_DIR)/php-cli
397   endef
398 endif
399
400 ifneq ($(CONFIG_PACKAGE_php5-cgi),)
401   define Build/Compile/php5-cgi
402         -$(MAKE) -C $(PKG_BUILD_DIR) clean
403         $(call Build/Configure/Default, \
404                 $(PKG_CONFIGURE_OPTS) \
405                 --disable-cli \
406                 --enable-cgi \
407                 , \
408                 LIBS="$(PKG_CONFIGURE_LIBS)" \
409                 php_cv_cc_rpath="no" \
410                 iconv_impl_name="gnu_libiconv" \
411                 ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \
412         )
413         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
414         mv $(PKG_BUILD_DIR)/sapi/cgi/php-cgi $(PKG_BUILD_DIR)/php-cgi
415   endef
416 endif
417
418 define Build/Compile
419         $(call Build/Compile/php5-cli)
420         $(call Build/Compile/php5-cgi)
421 endef
422
423 define Package/php5/conffiles
424 /etc/php.ini
425 endef
426
427 define Package/php5/install
428         $(INSTALL_DIR) $(1)/etc
429         $(INSTALL_DATA) ./files/php.ini $(1)/etc/
430 endef
431
432 define Package/php5-cli/install
433         $(INSTALL_DIR) $(1)/usr/bin
434         $(CP) $(PKG_BUILD_DIR)/php-cli $(1)/usr/bin/php-cli
435 endef
436
437 define Package/php5-cgi/install
438         $(INSTALL_DIR) $(1)/usr/bin
439         $(CP) $(PKG_BUILD_DIR)/php-cgi $(1)/usr/bin/php-cgi
440         ln -sf php-cgi $(1)/usr/bin/php-fcgi
441 endef
442
443 define Package/php5-fastcgi/install
444         $(INSTALL_DIR) $(1)/etc/init.d
445         $(INSTALL_BIN) ./files/php.init $(1)/etc/init.d/php
446 endef
447
448 PHP5_MODULES:=
449
450 define BuildModule
451   define Package/php5-mod-$(1)
452     $(call Package/php5/Default)
453     ifneq ($(3),)
454       DEPENDS:=$(3)
455     else
456       DEPENDS:=php5
457     endif
458     TITLE:=$(2) shared module
459   endef
460
461   define Package/php5-mod-$(1)/config
462     depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
463     $(4)
464   endef
465
466   define Package/php5-mod-$(1)/install
467         $(INSTALL_DIR) $$(1)/usr/lib/php
468         $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/
469         $(INSTALL_DIR) $$(1)/etc/php5
470         echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
471   endef
472
473   PHP5_MODULES+= php5-mod-$(1)
474 endef
475
476 $(eval $(call BuildPackage,php5))
477 $(eval $(call BuildPackage,php5-cli))
478 $(eval $(call BuildPackage,php5-cgi))
479 $(eval $(call BuildPackage,php5-fastcgi))
480
481 $(eval $(call BuildModule,ctype,Ctype))
482 $(eval $(call BuildModule,curl,cURL,php5 +libcurl))
483 $(eval $(call BuildModule,fileinfo,Fileinfo,php5 +libmagic))
484 $(eval $(call BuildModule,dom,DOM,php5 +libxml2,depends on PHP5_LIBXML))
485 $(eval $(call BuildModule,exif,EXIF))
486 $(eval $(call BuildModule,ftp,FTP))
487 $(eval $(call BuildModule,gd,GD graphics,php5 +libgd))
488 $(eval $(call BuildModule,gmp,GMP,php5 +libgmp))
489 $(eval $(call BuildModule,hash,Hash))
490 $(eval $(call BuildModule,iconv,iConv,php5 +libiconv))
491 $(eval $(call BuildModule,json,JSON))
492 $(eval $(call BuildModule,ldap,LDAP,php5 +libopenldap +libsasl2))
493 $(eval $(call BuildModule,mbstring,MBString))
494 $(eval $(call BuildModule,mcrypt,Mcrypt,php5 +libmcrypt +libltdl))
495 $(eval $(call BuildModule,mysql,MySQL,php5 +libmysqlclient))
496 $(eval $(call BuildModule,openssl,OpenSSL,php5 +libopenssl))
497 $(eval $(call BuildModule,pcntl,PCNTL))
498 $(eval $(call BuildModule,pdo,PHP Data Objects))
499 $(eval $(call BuildModule,pdo-mysql,PDO driver for MySQL,php5-mod-pdo +libmysqlclient))
500 $(eval $(call BuildModule,pdo-pgsql,PDO driver for PostgreSQL,php5-mod-pdo +libpq))
501 $(eval $(call BuildModule,pdo-sqlite,PDO driver for SQLite 3.x,php5-mod-pdo +libsqlite3 +libpthread))
502 $(eval $(call BuildModule,pgsql,PostgreSQL,php5 +libpq))
503 $(eval $(call BuildModule,session,Session))
504 $(eval $(call BuildModule,simplexml,SimpleXML,php5 +libxml2,depends on PHP5_LIBXML))
505 $(eval $(call BuildModule,soap,SOAP,php5 +libxml2,depends on PHP5_LIBXML))
506 $(eval $(call BuildModule,sockets,Sockets))
507 $(eval $(call BuildModule,sqlite,SQLite 2.x,php5 +libsqlite2))
508 $(eval $(call BuildModule,sqlite3,SQLite3,php5 +libsqlite3 +libpthread))
509 $(eval $(call BuildModule,sysvmsg,System V messages))
510 $(eval $(call BuildModule,sysvsem,System V shared memory))
511 $(eval $(call BuildModule,sysvshm,System V semaphore))
512 $(eval $(call BuildModule,tokenizer,Tokenizer))
513 $(eval $(call BuildModule,xml,XML,php5 $(if $(CONFIG_PHP5_LIBXML),+libxml2,+libexpat)))
514 $(eval $(call BuildModule,xmlreader,XMLReader,php5 +libxml2 +libiconv,depends on PHP5_LIBXML))
515 $(eval $(call BuildModule,xmlwriter,XMLWriter,php5 +libxml2 +libiconv,depends on PHP5_LIBXML))
516
517 PKG_CONFIG_DEPENDS:= $(patsubst %,CONFIG_PACKAGE_%,$(PHP5_MODULES))
518 $(foreach p,$(PHP5_MODULES),$(eval $(call BuildPackage,$(p))))