[packages] php5: add support for php5 calendar module
[openwrt/svn-archive/archive.git] / lang / php5 / Makefile
index 929099f49ba48c1422d4e03a93d8b0c8066c30a0..fdd7a38042772384455e8e71afd581efa32ed2df 100644 (file)
-# 
-# Copyright (C) 2006 OpenWrt.org
+#
+# Copyright (C) 2006-2012 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
-# $Id$
 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=php
-PKG_VERSION:=5.0.5
-PKG_RELEASE:=1
+PKG_VERSION:=5.3.10
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_SOURCE_URL:=http://fr.php.net/distributions/
-PKG_MD5SUM:=b5d4ca75bbb11ee5b830fa67213d9f7f
-PKG_CAT:=bzcat
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://www.php.net/distributions/
+PKG_MD5SUM:=816259e5ca7d0a7e943e56a3bb32b17f
+
+PKG_FIXUP:=libtool no-autoreconf
+PKG_BUILD_PARALLEL:=1
+
+PHP5_MODULES = \
+       apc \
+       calendar ctype curl \
+       fileinfo \
+       dio dom \
+       exif \
+       ftp \
+       gettext gd gmp \
+       hash http \
+       iconv \
+       json \
+       ldap libevent \
+       mbstring mcrypt mysql mysqli \
+       openssl \
+       pcntl pdo pdo-mysql pdo-pgsql pdo-sqlite pgsql \
+       session shmop simplexml soap sockets sqlite sqlite3 sysvmsg sysvsem sysvshm \
+       tokenizer \
+       xml xmlreader xmlwriter zip \
+
+PKG_CONFIG_DEPENDS:= \
+       CONFIG_PACKAGE_php5-cgi CONFIG_PACKAGE_php5-cli \
+       $(patsubst %,CONFIG_PACKAGE_php5-mod-%,$(PHP5_MODULES)) \
+       CONFIG_PHP5_FILTER CONFIG_PHP5_LIBXML PHP5_SYSTEMTZDATA
 
 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
 
 define Package/php5/Default
+  SUBMENU:=PHP
   SECTION:=lang
   CATEGORY:=Languages
   TITLE:=PHP5 Hypertext preprocessor
-  DESCRIPTION:=\
-       PHP is a widely-used general-purpose scripting language that is especially \\\
-       suited for Web development and can be embedded into HTML.
   URL:=http://www.php.net/
-endef
-
-define Package/php5
-  $(call Package/php5/Default)
-  DEPENDS:=+libopenssl +zlib
-  DESCRIPTION+=\\\
-       \\\
-       This package contains only the PHP config file. You must actually choose your \\\
-       PHP flavour (cli, cgi or fastcgi).
-  MENU:=1
-endef
-
-define Package/php5/conffiles
-/etc/php.ini
-endef
-
-define Package/php5-cli
-  $(call Package/php5/Default)
+  MAINTAINER:=Michael Heimpold <mhei@heimpold.de>
   DEPENDS:=php5
-  TITLE+= (CLI)
-  DESCRIPTION+=\\\
-       \\\
-       This package contains the CLI version of the PHP5 interpreter.
 endef
 
-define Package/php5-cgi
-  $(call Package/php5/Default)
-  DEPENDS:=php5
-  TITLE+= (CGI)
-  DESCRIPTION+=\\\
-       \\\
-       This package contains the CGI version of the PHP5 interpreter.
+define Package/php5/Default/description
+  PHP is a widely-used general-purpose scripting language that is especially
+  suited for Web development and can be embedded into HTML.
 endef
 
-define Package/php5-fastcgi
-  $(call Package/php5/Default)
-  DEPENDS:=php5
-  TITLE+= (FastCGI)
-  DESCRIPTION+=\\\
-       \\\
-       This package contains the FastCGI version of the PHP5 interpreter.
+define Package/php5/config
+       config PHP5_FILTER
+               bool "PHP5 Filter support"
+               depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
+
+       config PHP5_LIBXML
+               bool "PHP5 LIBXML support"
+               depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
+
+       config PHP5_SYSTEMTZDATA
+               bool "Use system timezone data instead of php's built-in database"
+               depends on PACKAGE_php5-cli || PACKAGE_php5-cgi
+               select PACKAGE_zoneinfo-core
+               default y
+               help
+                       Enabling this feature automatically selects the zoneinfo-core package
+                       which contains data for UTC timezone. To use other timezones you have
+                       to install the corresponding zoneinfo-... package(s).
 endef
 
