Index: Portfile
===================================================================
--- Portfile	(revision 41015)
+++ Portfile	(working copy)
@@ -50,26 +50,40 @@
 livecheck.url	${master_sites}
 livecheck.regex	${name}-(0.9.8\[a-z\])
 
-#make 4-way universal build ready
+if { ![info exists universal_archs] } {
+	set universal_archs {i386 ppc}
+	#set universal_archs {i386 x86_64 ppc ppc64}
+}
+set first_arch [lindex ${universal_archs} 0]
+
 variant universal {
 	post-patch {
-#		foreach arch {i386 x86_64 ppc ppc64}
-		foreach arch {i386 ppc} {
-			file copy ${worksrcpath} ${workpath}/${arch}
+		foreach arch ${universal_archs} {
+			if {[string equal ${arch} ${first_arch}]} {
+				move ${worksrcpath} ${workpath}/${first_arch}
+			} else {
+				copy ${workpath}/${first_arch} ${workpath}/${arch}
+			}
 		}
 	}
 
 	configure {
-		foreach arch {i386 ppc} {
-			system "cd ${workpath}/${arch} && ./Configure darwin-${arch}-cc ${configure.pre_args} ${configure.args}"
+		foreach arch ${universal_archs} {
+			if { [string first 64 $arch] == -1 } {
+				set my_cc "darwin-${arch}-cc"
+			} else {
+				if {[string first ppc $arch] != -1} {
+					set my_cc "darwin64-ppc-cc"
+				} else {
+					set my_cc "darwin64-${arch}-cc"
+				}
+			}
+			system "cd ${workpath}/${arch} && ./Configure ${my_cc} ${configure.pre_args} ${configure.args}"
 		}
-#		system "cd ${workpath}/x86_64 && ./Configure darwin64-x86_64-cc ${configure.pre_args} ${configure.args}"
-#		system "cd ${workpath}/ppc64 && ./Configure darwin64-ppc-cc ${configure.pre_args} ${configure.args}"
 	}
 
 	build {
-#		foreach arch {i386 x86_64 ppc ppc64}
-		foreach arch {i386 ppc} {
+		foreach arch ${universal_archs} {
 			system "cd ${workpath}/${arch} && make all"
 		}
 	}
@@ -78,10 +92,21 @@
 # in port 1.7, just call:
 #		merge "${workpath}/pre-dest"
 # till then, do this:
-#		foreach arch {i386 x86_64 ppc ppc64}
-		foreach arch {i386 ppc} {
+		foreach arch ${universal_archs} {
 			xinstall -d ${workpath}/pre-dest/${arch}
 			system "cd ${workpath}/${arch} && make install INSTALL_PREFIX=${workpath}/pre-dest/${arch} MANDIR=${prefix}/share/man"
+			
+			# opensslconf.h will differ between 32- and 64-bit, so patch it so it doesn't
+			if { [string first 64 $arch] != -1 } {
+				if { [string first ppc $arch] != -1 } {
+					set configpatch ${filespath}/patch-opensslconf.h-ppc64.diff
+				} else {
+					set configpatch ${filespath}/patch-opensslconf.h-x86_64.diff
+				}
+			} else {
+				set configpatch ${filespath}/patch-opensslconf.h-32.diff
+			}
+			system "cd ${workpath}/pre-dest/${arch}${prefix} && patch --no-backup-if-mismatch -p0 < ${configpatch}"
 		}
 
 		set basepath "${workpath}/pre-dest/i386"
@@ -109,23 +134,38 @@
 							Mach-O.* {
 								# Mach-O binaries get lipo-ed
 								ui_debug "Mach-O file -- lipo-ing"
-#								system "lipo -arch i386 ${workpath}/pre-dest/i386/${fpath} -arch x86_64 ${workpath}/pre-dest/x86_64/${fpath} -arch ppc ${workpath}/pre-dest/ppc/${fpath} -arch ppc64 ${workpath}/pre-dest/ppc64/${fpath} -create -output ${destroot}${fpath}"
-								system "lipo -arch i386 ${workpath}/pre-dest/i386/${fpath} -arch ppc ${workpath}/pre-dest/ppc/${fpath} -create -output ${destroot}${fpath}"
+								set machocmd "lipo"
+								foreach arch ${universal_archs} {
+									set machocmd "${machocmd} -arch $arch ${workpath}/pre-dest/${arch}/${fpath}"
+								}
+								set machocmd "${machocmd} -create -output ${destroot}${fpath}"
+								system ${machocmd}
 							}
 							current\ ar\ archive {
 								# ar archives get lipo-ed
 								ui_debug "ar archive -- lipo-ing"
-#								system "lipo -arch i386 ${workpath}/pre-dest/i386/${fpath} -arch x86_64 ${workpath}/pre-dest/x86_64/${fpath} -arch ppc ${workpath}/pre-dest/ppc/${fpath} -arch ppc64 ${workpath}/pre-dest/ppc64/${fpath} -create -output ${destroot}${fpath}"
-								system "lipo -arch i386 ${workpath}/pre-dest/i386/${fpath} -arch ppc ${workpath}/pre-dest/ppc/${fpath} -create -output ${destroot}${fpath}"
+								set arcmd "lipo"
+								foreach arch ${universal_archs} {
+									set arcmd "${arcmd} -arch $arch ${workpath}/pre-dest/${arch}/${fpath}"
+								}
+								set arcmd "${arcmd} -create -output ${destroot}${fpath}"
+								system ${arcmd}
 							}
 							default {
 								# unknown file types are copied IF they do not differ across ALL architectures -- if they do: This is an error!
 								ui_debug "unknown filetype: ${filetype}"
-								set differ1 [exec "/usr/bin/diff" "-q" "${workpath}/pre-dest/i386/${fpath}" "${workpath}/pre-dest/ppc/${fpath}"]
-#								set differ2 [exec "/usr/bin/diff" "-q" "${workpath}/pre-dest/i386/${fpath}" "${workpath}/pre-dest/x86_64/${fpath}"]
-#								set differ3 [exec "/usr/bin/diff" "-q" "${workpath}/pre-dest/i386/${fpath}" "${workpath}/pre-dest/ppc64/${fpath}"]
-								if {${differ1} != ""} {
-									ui_debug "ERROR"
+								
+								set any_difference no
+								foreach arch ${universal_archs} {
+									if {![string equal ${arch} ${first_arch}]} {
+										set differ1 [exec "/usr/bin/diff" "-q" "${workpath}/pre-dest/${first_arch}/${fpath}" "${workpath}/pre-dest/${arch}/${fpath}"]
+										if {![string equal ${differ1} ""]} {
+											set any_difference yes
+										}
+									}
+								}
+								if {${any_difference}} {
+									ui_debug "ERROR: files differ"
 								} else {
 									ui_debug "files match, just copying"
 									file copy "${basepath}${fpath}" "${destroot}${fpath}"

