Index: files/patch-Makefiles-universal-ppc
===================================================================
--- files/patch-Makefiles-universal-ppc	(revision 0)
+++ files/patch-Makefiles-universal-ppc	(revision 0)
@@ -0,0 +1,33 @@
+--- Makefile.orig	2007-04-01 18:13:46.000000000 +0200
++++ Makefile	2007-04-01 18:15:07.000000000 +0200
+@@ -60,7 +60,7 @@
+ # PKCS1_CHECK - pkcs1 tests.
+ 
+ CC= cc
+-CFLAG= -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DB_ENDIAN
++CFLAG= -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -DB_ENDIAN -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc
+ DEPFLAG= -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 
+ PEX_LIBS= 
+ EX_LIBS= -L/opt/local/lib  -lz
+@@ -142,7 +142,7 @@
+ SHARED_SSL=libssl$(SHLIB_EXT)
+ SHARED_LIBS=$(SHARED_CRYPTO) $(SHARED_SSL)
+ SHARED_LIBS_LINK_EXTS=.$(SHLIB_MAJOR).dylib .dylib
+-SHARED_LDFLAGS=-dynamiclib
++SHARED_LDFLAGS=-dynamiclib -arch ppc
+ 
+ GENERAL=        Makefile
+ BASENAME=       openssl
+--- Makefile.shared.orig	2007-04-01 18:16:24.000000000 +0200
++++ Makefile.shared	2007-04-01 18:16:55.000000000 +0200
+@@ -11,8 +11,8 @@
+ # LDFLAGS contains flags to be used when temporary object files (when building
+ # shared libraries) are created, or when an application is linked.
+ # SHARED_LDFLAGS contains flags to be used when the shared library is created.
+-LDFLAGS=-arch i386
+-SHARED_LDFLAGS=-arch i386
++LDFLAGS=-arch ppc
++SHARED_LDFLAGS=-arch ppc
+ 
+ # LIBNAME contains just the name of the library, without prefix ("lib"
+ # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
Index: files/patch-Makefile-universal-install
===================================================================
--- files/patch-Makefile-universal-install	(revision 0)
+++ files/patch-Makefile-universal-install	(revision 0)
@@ -0,0 +1,11 @@
+--- Makefile.orig	2007-04-02 05:42:04.000000000 +0200
++++ Makefile	2007-04-02 05:42:15.000000000 +0200
+@@ -475,7 +475,7 @@
+ dist_pem_h:
+ 	(cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
+ 
+-install: all install_docs install_sw
++install: install_docs install_sw
+ 
+ install_sw:
+ 	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
Index: files/patch-Makefiles-universal-i386
===================================================================
--- files/patch-Makefiles-universal-i386	(revision 0)
+++ files/patch-Makefiles-universal-i386	(revision 0)
@@ -0,0 +1,33 @@
+--- Makefile.orig	2007-04-01 18:13:46.000000000 +0200
++++ Makefile	2007-04-01 18:15:07.000000000 +0200
+@@ -60,7 +60,7 @@
+ # PKCS1_CHECK - pkcs1 tests.
+ 
+ CC= cc
+-CFLAG= -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -fomit-frame-pointer -fno-common
++CFLAG= -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -fomit-frame-pointer -fno-common -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386
+ DEPFLAG= -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 
+ PEX_LIBS= 
+ EX_LIBS= -L/opt/local/lib  -lz
+@@ -142,7 +142,7 @@
+ SHARED_SSL=libssl$(SHLIB_EXT)
+ SHARED_LIBS=$(SHARED_CRYPTO) $(SHARED_SSL)
+ SHARED_LIBS_LINK_EXTS=.$(SHLIB_MAJOR).dylib .dylib
+-SHARED_LDFLAGS=-dynamiclib
++SHARED_LDFLAGS=-dynamiclib -arch i386
+ 
+ GENERAL=        Makefile
+ BASENAME=       openssl
+--- Makefile.shared.orig	2007-04-01 18:16:24.000000000 +0200
++++ Makefile.shared	2007-04-01 18:16:55.000000000 +0200
+@@ -11,8 +11,8 @@
+ # LDFLAGS contains flags to be used when temporary object files (when building
+ # shared libraries) are created, or when an application is linked.
+ # SHARED_LDFLAGS contains flags to be used when the shared library is created.
+-LDFLAGS=
+-SHARED_LDFLAGS=
++LDFLAGS=-arch i386
++SHARED_LDFLAGS=-arch i386
+ 
+ # LIBNAME contains just the name of the library, without prefix ("lib"
+ # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
Index: Portfile
===================================================================
--- Portfile	(revision 23472)
+++ Portfile	(working copy)
@@ -46,3 +46,106 @@
 livecheck.check	regex
 livecheck.url	${master_sites}
 livecheck.regex	${name}-(0.9.8\[a-z\])
+
+variant foo {
+    
+# general procedures
+    proc backup {arch} {
+        global archList fileList workpath
+        lappend archList ${arch}
+        foreach fullPath ${fileList} {
+            regexp {(.+/)([^/]+)} ./$fullPath dummy filePath fileName
+            xinstall -d ${workpath}/${arch}/${filePath}
+            xinstall ${fullPath} ${workpath}/${arch}/${filePath}
+        }
+    }
+    proc lipo {} {
+        global archList fileList workpath
+        foreach fullPath ${fileList} {
+            regexp {(.+/)([^/]+)} ./$fullPath dummy filePath fileName
+            xinstall -d ${filePath}
+            file delete ${fullPath}
+            set lipoSources ""
+            foreach a $archList {
+                append lipoSources "-arch ${a} ${workpath}/${a}/${fullPath} "
+            }
+            system "lipo ${lipoSources}-create -output ${fullPath}"
+        }
+    }
+
+# special procedure
+    proc clean {} {
+        system "make clean"
+        foreach f [glob lib*.a lib*.*.*.*.dylib] {
+            file delete ${f}
+        }
+    }
+
+# i386
+    # configure
+    pre-configure {
+        cd ${worksrcpath}
+        system "./Configure darwin-i386-cc ${configure.pre_args} ${configure.args}"
+        system "patch < ${filespath}/patch-Makefiles-universal-i386"
+        reinplace "s|^PROCESSOR=.*|PROCESSOR=|" Makefile
+    }
+    # build
+    configure {
+        cd ${worksrcpath}
+        system "make"
+    }
+    # backup, clean up
+    post-configure {
+        cd ${worksrcpath}
+        # get list of files to be backed up - only needs to be done once
+        set binList     "apps/openssl"
+        set enList      [glob engines/*.so]
+        set libList     [glob lib*.a lib*.*.*.*.dylib]
+        set testList    [concat test/sha256t test/sha512t [glob test/*test]]
+
+        global fileList
+        set fileList    [concat $binList $enList $libList $testList]
+
+        backup i386
+
+        clean
+    }
+# ppc
+    # configure
+    pre-build {
+        cd ${worksrcpath}
+        system "./Configure darwin-ppc-cc ${configure.pre_args} ${configure.args}"
+        system "patch < ${filespath}/patch-Makefiles-universal-ppc"
+    }
+    # build
+    build {
+        cd ${worksrcpath}
+        system "make"
+    }
+    # backup
+    post-build {
+        cd ${worksrcpath}
+        # there's already a list of files to be backed up
+
+        global fileList
+
+        backup ppc
+
+        clean
+    }
+
+# universal
+    pre-destroot {
+        cd ${worksrcpath}
+        global fileList
+        system "make openssl.pc libssl.pc libcrypto.pc"
+        lipo
+        system "patch < ${filespath}/patch-Makefile-universal-install"
+    }
+    destroot.target     install_docs install_sw
+
+    # the test suite can only be run *after* destrooting
+    test.run            yes
+    test.dir            ${worksrcpath}/test
+    test.target         alltests
+}
