Index: dports/devel/apr/Portfile
===================================================================
--- dports/devel/apr/Portfile	(revision 49664)
+++ dports/devel/apr/Portfile	(working copy)
@@ -1,6 +1,7 @@
 # $Id$
 
 PortSystem	1.0
+PortGroup  muniversal 1.0
 
 name		apr
 version		1.3.3
@@ -34,6 +35,89 @@
 	use_parallel_build	no
 }
 
+# configure script expects to be able to run binaries
+if { ${os.arch}=="i386" } {
+    set universal_archs_supported  "i386 x86_64"
+} else {
+    set universal_archs_supported  "ppc ppc64"
+}
+
+set merger_dont_diff "${prefix}/bin/apr-1-config \
+    ${prefix}/share/apr-1/build/apr_rules.mk \
+    ${prefix}/share/apr-1/build/libtool"
+     
+# Don't append "-m32" or "-m64" to compiler command itself (only to the args) or libtool
+# won't work.
+set merger_arch_compiler "no"
+
+set diff_format_shell_ppc {--old-group-format='if test "x$TARGET_ARCH" != "xppc64"; then
+%<fi
+' --new-group-format='if test "x$TARGET_ARCH" = "xppc64"; then
+%>fi
+' --unchanged-group-format='%=' --changed-group-format='if test "x$TARGET_ARCH" = "xppc64"; then
+%>else
+%<fi
+'}
+
+set diff_format_make_ppc {--old-group-format='ifneq ($(TARGET_ARCH), ppc64)
+%<endif
+' --new-group-format='ifeq ($(TARGET_ARCH), ppc64)
+%>endif
+' --unchanged-group-format='%=' --changed-group-format='ifeq ($(TARGET_ARCH), ppc64)
+%>else
+%<endif
+'}
+
+set diff_format_shell_intel {--old-group-format='if test "x$TARGET_ARCH" != "xx86_64"; then
+%<fi
+' --new-group-format='if test "x$TARGET_ARCH" = "xx86_64"; then
+%>fi
+' --unchanged-group-format='%=' --changed-group-format='if test "x$TARGET_ARCH" = "xx86_64"; then
+%>else
+%<fi
+'}
+
+set diff_format_make_intel {--old-group-format='ifneq ($(TARGET_ARCH), x86_64)
+%<endif
+' --new-group-format='ifeq ($(TARGET_ARCH), x86_64)
+%>endif
+' --unchanged-group-format='%=' --changed-group-format='ifeq ($(TARGET_ARCH), x86_64)
+%>else
+%<endif
+'}
+
+post-destroot {
+    if {[variant_isset universal]} {
+        foreach fl ${merger_dont_diff} {
+            set fl [subst ${fl}]
+            if { ${os.arch}=="i386" } {
+                set fl64 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/x86_64-\1}]]
+                set fl32 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/i386-\1}]]
+                if { [file exists ${destroot}${fl32}] && [file exists ${destroot}${fl64}] } {
+                    if { [string match {*.mk} ${fl}] } {
+                        system "/usr/bin/diff -d ${diff_format_make_intel} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                    } else {
+                        system "/usr/bin/diff -d ${diff_format_shell_intel} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                        system "/bin/chmod a+x ${destroot}${fl}"
+                    }
+                }
+            } else {
+                set fl64 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/ppc64-\1}]]
+                set fl32 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/ppc-\1}]]
+                ui_debug "fl64: $fl64, fl32: $fl32"
+                if { [file exists ${destroot}${fl32}] && [file exists ${destroot}${fl64}] } {
+                    if { [string match {*.mk} ${fl}] } {
+                        system "/usr/bin/diff -d ${diff_format_make_ppc} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                    } else {
+                        system "/usr/bin/diff -d ${diff_format_shell_ppc} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                        system "/bin/chmod a+x ${destroot}${fl}"
+                    }
+                }
+            }
+        }
+    }
+}
+                        
 livecheck.check regex
 livecheck.url   http://apache.org/dist/apr/
 livecheck.regex {<a href="#apr">APR (\d+(?:\.\d+)*) is the latest available version</a>}
Index: dports/devel/apr-util/Portfile
===================================================================
--- dports/devel/apr-util/Portfile	(revision 49664)
+++ dports/devel/apr-util/Portfile	(working copy)
@@ -1,6 +1,7 @@
 # $Id$
 
 PortSystem 1.0
+PortGroup  muniversal 1.0
 
 name		apr-util
 version		1.3.4
