--- Portfile-orig	Tue Sep 30 23:38:31 2003
+++ Portfile	Thu Oct  2 02:23:47 2003
@@ -2,54 +2,90 @@
 
 PortSystem 1.0
 name            php4
-version         4.3.2
+version         4.3.4RC1	
 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}:rc
 worksrcdir	php-${version}
-master_sites 	http://fr.php.net/distributions/ \
-		http://www.php.net/distributions/
-checksums	php-4.3.2.tar.gz md5 8433a1d0ce679780990d4813ae094590
 
-depends_lib	lib:libcurl.2:curl \
-		lib:libiconv.2:libiconv \
+                
+checksums	php-4.3.4RC1.tar.gz 7c137aea5608ec1526b0f98f9c41d791
+
+patchfiles	patch-configure
+
+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
+set apache_path ${prefix}/${name}-${version}
+set apache2_path ${prefix}/apache2
+
+configure.env	LDFLAGS=-L${prefix}/lib \
+				CPPFLAGS=-I${prefix}/include \
+				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
+		
 variant darwin {
 	depends_lib-append	lib:libdl.1:dlcompat
 }
 
+variant cli {}
+
 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
+	depends_lib-append	path:${apache_path}/sbin/apxs:apache
+	configure.args-append 	--with-apxs=${apache_path}/sbin/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:${apache2_path}/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 +93,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 +106,59 @@
 	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=/usr
+	} 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] } {
+		file mkdir ${destroot}${apache_path}/libexec/apache
+		system "install -m 755 ${worksrcpath}/libs/libphp4.so ${destroot}${apache_path}/libexec/apache/"
+		file mkdir ${destroot}${apache_path}/etc/apache/extras-conf
+		system "install -o root -m 755 -c  ${portpath}/files/mod_php.conf ${destroot}${apache_path}/etc/apache/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"
+
 }
