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