--- Portfile-orig	Wed Oct 29 00:12:24 2003
+++ Portfile	Wed Oct 29 01:09:50 2003
@@ -2,54 +2,98 @@
 
 PortSystem 1.0
 name            php4
-version         4.3.2
+version         4.3.3	
 revision		1
-categories      www
+categories      lang www
 maintainers    	bchesneau@mac.com
 description     PHP: Hypertext Preprocessor
 long_description 	PHP is a widely-used general-purpose scripting language \
 			that is especially suited for Web development and can be \
 			embedded into HTML. 
 platforms	darwin freebsd
+
+master_sites 	http://www.php.net/distributions/:release \
+                http://it.php.net/distributions/:release \
+                http://fi.php.net/distributions/:release \
+                http://de.php.net/distributions/:release \
+                http://gr.php.net/distributions/:release \
+                http://fr.php.net/distributions/:release \
+                http://es.php.net/distributions/:release \
+                http://se.php.net/distributions/:release \
+                http://downloads.php.net/ilia/:rc \
+                http://downloads.php.net/jani/:rc 
+                
 distname	php-${version}
+distfiles	${distname}${extract.sufx}:release
 worksrcdir	php-${version}
-master_sites 	http://fr.php.net/distributions/ \
-		http://www.php.net/distributions/
-checksums	php-4.3.2.tar.gz md5 8433a1d0ce679780990d4813ae094590
+checksums	php-4.3.3.tar.gz md5 fe3fede4115354155fc6185522f7c6b2                
+
+patchfiles	patch-configure
 
-depends_lib	lib:libcurl.2:curl \
-		lib:libiconv.2:libiconv \
+depends_lib	lib:libiconv.2:libiconv \
 		lib:libexpat.0.4:expat  \
 		lib:libintl:gettext \
-		lib:libjpeg.9:jpeg \
-		lib:libpng3:libpng \
-		lib:libmhash:mhash \
 		lib:libz.1:zlib
 
-set imapversion 2002d
+
+configure.env	LDFLAGS=-L${prefix}/lib \
+				CPPFLAGS="-I${prefix}/include -no-cpp-precomp -DBIND_8_COMPAT" \
+				LIBS=-ldl
 				
-configure.env	LDFLAGS=-L${prefix}/lib CPPFLAGS=-I${prefix}/include
 
 configure.args	--mandir=${prefix}/share/man --infodir=${prefix}/share/info \
 		--with-config-file-path=${prefix}/etc --enable-calendar \
 		--with-iconv=${prefix} --enable-exif --enable-ftp --enable-wddx\
-		--with-zlib --with-curl=${prefix} --with-gd --with-jpeg-dir=${prefix} \
-		--with-png-dir=${prefix} --without-mysql --with-gettext=${prefix} \
-		--with-mhash=${prefix} --with-expat-dir=${prefix} --with-iconv-dir=${prefix} \
-		--with-xmlrpc --enable-filepro --enable-bcmath
-
+		--with-zlib --without-mysql --with-gettext=${prefix} \
+		--with-expat-dir=${prefix} --with-xml --with-xmlrpc --enable-filepro \
+		--enable-bcmath --enable-trans-sid  \
+		--enable-mbstring --enable-dbx --enable-sockets
+		
 variant darwin {
 	depends_lib-append	lib:libdl.1:dlcompat
 }
 
+variant cli {}
+
+
+variant apache_layout {
+	depends_lib-append	path:${prefix}/apache/bin/apxs:apache
+}
+
 variant apache {
-	depends_lib-append	path:${prefix}/apache-1.3.28/sbin/apxs:apache
-	configure.args-append --with-apxs=${prefix}/apache-1.3.28/sbin/apxs
+
+	if { ! [variant_isset apache_layout] } {
+		depends_lib-append	path:${prefix}/sbin/apxs:apache
+		configure.args-append 	--with-apxs=${prefix}/sbin/apxs
+	} else {
+		configure.args-append 	--with-apxs=${prefix}/apache/bin/apxs
+	}
 }
 
 variant apache2 {
-        depends_lib-append      path:${prefix}/apache2/bin/apxs:apache2
-	configure.args-append --with-apxs2=${prefix}/apache2/bin/apxs
+	depends_lib-append	path:${prefix}/apache2/bin/apxs:apache2
+	configure.args-append 	--with-apxs2=${apache2_path}/bin/apxs
+}
+
+variant crypt {
+	depends_lib-append	lib:libmhash:mhash \
+				lib:libmcrypt:libmcrypt
+	configure.args-append	--with-mhash=${prefix} --with-mcrypt=${prefix}
+}	
+
+variant curl {
+	depends_lib-append	lib:libcurl.2:curl
+	configure.args-append	--with-curl=${prefix}
+}
+
+variant gd {
+	depends_lib-append	lib:libjpeg.9:jpeg \
+				lib:libpng3:libpng
+						
+	
+	configure.args-append	--with-gd \
+				--with-jpeg-dir=${prefix} \
+				--with-png-dir=${prefix}
 }
 
 variant mysql {
@@ -57,6 +101,12 @@
 	configure.args-append	--with-mysql=${prefix}
 }
 