-define Package/php5-mod-curl
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libcurl
-  TITLE:=cURL module
-endef
-
-define Package/php5-mod-ftp
-  $(call Package/php5/Default)
-  DEPENDS:=php5
-  TITLE:=FTP module
-endef
-
-define Package/php5-mod-gd
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libgd
-  TITLE:=GD graphics module
-endef
-
-define Package/php5-mod-gmp
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libgmp
-  TITLE:=GMP module
-endef
-
-define Package/php5-mod-ldap
+define Package/php5
   $(call Package/php5/Default)
-  DEPENDS:=php5 +libopenldap
-  TITLE:=LDAP module
-endef
 
-define Package/php5-mod-mysql
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libmysqlclient
-  TITLE:=MySQL module
+  DEPENDS:=+libpcre +zlib \
+           +PHP5_LIBXML:libxml2
 endef
 
-define Package/php5-mod-openssl
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libopenssl
-  TITLE:=OpenSSL module
+define Package/php5/description
+  $(call Package/php5/Default/description)
+  This package contains only the PHP config file. You must actually choose
+  your PHP flavour (cli, cgi or fastcgi).
 endef
 
-define Package/php5-mod-pcre
+define Package/php5-cli
   $(call Package/php5/Default)
-  DEPENDS:=php5 +libpcre
-  TITLE:=PCRE module
+  TITLE+= (CLI)
 endef
 
-define Package/php5-mod-pgsql
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libpq
-  TITLE:=PostgreSQL module
+define Package/php5-cli/description
+  $(call Package/php5/Default/description)
+  This package contains the CLI version of the PHP5 interpreter.
 endef
 
-define Package/php5-mod-session
+define Package/php5-cgi
   $(call Package/php5/Default)
-  DEPENDS:=php5
-  TITLE:=Session module
+  TITLE+= (CGI & FastCGI)
 endef
 
-define Package/php5-mod-sockets
-  $(call Package/php5/Default)
-  DEPENDS:=php5
-  TITLE:=Sockets module
+define Package/php5-cgi/description
+  $(call Package/php5/Default/description)
+  This package contains the CGI version of the PHP5 interpreter.
 endef
 
-define Package/php5-mod-sqlite
+define Package/php5-fastcgi
   $(call Package/php5/Default)
-  DEPENDS:=php5 +libsqlite2
-  TITLE:=SQLite module
+  DEPENDS+= +php5-cgi
+  TITLE:=FastCGI startup script
 endef
 
-define Package/php5-mod-xml
-  $(call Package/php5/Default)
-  DEPENDS:=php5 +libexpat
-  TITLE:=XML module
+define Package/php5-fastcgi/description
+  As FastCGI support is now a core feature the php5-fastcgi package now depends
+  on the php5-cgi package, containing just the startup script.
 endef
 
-PKG_CONFIGURE_LIBS:= -lcrypto -lssl
-PKG_CONFIGURE_OPTS:= \
+CONFIGURE_ARGS+= \
        --enable-shared \
        --disable-static \
        --disable-rpath \
        --disable-debug \
        --without-pear \
-       --disable-spl \
        \
        --with-config-file-path=/etc \
-       --disable-ipv6 \
+       --with-config-file-scan-dir=/etc/php5 \
        --enable-magic-quotes \
-       --enable-memory-limit \
        --disable-short-tags \
        \
-       --disable-ctype \
-       --disable-dom \
-       --enable-ftp=shared \
-       --without-gettext \
-       --without-iconv \
-       --disable-libxml \
-         --without-libxml-dir \
-       --disable-mbstring \
-       --disable-mbregex \
-       --with-openssl=shared,"$(STAGING_DIR)/usr" \
-         --with-kerberos=no \
-         --with-openssl-dir="$(STAGING_DIR)/usr" \
-       --enable-session=shared \
-       --disable-simplexml \
-       --disable-soap \
-       --enable-sockets=shared \
-       --disable-tokenizer \
        --with-zlib="$(STAGING_DIR)/usr" \
          --with-zlib-dir="$(STAGING_DIR)/usr" \