@@ -29,6 +30,20 @@
 		--with-iconv=${prefix} --with-berkeley-db=${prefix}/include:${prefix}/lib/db46 \
 		--without-mysql --without-pgsql --with-sqlite3=${prefix}
 
+array set merger_configure_env {
+    ppc     TARGET_ARCH=ppc
+    i386    TARGET_ARCH=i386
+    ppc64   TARGET_ARCH=ppc64
+    x86_64  TARGET_ARCH=x86_64
+}
+
+array set merger_build_env {
+    ppc     TARGET_ARCH=ppc
+    i386    TARGET_ARCH=i386
+    ppc64   TARGET_ARCH=ppc64
+    x86_64  TARGET_ARCH=x86_64
+}
+
 test.run	yes
 test.target	check
 test.env	DYLD_LIBRARY_PATH=${worksrcpath}/.libs
@@ -36,7 +51,86 @@
 	use_parallel_build	no
 }
 
+# No cross architecture universal binaries
+if { ${os.arch}=="i386" } {
+    set universal_archs_supported  "i386 x86_64"
+} else {
+    set universal_archs_supported  "ppc ppc64"
+}
 
+set merger_dont_diff "${prefix}/bin/apu-1-config"
+          
+
+set diff_format_shell_ppc {--old-group-format='if test "x$TARGET_ARCH" != "xppc64"; then
+%<fi
+' --new-group-format='if test "x$TARGET_ARCH" = "xppc64"; then
+%>fi
+' --unchanged-group-format='%=' --changed-group-format='if test "x$TARGET_ARCH" = "xppc64"; then
+%>else
+%<fi
+'}
+
+set diff_format_make_ppc {--old-group-format='ifneq ($(TARGET_ARCH), ppc64)
+%<endif
+' --new-group-format='ifeq ($(TARGET_ARCH), ppc64)
+%>endif
+' --unchanged-group-format='%=' --changed-group-format='ifeq ($(TARGET_ARCH), ppc64)
+%>else
+%<endif
+'}
+
+set diff_format_shell_intel {--old-group-format='if test "x$TARGET_ARCH" != "xx86_64"; then
+%<fi
+' --new-group-format='if test "x$TARGET_ARCH" = "xx86_64"; then
+%>fi
+' --unchanged-group-format='%=' --changed-group-format='if test "x$TARGET_ARCH" = "xx86_64"; then
+%>else
+%<fi
+'}
+
+set diff_format_make_intel {--old-group-format='ifneq ($(TARGET_ARCH), x86_64)
+%<endif
+' --new-group-format='ifeq ($(TARGET_ARCH), x86_64)
+%>endif
+' --unchanged-group-format='%=' --changed-group-format='ifeq ($(TARGET_ARCH), x86_64)
+%>else
+%<endif
+'}
+
+post-destroot {
+    if {[variant_isset universal]} {
+        foreach fl ${merger_dont_diff} {
+            set fl [subst ${fl}]
+            if { ${os.arch}=="i386" } {
+                set fl64 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/x86_64-\1}]]
+                set fl32 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/i386-\1}]]
+                if { [file exists ${destroot}${fl32}] && [file exists ${destroot}${fl64}] } {
+                    if { [string match {*.mk} ${fl}] } {
+                        system "/usr/bin/diff -d ${diff_format_make_intel} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                    } else {
+                        system "/usr/bin/diff -d ${diff_format_shell_intel} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                        system "/bin/chmod a+x ${destroot}${fl}"
+                    }
+                }
+            } else {
+                set fl64 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/ppc64-\1}]]
+                set fl32 [regsub {/([^/]*)$} ${fl} [subst -nobackslashes {/ppc-\1}]]
+                ui_debug "fl64: $fl64, fl32: $fl32"
+                if { [file exists ${destroot}${fl32}] && [file exists ${destroot}${fl64}] } {
+                    if { [string match {*.mk} ${fl}] } {
+                        system "/usr/bin/diff -d ${diff_format_make_ppc} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                    } else {
+                        system "/usr/bin/diff -d ${diff_format_shell_ppc} ${destroot}${fl32} ${destroot}${fl64} > ${destroot}${fl}; test \$? -le 1"
+                        system "/bin/chmod a+x ${destroot}${fl}"
+                    }
+                }
+            }
+        }
+    }
+}
+                        
+
+
 variant no_bdb	description {Build without BerkeleyDB support} {
 			depends_lib-delete port:db46
 			configure.args-delete --with-berkeley-db=${prefix}/include:${prefix}/lib/db46