+variant mysql4 {
+	depends_lib-append	lib:libmysqlclient:mysql4
+	configure.args-append	--with-mysql=${prefix}
+}
+
+
 variant postgresql {
 	configure.env-append	LDFLAGS=-L${prefix}/lib -L${prefix}/pgsql
 					
@@ -64,27 +114,67 @@
 	configure.args-append	--with-pgsql=${prefix}/pgsql 
 }
 
-variant imap {
-	master_sites-append 	ftp://ftp.cac.washington.edu/imap/:imap\
-				http://distfiles.opendarwin.org/:imap
-	distfiles-append	imap-${imapversion}.tar.Z:imap
-	checksums-append	imap-2002d.tar.Z md5 64e82a195d21481fc4c54c4ed9fe0527
+variant ssl {
+	configure.args-append	--with-openssl=/usr
+}
 
-	extract.only		php-${version}.tar.gz imap-${imapversion}.tar.Z
-	configure.args-append 	--with-imap=../imap-${imapversion} --with-imap-ssl=/usr
+variant imap {
+	depends_lib-append		lib:c-client:cclient
+	configure.env-append	 CFLAGS=-I${prefix}/include/c-client
+	
+		
+	if { [variant_isset ssl] } {
+		configure.args-append 	--with-imap=${prefix} --with-imap-ssl=${prefix}
+	} else {
+		configure.args-append	--with-imap=${prefix}
+	}
 }
 
+variant xslt {
+	depends_lib-append	lib:libsablot:sablotron
+	
+	configure.args-append	--enable-xslt --with-xslt-sablot=${prefix}
+ }
+
 pre-configure {
-	if { [variant_isset imap] } {
-		system "cd ${workpath}/imap-${imapversion} && \
-						make osx SSLTYPE=nopwd"
-		system "cd ${workpath}/${worksrcdir}"
+	if { ![variant_isset cli] } {
+        	configure.args-append   --disable-cli
 	}
 }
 
-destroot.args	prefix=${destroot}${prefix}
-	
+destroot.args	INSTALL_ROOT=${destroot} PHP_PEAR_INSTALL_DIR=${prefix}/lib/php
+
+destroot.target	install-cli install-modules install-pear install-build install-headers install-programs
+
 post-destroot	{
+
+	#copy module
+	if { [variant_isset apache] } {
+	
+		if { ! [variant_isset apache_layout] } {
+			file mkdir ${destroot}${prefix}/libexec/apache
+			system "install -m 755 ${worksrcpath}/libs/libphp4.so ${destroot}${prefix}/libexec/apache/"
+			file mkdir ${destroot}${prefix}/etc/apache/extras-conf
+			system "install -o root -m 755 -c  ${portpath}/files/mod_php.conf ${destroot}$prefix/etc/apache/extras-conf"
+		} else {
+			file mkdir ${destroot}${prefix}/apache/libexec
+			system "install -m 755 ${worksrcpath}/libs/libphp4.so ${destroot}${prefix}/apache/libexec/"
+			file mkdir ${destroot}${prefix}/apache/conf/extras-conf
+			system "install -o root -m 755 -c  ${portpath}/files/mod_php.conf ${destroot}${prefix}/apache/conf/extras-conf"
+		}
+	} 
+	
+	if { [variant_isset apache2] } {
+		file mkdir ${destroot}${apache2_path}/modules
+		system "install -m 755 ${worksrcpath}/libs/libphp4.so ${destroot}${apache_path}/modules/"
+		file mkdir ${destroot}${apache2_path}/conf/extras-conf
+		system "install -o root -m 755 -c  ${portpath}/files/mod_php.conf ${destroot}${apache2_path}/conf/extras-conf"
+	} 
+
+
+	#copy php.ini
 	file mkdir ${destroot}${prefix}/etc
-	system "cp ${workpath}/${worksrcdir}/php.ini-dist ${destroot}${prefix}/etc/php.ini"
+	system "install -m 755 ${workpath}/${worksrcdir}/php.ini-dist ${destroot}${prefix}/etc/php.ini-dist"
+	system "install -m 755 ${workpath}/${worksrcdir}/php.ini-recommended ${destroot}${prefix}/etc/php.ini-recommended"
+
 }