+       --with-pcre-regex="$(STAGING_DIR)/usr" \
+       --disable-phar
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-cli),)
+  CONFIGURE_ARGS+= --enable-cli
+else
+  CONFIGURE_ARGS+= --disable-cli
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-cgi),)
+  CONFIGURE_ARGS+= --enable-cgi
+else
+  CONFIGURE_ARGS+= --disable-cgi
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-apc),)
+  CONFIGURE_ARGS+= --enable-apc=shared --disable-apc-mmap --disable-apc-pthreadmutex
+else
+  CONFIGURE_ARGS+= --disable-apc
+endif
 
-ifneq ($(SDK),)
-  PKG_BUILD_DEPENDS:=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libsqlite2 libexpat
-# force PKG_CONFIGURE_{LIBS,OPTS} below when built in the SDK
-  CONFIG_PACKAGE_php5-cli:=m
-  CONFIG_PACKAGE_php5-cgi:=m
-  CONFIG_PACKAGE_php5-fastcgi:=m
-  CONFIG_PACKAGE_php5-mod-curl:=m
-  CONFIG_PACKAGE_php5-mod-gd:=m
-  CONFIG_PACKAGE_php5-mod-gmp:=m
-  CONFIG_PACKAGE_php5-mod-ldap:=m
-  CONFIG_PACKAGE_php5-mod-mysql:=m
-  CONFIG_PACKAGE_php5-mod-pcre:=m
-  CONFIG_PACKAGE_php5-mod-pgsql:=m
-  CONFIG_PACKAGE_php5-mod-sqlite:=m
-  CONFIG_PACKAGE_php5-mod-xml:=m
-endif
-
-ifneq ($(CONFIG_PACKAGE_php5-mod-curl),)
-  PKG_CONFIGURE_OPTS+= --with-curl=shared,"$(STAGING_DIR)/usr"
-else
-  PKG_CONFIGURE_OPTS+= --without-curl
-endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-gd),)
-  PKG_CONFIGURE_OPTS+= --with-gd=shared,"$(STAGING_DIR)/usr" \
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-calendar),)
+  CONFIGURE_ARGS+= --enable-calendar=shared
+else
+  CONFIGURE_ARGS+= --disable-calendar
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-ctype),)
+  CONFIGURE_ARGS+= --enable-ctype=shared
+else
+  CONFIGURE_ARGS+= --disable-ctype
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-curl),)
+  CONFIGURE_ARGS+= --with-curl=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-curl
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-fileinfo),)
+  CONFIGURE_ARGS+= --enable-fileinfo=shared
+else
+  CONFIGURE_ARGS+= --disable-fileinfo
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-gettext),)
+  CONFIGURE_ARGS+= --with-gettext=shared,"$(STAGING_DIR)/usr/lib/libintl-full"
+else
+  CONFIGURE_ARGS+= --without-gettext
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-dio),)
+  CONFIGURE_ARGS+= --enable-dio=shared
+else
+  CONFIGURE_ARGS+= --disable-dio
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-dom),)
+  CONFIGURE_ARGS+= --enable-dom=shared
+else
+  CONFIGURE_ARGS+= --disable-dom
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-exif),)
+  CONFIGURE_ARGS+= --enable-exif=shared
+else
+  CONFIGURE_ARGS+= --disable-exif
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-ftp),)
+  CONFIGURE_ARGS+= --enable-ftp=shared
+else
+  CONFIGURE_ARGS+= --disable-ftp
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-gd),)
+  CONFIGURE_ARGS+= \
+       --with-gd=shared,"$(STAGING_DIR)/usr" \
        --without-freetype-dir \
        --with-jpeg-dir="$(STAGING_DIR)/usr" \
        --with-png-dir="$(STAGING_DIR)/usr" \
        --without-xpm-dir \
-       --without-ttf \
-       --without-t1lib \
+       --without-t1lib \
        --enable-gd-native-ttf \
        --disable-gd-jis-conv
 else
