d56890141314abc74e78c7b6e76e37ae9796e6be
[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         --with-zlib="$(STAGING_DIR)/usr" \
118           --with-zlib-dir="$(STAGING_DIR)/usr" \
119         --with-pcre-regex="$(STAGING_DIR)/usr" \
120         --disable-phar
121
122 ifneq ($(SDK),)
123   PKG_BUILD_DEPENDS+=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libsqlite2 libpthread libsqlite3 libpcre libxml2
124 # force PKG_CONFIGURE_{LIBS,OPTS} below when built in the SDK
125   CONFIG_PACKAGE_php5-cli:=m
126   CONFIG_PACKAGE_php5-cgi:=m
127   CONFIG_PACKAGE_php5-fastcgi:=m
128   CONFIG_PACKAGE_php5-mod-curl:=m
129   CONFIG_PACKAGE_php5-mod-gd:=m
130   CONFIG_PACKAGE_php5-mod-gmp:=m
131   CONFIG_PACKAGE_php5-mod-ldap:=m
132   CONFIG_PACKAGE_php5-mod-mysql:=m
133   CONFIG_PACKAGE_php5-mod-pgsql:=m
134   CONFIG_PACKAGE_php5-mod-sqlite:=m
135   CONFIG_PACKAGE_php5-mod-sqlite3:=m
136   CONFIG_PACKAGE_php5-mod-xml:=m
137 endif
138
139 ifneq ($(CONFIG_PACKAGE_php5-mod-ctype),)
140   PKG_CONFIGURE_OPTS+= --enable-ctype=shared
141 else
142   PKG_CONFIGURE_OPTS+= --disable-ctype
143 endif
144
145 ifneq ($(CONFIG_PACKAGE_php5-mod-curl),)
146   PKG_CONFIGURE_OPTS+= --with-curl=shared,"$(STAGING_DIR)/usr"
147 else
148   PKG_CONFIGURE_OPTS+= --without-curl
149 endif
150
151 ifneq ($(CONFIG_PACKAGE_php5-mod-fileinfo),)
152   PKG_CONFIGURE_OPTS+= --enable-fileinfo=shared
153 else
154   PKG_CONFIGURE_OPTS+= --disable-fileinfo
155 endif
156
157 ifneq ($(CONFIG_PACKAGE_php5-mod-dom),)
158   PKG_CONFIGURE_OPTS+= --enable-dom=shared
159 else
160   PKG_CONFIGURE_OPTS+= --disable-dom
161 endif
162
163 ifneq ($(CONFIG_PACKAGE_php5-mod-exif),)
164   PKG_CONFIGURE_OPTS+= --enable-exif=shared
165 else
166   PKG_CONFIGURE_OPTS+= --disable-exif
167 endif
168
169 ifneq ($(CONFIG_PACKAGE_php5-mod-ftp),)
170   PKG_CONFIGURE_OPTS+= --enable-ftp=shared
171 else
172   PKG_CONFIGURE_OPTS+= --disable-ftp
173 endif
174
175 ifneq ($(CONFIG_PACKAGE_php5-mod-gd),)
176   PKG_CONFIGURE_OPTS+= --with-gd=shared,"$(STAGING_DIR)/usr" \
177         --without-freetype-dir \
178         --with-jpeg-dir="$(STAGING_DIR)/usr" \
179         --with-png-dir="$(STAGING_DIR)/usr" \
180         --without-xpm-dir \
181         --without-t1lib \
182         --enable-gd-native-ttf \
183         --disable-gd-jis-conv
184 else
185   PKG_CONFIGURE_OPTS+= --without-gd
186 endif
187
188 ifneq ($(CONFIG_PACKAGE_php5-mod-gmp),)
189   PKG_CONFIGURE_OPTS+= --with-gmp=shared,"$(STAGING_DIR)/usr"
190 else
191   PKG_CONFIGURE_OPTS+= --without-gmp
192 endif
193
194 ifneq ($(CONFIG_PACKAGE_php5-mod-hash),)
195   PKG_CONFIGURE_OPTS+= --enable-hash=shared
196 else
197   PKG_CONFIGURE_OPTS+= --disable-hash
198 endif
199
200 ifneq ($(CONFIG_PACKAGE_php5-mod-iconv),)
201   PKG_CONFIGURE_OPTS+= --with-iconv=shared,"$(ICONV_PREFIX)"
202 else
203   PKG_CONFIGURE_OPTS+= --without-iconv
204 endif
205
206 ifneq ($(CONFIG_PACKAGE_php5-mod-json),)
207   PKG_CONFIGURE_OPTS+= --enable-json=shared
208 else
209   PKG_CONFIGURE_OPTS+= --disable-json
210 endif
211
212 ifneq ($(CONFIG_PACKAGE_php5-mod-ldap),)
213   PKG_CONFIGURE_OPTS+= --with-ldap=shared,"$(STAGING_DIR)/usr" \
214         --with-ldap-sasl="$(STAGING_DIR)/usr"
215 else
216   PKG_CONFIGURE_OPTS+= --without-ldap
217 endif
218
219 ifneq ($(CONFIG_PACKAGE_php5-mod-mbstring),)
220   PKG_CONFIGURE_OPTS+= --enable-mbstring=shared --enable-mbregex
221 else
222   PKG_CONFIGURE_OPTS+= --disable-mbstring
223 endif
224
225 ifneq ($(CONFIG_PACKAGE_php5-mod-mcrypt),)
226   PKG_CONFIGURE_OPTS+=  --with-mcrypt=shared,"$(STAGING_DIR)/usr"
227 else
228   PKG_CONFIGURE_OPTS+= --without-mcrypt
229 endif
230
231 ifneq ($(CONFIG_PACKAGE_php5-mod-mysql),)
232   PKG_CONFIGURE_OPTS+= --with-mysql=shared,"$(STAGING_DIR)/usr"
233 else
234   PKG_CONFIGURE_OPTS+= --without-mysql
235 endif
236
237 ifneq ($(CONFIG_PACKAGE_php5-mod-openssl),)
238   PKG_CONFIGURE_OPTS+= --with-openssl=shared,"$(STAGING_DIR)/usr"
239   PKG_CONFIGURE_OPTS+= --with-kerberos=no
240   PKG_CONFIGURE_OPTS+= --with-openssl-dir="$(STAGING_DIR)/usr"
241 else
242   PKG_CONFIGURE_OPTS+= --without-openssl
243 endif
244
245 ifneq ($(CONFIG_PACKAGE_php5-mod-pcntl),)
246   PKG_CONFIGURE_OPTS+= --enable-pcntl=shared
247 else
248   PKG_CONFIGURE_OPTS+= --disable-pcntl
249 endif
250
251 ifneq ($(CONFIG_PACKAGE_php5-mod-pdo),)
252   PKG_CONFIGURE_OPTS+= --enable-pdo=shared
253   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-mysql),)
254     PKG_CONFIGURE_OPTS+= --with-pdo-mysql=shared,"$(STAGING_DIR)/usr"
255   else
256     PKG_CONFIGURE_OPTS+= --without-pdo-mysql
257   endif
258   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-pgsql),)
259     PKG_CONFIGURE_OPTS+= --with-pdo-pgsql=shared,"$(STAGING_DIR)/usr"
260   else
261     PKG_CONFIGURE_OPTS+= --without-pdo-pgsql
262   endif
263   ifneq ($(CONFIG_PACKAGE_php5-mod-pdo-sqlite),)
264     PKG_CONFIGURE_OPTS+= --with-pdo-sqlite=shared,"$(STAGING_DIR)/usr"
265     PKG_CONFIGURE_LIBS+= -lsqlite3 -lpthread
266   else
267     PKG_CONFIGURE_OPTS+= --without-pdo-sqlite
268   endif
269 else
270   PKG_CONFIGURE_OPTS+= --disable-pdo
271 endif
272
273 ifneq ($(CONFIG_PACKAGE_php5-mod-pgsql),)
274   PKG_CONFIGURE_OPTS+= --with-pgsql=shared,"$(STAGING_DIR)/usr"
275 else
276   PKG_CONFIGURE_OPTS+= --without-pgsql
277 endif
278
279 ifneq ($(CONFIG_PACKAGE_php5-mod-session),)
280   PKG_CONFIGURE_OPTS+= --enable-session=shared
281 else
282   PKG_CONFIGURE_OPTS+= --disable-session
283 endif
284
285 ifneq ($(CONFIG_PACKAGE_php5-mod-simplexml),)
286   PKG_CONFIGURE_OPTS+= --enable-simplexml=shared
287 else
288   PKG_CONFIGURE_OPTS+= --disable-simplexml
289 endif
290
291 ifneq ($(CONFIG_PACKAGE_php5-mod-soap),)
292   PKG_CONFIGURE_OPTS+= --enable-soap=shared
293 else
294   PKG_CONFIGURE_OPTS+= --disable-soap
295 endif
296
297 ifneq ($(CONFIG_PACKAGE_php5-mod-sockets),)
298   PKG_CONFIGURE_OPTS+= --enable-sockets=shared
299 else
300   PKG_CONFIGURE_OPTS+= --disable-sockets
301 endif
302
303 ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite),)
304   PKG_CONFIGURE_OPTS+= --with-sqlite=shared,"$(STAGING_DIR)/usr"
305 else
306   PKG_CONFIGURE_OPTS+= --without-sqlite
307 endif
308
309 ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite3),)
310   PKG_CONFIGURE_OPTS+= --with-sqlite3=shared,"$(STAGING_DIR)/usr"
311   PKG_CONFIGURE_LIBS+= -lsqlite3 -lpthread
312 else
313   PKG_CONFIGURE_OPTS+= --without-sqlite3
314 endif
315
316 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvmsg),)
317   PKG_CONFIGURE_OPTS+= --enable-sysvmsg=shared
318 else
319   PKG_CONFIGURE_OPTS+= --disable-sysvmsg
320 endif
321
322 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvsem),)
323   PKG_CONFIGURE_OPTS+= --enable-sysvsem=shared
324 else
325   PKG_CONFIGURE_OPTS+= --disable-sysvsem
326 endif
327
328 ifneq ($(CONFIG_PACKAGE_php5-mod-sysvshm),)
329   PKG_CONFIGURE_OPTS+= --enable-sysvshm=shared
330 else
331   PKG_CONFIGURE_OPTS+= --disable-sysvshm
332 endif
333
334 ifneq ($(CONFIG_PACKAGE_php5-mod-tokenizer),)
335   PKG_CONFIGURE_OPTS+= --enable-tokenizer=shared
336 else
337   PKG_CONFIGURE_OPTS+= --disable-tokenizer
338 endif
339
340 ifneq ($(CONFIG_PACKAGE_php5-mod-xml),)
341   PKG_CONFIGURE_OPTS+= --enable-xml=shared,"$(STAGING_DIR)/usr"
342   ifneq ($(CONFIG_PHP5_LIBXML),)
343     PKG_CONFIGURE_OPTS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
344   else
345     PKG_CONFIGURE_OPTS+= --with-libexpat-dir="$(STAGING_DIR)/usr"
346   endif
347 else
348   PKG_CONFIGURE_OPTS+= --disable-xml
349 endif
350
351 ifneq ($(CONFIG_PACKAGE_php5-mod-xmlreader),)
352   PKG_CONFIGURE_OPTS+= --enable-xmlreader=shared,"$(STAGING_DIR)/usr"
353 else
354   PKG_CONFIGURE_OPTS+= --disable-xmlreader
355 endif
356
357 ifneq ($(CONFIG_PACKAGE_php5-mod-xmlwriter),)
358   PKG_CONFIGURE_OPTS+= --enable-xmlwriter=shared,"$(STAGING_DIR)/usr"
359 else
360   PKG_CONFIGURE_OPTS+= --disable-xmlwriter
361 endif
362
363 ifneq ($(CONFIG_PHP5_APC),)
364   PKG_CONFIGURE_OPTS+= --enable-apc --disable-apc-mmap --disable-apc-pthreadmutex
365   PKG_CONFIGURE_LIBS+= -lrt
366 else
367   PKG_CONFIGURE_OPTS+= --disable-apc
368 endif
369
370 ifneq ($(CONFIG_PHP5_FILTER),)
371   PKG_CONFIGURE_OPTS+= --enable-filter
372 else
373   PKG_CONFIGURE_OPTS+= --disable-filter
374 endif
375
376 ifneq ($(CONFIG_PHP5_LIBXML),)
377   PKG_CONFIGURE_OPTS+= --enable-libxml
378   PKG_CONFIGURE_OPTS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
379 else
380   PKG_CONFIGURE_OPTS+= --disable-libxml
381 endif
382
383
384 define Build/Configure
385 endef
386
387 ifneq ($(CONFIG_PACKAGE_php5-cli),)
388   define Build/Compile/php5-cli
389         -$(MAKE) -C $(PKG_BUILD_DIR) clean
390         $(call Build/Configure/Default, \
391                 $(PKG_CONFIGURE_OPTS) \
392                 --enable-cli \
393                 --disable-cgi \
394                 , \
395                 LIBS="$(PKG_CONFIGURE_LIBS)" \
396                 php_cv_cc_rpath="no" \
397                 iconv_impl_name="gnu_libiconv" \
398                 ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \
399         )
400         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
401         mv $(PKG_BUILD_DIR)/sapi/cli/php $(PKG_BUILD_DIR)/php-cli
402   endef
403 endif
404
405 ifneq ($(CONFIG_PACKAGE_php5-cgi),)
406   define Build/Compile/php5-cgi
407         -$(MAKE) -C $(PKG_BUILD_DIR) clean
408         $(call Build/Configure/Default, \
409                 $(PKG_CONFIGURE_OPTS) \
410                 --disable-cli \
411                 --enable-cgi \
412                 , \
413                 LIBS="$(PKG_CONFIGURE_LIBS)" \
414                 php_cv_cc_rpath="no" \
415                 iconv_impl_name="gnu_libiconv" \
416                 ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \
417         )
418         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
419         mv $(PKG_BUILD_DIR)/sapi/cgi/php-cgi $(PKG_BUILD_DIR)/php-cgi
420   endef
421 endif
422
423 define Build/Compile
424         $(call Build/Compile/php5-cli)
425         $(call Build/Compile/php5-cgi)
426 endef
427
428 define Package/php5/conffiles
429 /etc/php.ini
430 endef
431
432 define Package/php5/install
433         $(INSTALL_DIR) $(1)/etc
434         $(INSTALL_DATA) ./files/php.ini $(1)/etc/
435 endef
436
437 define Package/php5-cli/install
438         $(INSTALL_DIR) $(1)/usr/bin
439         $(CP) $(PKG_BUILD_DIR)/php-cli $(1)/usr/bin/php-cli
440 endef
441
442 define Package/php5-cgi/install
443         $(INSTALL_DIR) $(1)/usr/bin
444         $(CP) $(PKG_BUILD_DIR)/php-cgi $(1)/usr/bin/php-cgi
445         ln -sf php-cgi $(1)/usr/bin/php-fcgi
446 endef
447
448 define Package/php5-fastcgi/install
449         $(INSTALL_DIR) $(1)/etc/init.d
450         $(INSTALL_BIN) ./files/php.init $(1)/etc/init.d/php
451 endef
452
453 PHP5_MODULES:=
454
455 define BuildModule
456   define Package/php5-mod-$(1)
457     $(call Package/php5/Default)
458     ifneq ($(3),)
459       DEPENDS:=$(3)
460     else
461       DEPENDS:=php5
462     endif
463     TITLE:=$(2) shared module
464   endef
465
466   define Package/php5-mod-$(1)/config
467     depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
468     $(4)
469   endef
470
471   define Package/php5-mod-$(1)/install
472         $(INSTALL_DIR) $$(1)/usr/lib/php
473         $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/
474         $(INSTALL_DIR) $$(1)/etc/php5
475         echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
476   endef
477
478   PHP5_MODULES+= php5-mod-$(1)
479 endef
480
481 $(eval $(call BuildPackage,php5))
482 $(eval $(call BuildPackage,php5-cli))
483 $(eval $(call BuildPackage,php5-cgi))
484 $(eval $(call BuildPackage,php5-fastcgi))
485
486 $(eval $(call BuildModule,ctype,Ctype))
487 $(eval $(call BuildModule,curl,cURL,php5 +libcurl))
488 $(eval $(call BuildModule,fileinfo,Fileinfo,php5 +libmagic))
489 $(eval $(call BuildModule,dom,DOM,php5 +libxml2,depends on PHP5_LIBXML))
490 $(eval $(call BuildModule,exif,EXIF))
491 $(eval $(call BuildModule,ftp,FTP))
492 $(eval $(call BuildModule,gd,GD graphics,php5 +libgd))
493 $(eval $(call BuildModule,gmp,GMP,php5 +libgmp))
494 $(eval $(call BuildModule,hash,Hash))
495 $(eval $(call BuildModule,iconv,iConv,php5 +libiconv))
496 $(eval $(call BuildModule,json,JSON))
497 $(eval $(call BuildModule,ldap,LDAP,php5 +libopenldap +libsasl2))
498 $(eval $(call BuildModule,mbstring,MBString))
499 $(eval $(call BuildModule,mcrypt,Mcrypt,php5 +libmcrypt +libltdl))
500 $(eval $(call BuildModule,mysql,MySQL,php5 +libmysqlclient))
501 $(eval $(call BuildModule,openssl,OpenSSL,php5 +libopenssl))
502 $(eval $(call BuildModule,pcntl,PCNTL))
503 $(eval $(call BuildModule,pdo,PHP Data Objects))
504 $(eval $(call BuildModule,pdo-mysql,PDO driver for MySQL,php5-mod-pdo +libmysqlclient))
505 $(eval $(call BuildModule,pdo-pgsql,PDO driver for PostgreSQL,php5-mod-pdo +libpq))
506 $(eval $(call BuildModule,pdo-sqlite,PDO driver for SQLite 3.x,php5-mod-pdo +libsqlite3 +libpthread))
507 $(eval $(call BuildModule,pgsql,PostgreSQL,php5 +libpq))
508 $(eval $(call BuildModule,session,Session))
509 $(eval $(call BuildModule,simplexml,SimpleXML,php5 +libxml2,depends on PHP5_LIBXML))
510 $(eval $(call BuildModule,soap,SOAP,php5 +libxml2,depends on PHP5_LIBXML))
511 $(eval $(call BuildModule,sockets,Sockets))
512 $(eval $(call BuildModule,sqlite,SQLite 2.x,php5 +libsqlite2))
513 $(eval $(call BuildModule,sqlite3,SQLite3,php5 +libsqlite3 +libpthread))
514 $(eval $(call BuildModule,sysvmsg,System V messages))
515 $(eval $(call BuildModule,sysvsem,System V shared memory))
516 $(eval $(call BuildModule,sysvshm,System V semaphore))
517 $(eval $(call BuildModule,tokenizer,Tokenizer))
518 $(eval $(call BuildModule,xml,XML,php5 $(if $(CONFIG_PHP5_LIBXML),+libxml2,+libexpat)))
519 $(eval $(call BuildModule,xmlreader,XMLReader,php5 +libxml2 +libiconv,depends on PHP5_LIBXML))
520 $(eval $(call BuildModule,xmlwriter,XMLWriter,php5 +libxml2 +libiconv,depends on PHP5_LIBXML))
521
522 PKG_CONFIG_DEPENDS:= $(patsubst %,CONFIG_PACKAGE_%,$(PHP5_MODULES))
523 $(foreach p,$(PHP5_MODULES),$(eval $(call BuildPackage,$(p))))