--- Portfile-orig	Wed Oct 29 00:12:24 2003
+++ Portfile	Fri Nov 21 09:57:38 2003
@@ -2,54 +2,115 @@
 
 PortSystem 1.0
 name            php4
-version         4.3.2
-revision		1
-categories      www
+version         4.3.4	
+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}.tar.gz: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	${distname}.tar.gz md5 c0e7f7388fadacbf4948391c6d93dc5e             
+
+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
+		lib:libz.1:zlib \
+		lib:libtiff.3:tiff
+
+
 
-set imapversion 2002d
 				
-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
-
-variant darwin {
+		--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 
+		
+platform darwin 6 {
 	depends_lib-append	lib:libdl.1:dlcompat
+	configure.env	LDFLAGS=-L${prefix}/lib \
+					CPPFLAGS="-I${prefix}/include -no-cpp-precomp -DBIND_8_COMPAT" \
+					LIBS=-ldl
+					
+}
+
+platform darwin 7 {
+	configure.env	LDFLAGS="-L${prefix}/lib" \
+					CPPFLAGS="-I${prefix}/include -no-cpp-precomp" \
+					LIBS=-ldl
+					
+	
+}
+
+platform freebsd {
+	configure.env	LDFLAGS=-L${prefix}/lib \
+					CPPFLAGS="-I${prefix}/include
+}
+
+
+variant cli {}
+
+variant apache_layout {
+	depends_lib-append	path:${prefix}/apache/bin/apxs
 }
+	
+	
 
 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,34 +118,114 @@
 	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
-					
 	depends_lib-append	lib:plpgsql:postgresql
-	configure.args-append	--with-pgsql=${prefix}/pgsql 
+	configure.args-append	--with-pgsql=${prefix} 
+}
+
+variant ssl {
+	configure.args-append	--with-openssl
 }
 
 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
+	depends_lib-append		lib:c-client:cclient
+	configure.env-append	 CFLAGS=-I${prefix}/include/c-client
+	configure.args-append 	--with-imap=${prefix} --with-imap-ssl=/usr
+}
 
-	extract.only		php-${version}.tar.gz imap-${imapversion}.tar.Z
-	configure.args-append 	--with-imap=../imap-${imapversion} --with-imap-ssl=/usr
+variant xslt {
+	depends_lib-append	lib:libsablot:sablotron
+	
+	configure.args-append	--enable-xslt --with-xslt-sablot=${prefix} --with-iconv-dir=${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
+
+pre-destroot {
+	if { [variant_isset cli] } {
+		if {[variant_isset apache] || [variant_isset apache2]} {
+			destroot.target	install-cli install-modules install-pear install-build install-headers install-programs
+		}
+	} else {
+		destroot.target	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"
+
+	system "mv ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample"
+
+}
+
+post-install {
+	ui_msg "\nIf this your first install, you might want"
+	
+	if { [variant_isset apache] } {
+		ui_msg " * enable php in apache :\n"
+		
+		if { [variant_isset apache_layout] } {
+			ui_msg "cd ${prefix}/apache/libexec"
+		} else {
+			ui_msg "cd ${prefix}/libexec/apache"
+		}
+		
+		ui_msg "apxs -a -e -n \"php4\" libphp4.so\n"
+		ui_msg "* copy /etc/php.ini-dist to /etc/php.ini"
+	}
+	
+	if { [variant_isset apache2] } {
+		ui_msg "cd ${prefix}/apache2/libs"
+		ui_msg "apxs -a -e -n \"php4\" libphp4.so\n"
+		ui_msg "* copy /etc/php.ini-dist to /etc/php.ini"
+	}
+	
+	ui_msg "* copy /etc/pear.conf.sample to /etc/pear.conf" 
+	
+	
+	
 }