-  PKG_CONFIGURE_OPTS+= --without-gd
+  CONFIGURE_ARGS+= --without-gd
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-gmp),)
+  CONFIGURE_ARGS+= --with-gmp=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-gmp
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-hash),)
+  CONFIGURE_ARGS+= --enable-hash=shared
+else
+  CONFIGURE_ARGS+= --disable-hash
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-gmp),)
-  PKG_CONFIGURE_OPTS+= --with-gmp=shared,"$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-http),)
+  CONFIGURE_ARGS+= \
+       --enable-http=shared \
+       --without-http-shared-deps \
+       --with-http-curl-requests="$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --disable-http
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-iconv),)
+  CONFIGURE_ARGS+= --with-iconv=shared,"$(ICONV_PREFIX)"
+else
+  CONFIGURE_ARGS+= --without-iconv
+endif
+
+ifneq ($(CONFIG_PACKAGE_php5-mod-json),)
+  CONFIGURE_ARGS+= --enable-json=shared
 else
-  PKG_CONFIGURE_OPTS+= --without-gmp
+  CONFIGURE_ARGS+= --disable-json
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-ldap),)
-  PKG_CONFIGURE_OPTS+= --with-ldap=shared,"$(STAGING_DIR)/usr" \
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-ldap),)
+  CONFIGURE_ARGS+= \
+       --with-ldap=shared,"$(STAGING_DIR)/usr" \
        --with-ldap-sasl="$(STAGING_DIR)/usr"
 else
-  PKG_CONFIGURE_OPTS+= --without-ldap
+  CONFIGURE_ARGS+= --without-ldap
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-mysql),)
-  PKG_CONFIGURE_OPTS+= --with-mysql=shared,"$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-libevent),)
+  CONFIGURE_ARGS+= --with-libevent=shared,"$(STAGING_DIR)/usr"
 else
-  PKG_CONFIGURE_OPTS+= --without-mysql
+  CONFIGURE_ARGS+= --without-libevent
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-pcre),)
-  PKG_CONFIGURE_OPTS+= --with-pcre-regex=shared,"$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-mbstring),)
+  CONFIGURE_ARGS+= --enable-mbstring=shared --enable-mbregex
 else
-  PKG_CONFIGURE_OPTS+= --without-pcre-regex
+  CONFIGURE_ARGS+= --disable-mbstring
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-pgsql),)
-  PKG_CONFIGURE_OPTS+= --with-pgsql=shared,"$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-mcrypt),)
+  CONFIGURE_ARGS+=  --with-mcrypt=shared,"$(STAGING_DIR)/usr"
 else
-  PKG_CONFIGURE_OPTS+= --without-pgsql
+  CONFIGURE_ARGS+= --without-mcrypt
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-sqlite),)
-  PKG_CONFIGURE_OPTS+= --with-sqlite=shared,"$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-mysql),)
+  CONFIGURE_ARGS+= --with-mysql=shared,"$(STAGING_DIR)/usr"
 else
-  PKG_CONFIGURE_OPTS+= --without-sqlite
+  CONFIGURE_ARGS+= --without-mysql
 endif
-ifneq ($(CONFIG_PACKAGE_php5-mod-xml),)
-  PKG_CONFIGURE_OPTS+= --enable-xml=shared,"$(STAGING_DIR)/usr" \
-       --with-libexpat-dir="$(STAGING_DIR)/usr"
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-mysqli),)
+  CONFIGURE_ARGS+= --with-mysqli=shared,"$(STAGING_DIR)/usr/bin/mysql_config"
 else
-  PKG_CONFIGURE_OPTS+= --disable-xml
+  CONFIGURE_ARGS+= --without-mysqli
 endif
 
-define Build/Configure
-endef
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-openssl),)
+  CONFIGURE_ARGS+= \
+       --with-openssl=shared,"$(STAGING_DIR)/usr" \
+       --with-kerberos=no \
+       --with-openssl-dir="$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-openssl
+endif
 
-ifneq ($(CONFIG_PACKAGE_php5-cli),)
-  define Build/Compile/php5-cli
-       -$(MAKE) -C $(PKG_BUILD_DIR) clean
-       $(call Build/Configure/Default, \
-               $(PKG_CONFIGURE_OPTS) \
-               --enable-cli \
-               --disable-cgi \
-               --disable-fastcgi \
-               --enable-force-cgi-redirect \
-               --enable-discard-path \
-               , \
-               LIBS="$(PKG_CONFIGURE_LIBS)" \
-               php_cv_cc_rpath="no" \
-       )
-       $(MAKE) -C $(PKG_BUILD_DIR)
-       mv $(PKG_BUILD_DIR)/sapi/cli/php $(PKG_BUILD_DIR)/php-cli
-  endef
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pcntl),)
+  CONFIGURE_ARGS+= --enable-pcntl=shared
+else
+  CONFIGURE_ARGS+= --disable-pcntl
 endif
 
-ifneq ($(CONFIG_PACKAGE_php5-cgi),)
-  define Build/Compile/php5-cgi
-       -$(MAKE) -C $(PKG_BUILD_DIR) clean
-       $(call Build/Configure/Default, \
-               $(PKG_CONFIGURE_OPTS) \
-               --disable-cli \
-               --enable-cgi \
-               --disable-fastcgi \
-               --enable-force-cgi-redirect \
-               --enable-discard-path \
-               , \
-               LIBS="$(PKG_CONFIGURE_LIBS)" \
-               php_cv_cc_rpath="no" \
-       )
-       $(MAKE) -C $(PKG_BUILD_DIR)
-       mv $(PKG_BUILD_DIR)/sapi/cgi/php $(PKG_BUILD_DIR)/php-cgi
-  endef
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pdo),)
+  CONFIGURE_ARGS+= --enable-pdo=shared
+  ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pdo-mysql),)
+    CONFIGURE_ARGS+= --with-pdo-mysql=shared,"$(STAGING_DIR)/usr"
+  else
+    CONFIGURE_ARGS+= --without-pdo-mysql
+  endif
+  ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pdo-pgsql),)
+    CONFIGURE_ARGS+= --with-pdo-pgsql=shared,"$(STAGING_DIR)/usr"
+  else
+    CONFIGURE_ARGS+= --without-pdo-pgsql
+  endif
+  ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pdo-sqlite),)
+    CONFIGURE_ARGS+= --with-pdo-sqlite=shared,"$(STAGING_DIR)/usr"
+  else
+    CONFIGURE_ARGS+= --without-pdo-sqlite
+  endif
+else
+  CONFIGURE_ARGS+= --disable-pdo
 endif
 
-ifneq ($(CONFIG_PACKAGE_php5-fastcgi),)
-  define Build/Compile/php5-fastcgi
-       -$(MAKE) -C $(PKG_BUILD_DIR) clean
-       $(call Build/Configure/Default, \
-               $(PKG_CONFIGURE_OPTS) \
-               --disable-cli \
-               --enable-cgi \
-               --enable-fastcgi \
-               --enable-force-cgi-redirect \
-               --enable-discard-path \
-               , \
-               LIBS="$(PKG_CONFIGURE_LIBS)" \
-               php_cv_cc_rpath="no" \
-       )
-       $(MAKE) -C $(PKG_BUILD_DIR)
-       mv $(PKG_BUILD_DIR)/sapi/cgi/php $(PKG_BUILD_DIR)/php-fastcgi
-  endef
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-pgsql),)
+  CONFIGURE_ARGS+= --with-pgsql=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-pgsql
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-session),)
+  CONFIGURE_ARGS+= --enable-session=shared
+else
+  CONFIGURE_ARGS+= --disable-session
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-shmop),)
+  CONFIGURE_ARGS+= --enable-shmop=shared
+else
+  CONFIGURE_ARGS+= --disable-shmop
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-simplexml),)
+  CONFIGURE_ARGS+= --enable-simplexml=shared
+else
+  CONFIGURE_ARGS+= --disable-simplexml
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-soap),)
+  CONFIGURE_ARGS+= --enable-soap=shared
+else
+  CONFIGURE_ARGS+= --disable-soap
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sockets),)
+  CONFIGURE_ARGS+= --enable-sockets=shared
+else
+  CONFIGURE_ARGS+= --disable-sockets
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sqlite),)
+  CONFIGURE_ARGS+= --with-sqlite=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-sqlite
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sqlite3),)
+  CONFIGURE_ARGS+= --with-sqlite3=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --without-sqlite3
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sysvmsg),)
+  CONFIGURE_ARGS+= --enable-sysvmsg=shared
+else
+  CONFIGURE_ARGS+= --disable-sysvmsg
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sysvsem),)
+  CONFIGURE_ARGS+= --enable-sysvsem=shared
+else
+  CONFIGURE_ARGS+= --disable-sysvsem
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-sysvshm),)
+  CONFIGURE_ARGS+= --enable-sysvshm=shared
+else
+  CONFIGURE_ARGS+= --disable-sysvshm
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-tokenizer),)
+  CONFIGURE_ARGS+= --enable-tokenizer=shared
+else
+  CONFIGURE_ARGS+= --disable-tokenizer
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-xml),)
+  CONFIGURE_ARGS+= --enable-xml=shared,"$(STAGING_DIR)/usr"
+  ifneq ($(CONFIG_PHP5_LIBXML),)
+    CONFIGURE_ARGS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
+  else
+    CONFIGURE_ARGS+= --with-libexpat-dir="$(STAGING_DIR)/usr"
+  endif
+else
+  CONFIGURE_ARGS+= --disable-xml
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-xmlreader),)
+  CONFIGURE_ARGS+= --enable-xmlreader=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --disable-xmlreader
+endif
+
+ifneq ($(SDK)$(CONFIG_PACKAGE_php5-mod-xmlwriter),)
+  CONFIGURE_ARGS+= --enable-xmlwriter=shared,"$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= --disable-xmlwriter
+endif
+
+ifneq ($(CONFIG_PACKAGE_php5-mod-zip),)
+  CONFIGURE_ARGS+= --enable-zip=shared
+else
+  CONFIGURE_ARGS+= --disable-zip
 endif
 
-define Build/Compile
-       $(call Build/Compile/php5-cli)
-       $(call Build/Compile/php5-cgi)
-       $(call Build/Compile/php5-fastcgi)
+ifneq ($(SDK)$(CONFIG_PHP5_FILTER),)
+  CONFIGURE_ARGS+= --enable-filter
+else
+  CONFIGURE_ARGS+= --disable-filter
+endif
+
+ifneq ($(SDK)$(CONFIG_PHP5_LIBXML),)
+  CONFIGURE_ARGS+= --enable-libxml
+  CONFIGURE_ARGS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2"
+else
+  CONFIGURE_ARGS+= --disable-libxml
+endif
+
+ifneq ($(CONFIG_PHP5_SYSTEMTZDATA),)
+  CONFIGURE_ARGS+= --with-system-tzdata
+else
+  CONFIGURE_ARGS+= --without-system-tzdata
+endif
+
+CONFIGURE_VARS+= \
+       LIBS="$(CONFIGURE_LIBS)" \
+       ac_cv_c_bigendian_php=$(if $(CONFIG_BIG_ENDIAN),yes,no) \
+       php_cv_cc_rpath="no" \
+       iconv_impl_name="gnu_libiconv" \
+       ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \
+
+define Package/php5/conffiles
+/etc/php.ini
 endef
 
 define Package/php5/install
@@ -331,46 +472,101 @@ endef
 
 define Package/php5-cli/install
        $(INSTALL_DIR) $(1)/usr/bin
-       $(CP) $(PKG_BUILD_DIR)/php-cli $(1)/usr/bin/php
+       $(CP) $(PKG_BUILD_DIR)/sapi/cli/php $(1)/usr/bin/php-cli
 endef
 
 define Package/php5-cgi/install
        $(INSTALL_DIR) $(1)/usr/bin
-       $(CP) $(PKG_BUILD_DIR)/php-cgi $(1)/usr/bin/php
+       $(CP) $(PKG_BUILD_DIR)/sapi/cgi/php-cgi $(1)/usr/bin/php-cgi
+       ln -sf php-cgi $(1)/usr/bin/php-fcgi
 endef
 
 define Package/php5-fastcgi/install
-       $(INSTALL_DIR) $(1)/usr/sbin
-       $(CP) $(PKG_BUILD_DIR)/php-fastcgi $(1)/usr/sbin/php
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DATA) ./files/php5-fastcgi.config $(1)/etc/config/php5-fastcgi
+
        $(INSTALL_DIR) $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/php.init $(1)/etc/init.d/php
+       $(INSTALL_BIN) ./files/php5-fastcgi.init $(1)/etc/init.d/php5-fastcgi
+endef
+
+define Build/InstallDev
+       make -C $(PKG_BUILD_DIR) install INSTALL_ROOT=$(PKG_BUILD_DIR)/staging
+       rm -f $(PKG_BUILD_DIR)/staging/usr/bin/php
+       $(CP) $(PKG_BUILD_DIR)/staging/* $(STAGING_DIR_HOST)
+       sed -i -e "s#prefix='/usr'#prefix='$(STAGING_DIR_HOST)/usr'#" $(STAGING_DIR_HOST)/usr/bin/phpize
+       sed -i -e "s#exec_prefix=\"\`eval echo /usr\`\"#exec_prefix='$(STAGING_DIR_HOST)/usr'#" $(STAGING_DIR_HOST)/usr/bin/phpize
 endef
 
-define BuildPlugin
-  define Package/$(1)/install
-       [ -z "$(2)" ] || $(INSTALL_DIR) $$(1)/usr/lib/php
-       for m in $(2); do \
-               $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$$$$$$$${m}.so $$(1)/usr/lib/php/ ; \
-       done
+define BuildModule
+
+  define Package/php5-mod-$(1)
+    $(call Package/php5/Default)
+
+    ifneq ($(3),)
+      DEPENDS+=$(3)
+    endif
+
+    TITLE:=$(2) shared module
+  endef
+
+  define Package/php5-mod-$(1)/install
+       $(INSTALL_DIR) $$(1)/usr/lib/php
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/
+       $(INSTALL_DIR) $$(1)/etc/php5
+       echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php5/$(subst -,_,$(1)).ini
   endef
 
-  $$(eval $$(call BuildPackage,$(1)))
+  $$(eval $$(call BuildPackage,php5-mod-$(1)))
+
 endef
 
 $(eval $(call BuildPackage,php5))
 $(eval $(call BuildPackage,php5-cli))
 $(eval $(call BuildPackage,php5-cgi))
 $(eval $(call BuildPackage,php5-fastcgi))
-$(eval $(call BuildPlugin,php5-mod-curl,curl))
-$(eval $(call BuildPlugin,php5-mod-ftp,ftp))
-$(eval $(call BuildPlugin,php5-mod-gd,gd))
-$(eval $(call BuildPlugin,php5-mod-gmp,gmp))
-$(eval $(call BuildPlugin,php5-mod-ldap,ldap))
-$(eval $(call BuildPlugin,php5-mod-mysql,mysql))
-$(eval $(call BuildPlugin,php5-mod-openssl,openssl))
-$(eval $(call BuildPlugin,php5-mod-pcre,pcre))
-$(eval $(call BuildPlugin,php5-mod-pgsql,pgsql))
-$(eval $(call BuildPlugin,php5-mod-session,session))
-$(eval $(call BuildPlugin,php5-mod-sockets,sockets))
-$(eval $(call BuildPlugin,php5-mod-sqlite,sqlite))
-$(eval $(call BuildPlugin,php5-mod-xml,xml))
+
+#$(eval $(call BuildModule,NAME,TITLE[,PKG DEPENDS]))
+$(eval $(call BuildModule,apc,APC,+PACKAGE_php5-mod-apc:librt))
+$(eval $(call BuildModule,calendar,Calendar))
+$(eval $(call BuildModule,ctype,Ctype))
+$(eval $(call BuildModule,curl,cURL,+PACKAGE_php5-mod-curl:libcurl))
+$(eval $(call BuildModule,fileinfo,Fileinfo,+PACKAGE_php5-mod-fileinfo:libmagic))
+$(eval $(call BuildModule,dio,Direct IO))
+$(eval $(call BuildModule,dom,DOM,+@PHP5_LIBXML +PACKAGE_php5-mod-dom:libxml2))
+$(eval $(call BuildModule,exif,EXIF))
+$(eval $(call BuildModule,ftp,FTP))
+$(eval $(call BuildModule,gettext,Gettext,+PACKAGE_php5-mod-gettext:libintl-full))
+$(eval $(call BuildModule,gd,GD graphics,+PACKAGE_php5-mod-gd:libgd))
+$(eval $(call BuildModule,gmp,GMP,+PACKAGE_php5-mod-gmp:libgmp))
+$(eval $(call BuildModule,hash,Hash))
+$(eval $(call BuildModule,http,HTTP,+PACKAGE_php5-mod-http:libcurl +PACKAGE_php5-mod-http:libevent2 +PACKAGE_php5-mod-http:librt))
+$(eval $(call BuildModule,iconv,iConv,+PACKAGE_php5-mod-iconv:libiconv))
+$(eval $(call BuildModule,json,JSON))
+$(eval $(call BuildModule,ldap,LDAP,+PACKAGE_php5-mod-ldap:libopenldap +PACKAGE_php5-mod-ldap:libsasl2))
+$(eval $(call BuildModule,libevent,libevent,+PACKAGE_php5-mod-libevent:libevent))
+$(eval $(call BuildModule,mbstring,MBString))
+$(eval $(call BuildModule,mcrypt,Mcrypt,+PACKAGE_php5-mod-mcrypt:libmcrypt +PACKAGE_php5-mod-mcrypt:libltdl))
+$(eval $(call BuildModule,mysql,MySQL,+PACKAGE_php5-mod-mysql:libmysqlclient))
+$(eval $(call BuildModule,mysqli,MySQL Improved Extension,+PACKAGE_php5-mod-mysqli:libmysqlclient))
+$(eval $(call BuildModule,openssl,OpenSSL,+PACKAGE_php5-mod-openssl:libopenssl))
+$(eval $(call BuildModule,pcntl,PCNTL))
+$(eval $(call BuildModule,pdo,PHP Data Objects))
+$(eval $(call BuildModule,pdo-mysql,PDO driver for MySQL,+php5-mod-pdo +PACKAGE_php5-mod-pdo-mysql:libmysqlclient))
+$(eval $(call BuildModule,pdo-pgsql,PDO driver for PostgreSQL,+php5-mod-pdo +PACKAGE_php5-mod-pdo-pgsql:libpq))
+$(eval $(call BuildModule,pdo-sqlite,PDO driver for SQLite 3.x,+php5-mod-pdo +PACKAGE_php5-mod-pdo-sqlite:libsqlite3 +PACKAGE_php5-mod-pdo-sqlite:libpthread))
+$(eval $(call BuildModule,pgsql,PostgreSQL,+PACKAGE_php5-mod-pgsql:libpq))
+$(eval $(call BuildModule,session,Session))
+$(eval $(call BuildModule,shmop,Shared Memory))
+$(eval $(call BuildModule,simplexml,SimpleXML,+@PHP5_LIBXML +PACKAGE_php5-mod-simplexml:libxml2))
+$(eval $(call BuildModule,soap,SOAP,+@PHP5_LIBXML +PACKAGE_php5-mod-soap:libxml2))
+$(eval $(call BuildModule,sockets,Sockets))
+$(eval $(call BuildModule,sqlite,SQLite 2.x,+PACKAGE_php5-mod-sqlite:libsqlite2))
+$(eval $(call BuildModule,sqlite3,SQLite3,+PACKAGE_php5-mod-sqlite3:libsqlite3 +PACKAGE_php5-mod-sqlite3:libpthread))
+$(eval $(call BuildModule,sysvmsg,System V messages))
+$(eval $(call BuildModule,sysvsem,System V shared memory))
+$(eval $(call BuildModule,sysvshm,System V semaphore))
+$(eval $(call BuildModule,tokenizer,Tokenizer))
+$(eval $(call BuildModule,xml,XML,+PHP5_LIBXML:libxml2 +!PHP5_LIBXML:libexpat))
+$(eval $(call BuildModule,xmlreader,XMLReader,+@PHP5_LIBXML +PACKAGE_php5-mod-xmlreader:libxml2 +PACKAGE_php5-mod-xmlreader:libiconv))
+$(eval $(call BuildModule,xmlwriter,XMLWriter,+@PHP5_LIBXML +PACKAGE_php5-mod-xmlwriter:libxml2 +PACKAGE_php5-mod-xmlwriter:libiconv))
+$(eval $(call BuildModule,zip,ZIP,+PACKAGE_php5-mod-zip:zlib))