Index: trunk/base/src/port1.0/portbuild.tcl
===================================================================
--- trunk/base/src/port1.0/portbuild.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portbuild.tcl	(revision 2118)
@@ -34,8 +34,7 @@
 
 set com.apple.build [target_new com.apple.build build_main]
-${com.apple.build} provides build
-${com.apple.build} requires main fetch extract checksum patch configure
-${com.apple.build} deplist depends_build depends_lib
-${com.apple.build} set prerun build_start
+target_provides ${com.apple.build} build
+target_requires ${com.apple.build} main fetch extract checksum patch configure
+target_prerun ${com.apple.build} build_start
 
 # define options
@@ -49,16 +48,13 @@
 default build.target "all"
 
-
 set UI_PREFIX "---> "
 
 proc build_getmaketype {args} {
-    global build.type build.cmd os.platform
-
-    if ![info exists build.type] {
+    if {![exists build.type]} {
 	return make
     }
-    switch -exact -- ${build.type} {
+    switch -exact -- [option build.type] {
 	bsd {
-	    if {${os.platform} == "darwin"} {
+	    if {[option os.platform] == "darwin"} {
 		return bsdmake
 	    } else {
@@ -67,5 +63,5 @@
 	}
 	gnu {
-	    if {${os.platform} == "darwin"} {
+	    if {[option os.platform] == "darwin"} {
 		return gnumake
 	    } else {
@@ -77,5 +73,5 @@
 	}
 	default {
-	    ui_warn "[format [msgcat::mc "Unknown build.type %s, using 'gnumake'"] ${build.type}]"
+	    ui_warn "[format [msgcat::mc "Unknown build.type %s, using 'gnumake'"] [option build.type]]"
 	    return gnumake
 	}
@@ -84,7 +80,7 @@
 
 proc build_start {args} {
-    global UI_PREFIX portname build.target
+    global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] ${portname} ${build.target}]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] [option portname] [option build.target]]"
 }
 
Index: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portchecksum.tcl	(revision 2118)
@@ -34,7 +34,7 @@
 
 set com.apple.checksum [target_new com.apple.checksum checksum_main]
-${com.apple.checksum} provides checksum
-${com.apple.checksum} requires main fetch
-${com.apple.checksum} set prerun checksum_start
+target_provides ${com.apple.checksum} checksum
+target_requires ${com.apple.checksum} main fetch
+target_prerun ${com.apple.checksum} checksum_start
 
 # define options
@@ -65,7 +65,5 @@
 
 proc dmd5 {file} {
-    global checksums
-
-    foreach {name type sum} $checksums {
+    foreach {name type sum} [option checksums] {
 	if {$name == $file} {
 	    return $sum
@@ -82,5 +80,5 @@
 
 proc checksum_main {args} {
-    global checksums distpath all_dist_files UI_PREFIX
+    global distpath all_dist_files UI_PREFIX
 
     # If no files have been downloaded there is nothing to checksum
@@ -89,5 +87,5 @@
     }
 
-    if ![info exists checksums] {
+    if {![exists checksums]} {
 	ui_error "[msgcat::mc "No checksums statement in Portfile.  File checksums are:"]"
 	foreach distfile $all_dist_files {
@@ -98,6 +96,6 @@
 
     # Optimization for the 2 argument case for checksums
-    if {[llength $checksums] == 2 && [llength $all_dist_files] == 1} {
-	set checksums [linsert $checksums 0 $all_dist_files]
+    if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} {
+	option checksums [linsert [option checksums] 0 $all_dist_files]
     }
 
Index: trunk/base/src/port1.0/portclean.tcl
===================================================================
--- trunk/base/src/port1.0/portclean.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portclean.tcl	(revision 2118)
@@ -36,18 +36,19 @@
 
 set com.apple.clean [target_new com.apple.clean clean_main]
-${com.apple.clean} set runtype always
-${com.apple.clean} provides clean
-${com.apple.clean} requires main
-${com.apple.clean} set prerun clean_start
+target_runtype ${com.apple.clean} always
+target_provides ${com.apple.clean} clean
+target_requires ${com.apple.clean} main
+target_prerun ${com.apple.clean} clean_start
+
+set UI_PREFIX "--->"
 
 proc clean_start {args} {
-    global UI_PREFIX portname
+    global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] $portname]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option portname]]"
 }
 
 proc clean_main {args} {
-    global workpath
-    exec rm -rf [file join ${workpath}]
+    exec rm -rf [file join [option workpath]]
     return 0
 }
Index: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portconfigure.tcl	(revision 2118)
@@ -34,8 +34,7 @@
 
 set com.apple.configure [target_new com.apple.configure configure_main]
-${com.apple.configure} provides configure
-${com.apple.configure} requires main fetch extract checksum patch
-${com.apple.configure} deplist depends_build depends_lib
-${com.apple.configure} set prerun configure_start
+target_provides ${com.apple.configure} configure
+target_requires ${com.apple.configure} main fetch extract checksum patch
+target_prerun ${com.apple.configure} configure_start
 
 # define options
@@ -54,7 +53,7 @@
 
 proc configure_start {args} {
-    global UI_PREFIX portname
+    global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] $portname]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]"
 }
 
Index: trunk/base/src/port1.0/portcontents.tcl
===================================================================
--- trunk/base/src/port1.0/portcontents.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portcontents.tcl	(revision 2118)
@@ -34,7 +34,7 @@
 
 set com.apple.contents [target_new com.apple.contents contents_main]
-${com.apple.contents} set runtype always
-${com.apple.contents} provides toc
-${com.apple.contents} requires main
+target_runtype ${com.apple.contents} always
+target_provides ${com.apple.contents} toc
+target_requires ${com.apple.contents} main
 
 set UI_PREFIX "---> "
Index: trunk/base/src/port1.0/portdepends.tcl
===================================================================
--- trunk/base/src/port1.0/portdepends.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portdepends.tcl	(revision 2118)
@@ -37,33 +37,23 @@
 
 # define options
-options depends_fetch depends_build depends_run depends_extract depends_lib
+options depends_build depends_run depends_lib
 # Export options via PortInfo
-options_export depends_lib depends_run
+options_export depends_build depends_lib depends_run
 
-option_proc depends_fetch handle_depends_options
-option_proc depends_build handle_depends_options
-option_proc depends_run handle_depends_options
-option_proc depends_extract handle_depends_options
-option_proc depends_lib handle_depends_options
+option_proc depends_build validate_depends_options
+option_proc depends_run validate_depends_options
+option_proc depends_lib validate_depends_options
 
-proc handle_depends_options {option action args} {
+proc validate_depends_options {option action args} {
     global targets
     switch -regex $action {
-	set|append {
+	set|append|delete {
 	    foreach depspec $args {
 			if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname] == 1} {
 				switch $deppath {
-					lib { set obj [libportfile_new $portname $depregex] }
-					bin { set obj [binportfile_new $portname $depregex] }
-					path { set obj [pathportfile_new $portname $depregex] }
-				}
-				if {[info exists obj]} {
-					$obj append provides $option portfile-$portname 
-					lappend targets $obj
-					foreach obj [depspec_get_matches $targets deplist $option] {
-						$obj append requires portfile-$portname
-					}
-				} else {
-					return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]
+					lib {}
+					bin {}
+					path {}
+					default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]}
 				}
 			} else {
@@ -72,7 +62,4 @@
 	    }
 	}
-	delete {
-	    # xxx: need to delete requirement from each item in the deplist
-	}
     }
 }
Index: trunk/base/src/port1.0/portextract.tcl
===================================================================
--- trunk/base/src/port1.0/portextract.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portextract.tcl	(revision 2118)
@@ -34,9 +34,8 @@
 
 set com.apple.extract [target_new com.apple.extract extract_main]
-${com.apple.extract} set init extract_init
-${com.apple.extract} provides extract
-${com.apple.extract} requires fetch checksum
-${com.apple.extract} deplist depends_extract
-${com.apple.extract} set prerun extract_start
+target_init ${com.apple.extract} extract_init
+target_provides ${com.apple.extract} extract
+target_requires ${com.apple.extract} fetch checksum
+target_prerun ${com.apple.extract} extract_start
 
 # define options
@@ -59,30 +58,30 @@
     global extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath
 
-    if [info exists use_bzip2] {
-	set extract.cmd bzip2
-    } elseif [info exists use_zip] {
-	set extract.cmd unzip
-	set extract.pre_args -q
-	set extract.post_args "-d ${extract.dir}"
+    if [exists use_bzip2] {
+		option extract.cmd bzip2
+    } elseif [exists use_zip] {
+		option extract.cmd unzip
+		option extract.pre_args -q
+		option extract.post_args "-d [option extract.dir]"
     }
 }
 
 proc extract_start {args} {
-    global UI_PREFIX portname
+    global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $portname]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option portname]]"
 }
 
 proc extract_main {args} {
-    global portname distname distpath distfiles use_bzip2 extract.only extract.cmd extract.before_args extract.after_args extract.args UI_PREFIX
+    global UI_PREFIX
 
-    if {![info exists distfiles] && ![info exists extract.only]} {
+    if {![exists distfiles] && ![exists extract.only]} {
 	# nothing to do
 	return 0
     }
 
-    foreach distfile ${extract.only} {
+    foreach distfile [option extract.only] {
 	ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile] ... " -nonewline
-	set extract.args "$distpath/$distfile"
+	option extract.args "[option distpath]/$distfile"
 	if [catch {system "[command extract]"} result] {
 	    return -code error "$result"
Index: trunk/base/src/port1.0/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/portfetch.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portfetch.tcl	(revision 2118)
@@ -34,9 +34,8 @@
 
 set com.apple.fetch [target_new com.apple.fetch fetch_main]
-${com.apple.fetch} set init fetch_init
-${com.apple.fetch} provides fetch
-${com.apple.fetch} requires main
-${com.apple.fetch} deplist depends_fetch
-${com.apple.fetch} set prerun fetch_start
+target_init ${com.apple.fetch} fetch_init
+target_provides ${com.apple.fetch} fetch
+target_requires ${com.apple.fetch} main
+target_prerun ${com.apple.fetch} fetch_start
 
 # define options: distname master_sites
Index: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portinstall.tcl	(revision 2118)
@@ -34,10 +34,9 @@
 
 set com.apple.install [target_new com.apple.install install_main]
-${com.apple.install} set runtype always
-${com.apple.install} provides install
-${com.apple.install} requires main fetch extract checksum patch configure build 
-${com.apple.install} deplist depends_run depends_lib
-${com.apple.install} set prerun install_start
-${com.apple.install} set postrun install_registry
+target_runtype ${com.apple.install} always
+target_provides ${com.apple.install} install
+target_requires ${com.apple.install} main fetch extract checksum patch configure build 
+target_prerun ${com.apple.install} install_start
+target_postrun ${com.apple.install} install_registry
 
 # define options
Index: trunk/base/src/port1.0/portmain.tcl
===================================================================
--- trunk/base/src/port1.0/portmain.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portmain.tcl	(revision 2118)
@@ -37,5 +37,5 @@
 
 set com.apple.main [target_new com.apple.main main]
-${com.apple.main} provides main
+target_provides ${com.apple.main} main
 
 # define options
Index: trunk/base/src/port1.0/portmpkg.tcl
===================================================================
--- trunk/base/src/port1.0/portmpkg.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portmpkg.tcl	(revision 2118)
@@ -34,7 +34,7 @@
 
 set com.apple.mpkg [target_new com.apple.mpkg mpkg_main]
-${com.apple.mpkg} set runtype always
-${com.apple.mpkg} provides mpkg
-${com.apple.mpkg} requires package
+target_runtype ${com.apple.mpkg} always
+target_provides ${com.apple.mpkg} mpkg
+target_requires ${com.apple.mpkg} package
 
 # define options
Index: trunk/base/src/port1.0/portpackage.tcl
===================================================================
--- trunk/base/src/port1.0/portpackage.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portpackage.tcl	(revision 2118)
@@ -34,7 +34,7 @@
 
 set com.apple.package [target_new com.apple.package package_main]
-${com.apple.package} set runtype always
-${com.apple.package} provides package
-${com.apple.package} requires install
+target_runtype ${com.apple.package} always
+target_provides ${com.apple.package} package
+target_requires ${com.apple.package} install
 
 # define options
@@ -77,5 +77,5 @@
     system "mkbom ${destpath} ${pkgpath}/Contents/Archive.bom"
     system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.bom ${portname}-${portversion}.bom"
-    system "cd ${destpath} && pax -w -z . > ${pkgpath}/Contents/Archive.pax.gz"
+    system "cd ${destpath} && pax -x cpio -w -z . > ${pkgpath}/Contents/Archive.pax.gz"
     system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.pax.gz ${portname}-${portversion}.pax.gz"
 
Index: trunk/base/src/port1.0/portpatch.tcl
===================================================================
--- trunk/base/src/port1.0/portpatch.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portpatch.tcl	(revision 2118)
@@ -34,7 +34,6 @@
 
 set com.apple.patch [target_new com.apple.patch patch_main]
-${com.apple.patch} provides patch
-${com.apple.patch} requires main fetch checksum extract 
-${com.apple.patch} deplist depends_build depends_lib
+target_provides ${com.apple.patch} patch
+target_requires ${com.apple.patch} main fetch checksum extract 
 
 set UI_PREFIX "---> "
@@ -48,16 +47,16 @@
 
 proc patch_main {args} {
-    global portname patchfiles distpath filespath workpath worksrcpath UI_PREFIX
+    global UI_PREFIX
 
     # First make sure that patchfiles exists and isn't stubbed out.
-    if ![info exists patchfiles] {
+    if {![exists patchfiles]} {
 	return 0
     }
 
-    foreach patch $patchfiles {
-	if [file exists $filespath/$patch] {
-	    lappend patchlist $filespath/$patch
-	} elseif [file exists $distpath/$patch] {
-	    lappend patchlist $distpath/$patch
+    foreach patch [option patchfiles] {
+	if [file exists [option filespath]/$patch] {
+	    lappend patchlist [option filespath]/$patch
+	} elseif [file exists [option distpath]/$patch] {
+	    lappend patchlist [option distpath]/$patch
 	}
     }
@@ -65,5 +64,5 @@
 	return -code error [msgcat::mc "Patch files missing"]
     }
-    cd ${worksrcpath}
+    cd [option worksrcpath]
     foreach patch $patchlist {
 	ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] $patch]"
Index: trunk/base/src/port1.0/portuninstall.tcl
===================================================================
--- trunk/base/src/port1.0/portuninstall.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portuninstall.tcl	(revision 2118)
@@ -34,8 +34,8 @@
 
 set com.apple.uninstall [target_new com.apple.uninstall uninstall_main]
-${com.apple.uninstall} set runtype always
-${com.apple.uninstall} provides uninstall
-${com.apple.uninstall} requires main
-${com.apple.uninstall} set prerun uninstall_start
+target_runtype ${com.apple.uninstall} always
+target_provides ${com.apple.uninstall} uninstall
+target_requires ${com.apple.uninstall} main
+target_prerun ${com.apple.uninstall} uninstall_start
 
 # define options
Index: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	(revision 2102)
+++ trunk/base/src/port1.0/portutil.tcl	(revision 2118)
@@ -32,4 +32,5 @@
 package provide portutil 1.0
 package require Pextlib 1.0
+package require darwinports_dlist 1.0
 package require msgcat
 
@@ -44,4 +45,35 @@
 
 namespace eval options {
+}
+
+# option
+# This is an accessor for Portfile options.  Targets may use
+# this in the same style as the standard Tcl "set" procedure.
+#	name  - the name of the option to read or write
+#	value - an optional value to assign to the option
+
+proc option {name args} {
+	# XXX: right now we just transparently use globals
+	# eventually this will need to bridge the options between
+	# the Portfile's interpreter and the target's interpreters.
+	global $name
+	if {[llength $args] > 0} {
+		ui_debug "setting option $name to $args"
+		set $name [lindex $args 0]
+	}
+	return [set $name]
+}
+
+# exists
+# This is an accessor for Portfile options.  Targets may use
+# this procedure to test for the existence of a Portfile option.
+#	name - the name of the option to test for existence
+
+proc exists {name} {
+	# XXX: right now we just transparently use globals
+	# eventually this will need to bridge the options between
+	# the Portfile's interpreter and the target's interpreters.
+	global $name
+	return [info exists $name]
 }
 
@@ -253,5 +285,5 @@
     set args [lrange $args 0 [expr $len - 2]]
     
-    set obj [variant_new "temp-variant"]
+    set ditem [variant_new "temp-variant"]
     
     # mode indicates what the arg is interpreted as.
@@ -265,16 +297,16 @@
 			requires { set mode "requires" }
 			conflicts { set mode "conflicts" }
-			default { $obj append $mode $arg }		
+			default { ditem_append $ditem $mode $arg }		
         }
     }
-    $obj set name "[join [$obj get provides] -]"
+    ditem_key $ditem name "[join [ditem_key $ditem provides] -]"
 
     # make a user procedure named variant-blah-blah
     # we will call this procedure during variant-run
-    makeuserproc "variant-[$obj get name]" \{$code\}
-    lappend all_variants $obj
+    makeuserproc "variant-[ditem_key $ditem name]" \{$code\}
+    lappend all_variants $ditem
     
     # Export provided variant to PortInfo
-    lappend PortInfo(variants) [$obj get provides]
+    lappend PortInfo(variants) [ditem_key $ditem provides]
 }
 
@@ -400,143 +432,13 @@
 ########### Internal Dependancy Manipulation Procedures ###########
 
-# returns a depspec by name
-proc dlist_get_by_name {dlist name} {
-    set result ""
-    foreach d $dlist {
-	if {[$d get name] == $name} {
-	    set result $d
-	    break
-	}
-    }
-    return $result
-}
-
-# returns a list of depspecs that contain the given name in the given key
-proc depspec_get_matches {dlist key value} {
-    set result [list]
-    foreach d $dlist {
-	foreach val [$d get $key] {
-	    if {$val == $value} {
-		lappend result $d
-	    }
-	}
-    }
-    return $result
-}
-
-# Count the unmet dependencies in the dlist based on the statusdict
-proc dlist_count_unmet {dlist statusdict names} {
-    upvar $statusdict upstatusdict
-    set unmet 0
-    foreach name $names {
-	# Service was provided, check next.
-	if {[info exists upstatusdict($name)] && $upstatusdict($name) == 1} {
-	    continue
-	} else {
-	    incr unmet
-	}
-    }
-    return $unmet
-}
-
-# Returns true if any of the dependencies are pending in the dlist
-proc dlist_has_pending {dlist uses} {
-    foreach name $uses {
-	if {[llength [depspec_get_matches $dlist provides $name]] > 0} {
-	    return 1
-	}
-    }
-    return 0
-}
-
-# Get the name of the next eligible item from the dependency list
-proc generic_get_next {dlist statusdict} {
-    set nextitem ""
-    # arbitrary large number ~ INT_MAX
-    set minfailed 2000000000
-    upvar $statusdict upstatusdict
-    
-    foreach obj $dlist {		
-	# skip if unsatisfied hard dependencies
-	if {[dlist_count_unmet $dlist upstatusdict [$obj get requires]]} { continue }
-	
-	# favor item with fewest unment soft dependencies
-	set unmet [dlist_count_unmet $dlist upstatusdict [$obj get uses]]
-	
-	# delay items with unmet soft dependencies that can be filled
-	if {$unmet > 0 && [dlist_has_pending $dlist [$obj get uses]]} { continue }
-	
-	if {$unmet >= $minfailed} {
-	    # not better than our last pick
-	    continue
-	} else {
-	    # better than our last pick
-	    set minfailed $unmet
-	    set nextitem $obj
-	}
-    }
-    return $nextitem
-}
-
-
-# Evaluate the list of depspecs, running each as it becomes eligible.
-# dlist is a collection of depspec objects to be run
-# get_next_proc is used to determine the best item to run
-proc dlist_evaluate {dlist get_next_proc} {
-    global portname
-    
-    # status - keys will be node names, values will be {-1, 0, 1}.
-    array set statusdict [list]
-    
-    # XXX: Do we want to evaluate this dynamically instead of statically? 
-    foreach obj $dlist {
-	if {[$obj test] == 1} {
-	    foreach name [$obj get provides] {
-		set statusdict($name) 1
-	    }
-	    ldelete dlist $obj
-	}
-    }
-    
-    # loop for as long as there are nodes in the dlist.
-    while (1) {
-	set obj [$get_next_proc $dlist statusdict]
-	
-	if {$obj == ""} { 
-	    break
-	} else {
-	    catch {$obj run} result
-	    # depspec->run returns an error code, so 0 == success.
-	    # translate this to the statusdict notation where 1 == success.
-	    foreach name [$obj get provides] {
-		set statusdict($name) [expr $result == 0]
-	    }
-	    
-	    # Delete the item from the waiting list.
-	    ldelete dlist $obj
-	}
-    }
-    
-    if {[llength $dlist] > 0} {
-	# somebody broke!
-	ui_info "Warning: the following items did not execute (for $portname): "
-	foreach obj $dlist {
-	    ui_info "[$obj get name] " -nonewline
-	}
-	ui_info ""
-	return 1
-    }
-    return 0
-}
-
-proc target_run {this} {
+proc target_run {ditem} {
     global target_state_fd portname
     set result 0
-    set procedure [$this get procedure]
+    set procedure [ditem_key $ditem procedure]
     if {$procedure != ""} {
-	set name [$this get name]
-	
-	if {[$this has init]} {
-	    set result [catch {[$this get init] $name} errstr]
+	set name [ditem_key $ditem name]
+	
+	if {[ditem_contains $ditem init]} {
+	    set result [catch {[ditem_key $ditem init] $name} errstr]
 	}
 	
@@ -546,10 +448,10 @@
 	} elseif {$result == 0} {
 	    # Execute pre-run procedure
-	    if {[$this has prerun]} {
-		set result [catch {[$this get prerun] $name} errstr]
+	    if {[ditem_contains $ditem prerun]} {
+		set result [catch {[ditem_key $ditem prerun] $name} errstr]
 	    }
 	    
 	    if {$result == 0} {
-		foreach pre [$this get pre] {
+		foreach pre [ditem_key $ditem pre] {
 		    ui_debug "Executing $pre"
 		    set result [catch {$pre $name} errstr]
@@ -564,5 +466,5 @@
 	    
 	    if {$result == 0} {
-		foreach post [$this get post] {
+		foreach post [ditem_key $ditem post] {
 		    ui_debug "Executing $post"
 		    set result [catch {$post $name} errstr]
@@ -571,6 +473,6 @@
 	    }
 	    # Execute post-run procedure
-	    if {[$this has postrun] && $result == 0} {
-		set postrun [$this get postrun]
+	    if {[ditem_contains $ditem postrun] && $result == 0} {
+		set postrun [ditem_key $ditem postrun]
 		ui_debug "Executing $postrun"
 		set result [catch {$postrun $name} errstr]
@@ -578,5 +480,5 @@
 	}
 	if {$result == 0} {
-	    if {[$this get runtype] != "always"} {
+	    if {[ditem_key $ditem runtype] != "always"} {
 		write_statefile target $name $target_state_fd
 	    }
@@ -595,43 +497,38 @@
 
 proc eval_targets {target} {
-    global targets target_state_fd
+    global targets target_state_fd portname
     set dlist $targets
-    
-    # Select the subset of targets under $target
+	    
+	# Select the subset of targets under $target
     if {$target != ""} {
-        set matches [depspec_get_matches $dlist provides $target]
+        set matches [dlist_search $dlist provides $target]
+
         if {[llength $matches] > 0} {
-	    set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
-	    # Special-case 'all'
-        } elseif {$target != "all"} {
-            ui_info "unknown target: $target"
+			set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
+			# Special-case 'all'
+		} elseif {$target != "all"} {
+			ui_info "unknown target: $target"
             return 1
         }
     }
-    
+	
     # Restore the state from a previous run.
     set target_state_fd [open_statefile]
     
-    set ret [dlist_evaluate $dlist generic_get_next]
-    
+    set dlist [dlist_eval $dlist "" target_run]
+
+    if {[llength $dlist] > 0} {
+		# somebody broke!
+		ui_info "Warning: the following items did not execute (for $portname): "
+		foreach ditem $dlist {
+			ui_info "[ditem_key $ditem name] " -nonewline
+		}
+		ui_info ""
+		set result 1
+	} else {
+		set result 0
+	}
+	
     close $target_state_fd
-    return $ret
-}
-
-# returns the names of dependents of <name> from the <itemlist>
-proc dlist_append_dependents {dlist obj result} {
-    
-    # Append the item to the list, avoiding duplicates
-    if {[lsearch $result $obj] == -1} {
-	lappend result $obj
-    }
-    
-    # Recursively append any hard dependencies
-    foreach dep [$obj get requires] {
-	foreach provider [depspec_get_matches $dlist provides $dep] {
-	    set result [dlist_append_dependents $dlist $provider $result]
-        }
-    }
-    # XXX: add soft-dependencies?
     return $result
 }
@@ -759,10 +656,10 @@
     set selected [list]
     
-    foreach obj $dlist {
+    foreach ditem $dlist {
 	# Enumerate through the provides, tallying the pros and cons.
 	set pros 0
 	set cons 0
 	set ignored 0
-	foreach flavor [$obj get provides] {
+	foreach flavor [ditem_key $ditem provides] {
 	    if {[info exists upvariations($flavor)]} {
 		if {$upvariations($flavor) == "+"} {
@@ -779,5 +676,5 @@
 	
 	if {$pros > 0 && $ignored == 0} {
-	    lappend selected $obj
+	    lappend selected $ditem
 	}
     }
@@ -785,10 +682,10 @@
 }
 
-proc variant_run {this} {
-    set name [$this get name]
-    ui_debug "Executing $name provides [$this get provides]"
+proc variant_run {ditem} {
+    set name [ditem_key $ditem name]
+    ui_debug "Executing $name provides [ditem_key $ditem provides]"
 
 	# test for conflicting variants
-	foreach v [$this get conflicts] {
+	foreach v [ditem_key $ditem conflicts] {
 		if {[variant_isset $v]} {
 			ui_error "Variant $name conflicts with $v"
@@ -823,5 +720,5 @@
     }
     
-    dlist_evaluate $newlist generic_get_next
+    dlist_eval $newlist "" variant_run
 	
 	# Make sure the variations match those stored in the statefile.
@@ -852,139 +749,20 @@
 }
 
-##### DEPSPEC #####
-
-# Object-Oriented Depspecs
-#
-# Each depspec will have its data stored in an array
-# (indexed by field name) and its procedures will be
-# called via the dispatch procedure that is returned
-# from depspec_new.
-#
-# sample usage:
-# set obj [depspec_new]
-# $obj set name "hello"
-#
-
-# Depspec
-#	str name
-#	str provides[]
-#	str requires[]
-#	str uses[]
-
-global depspec_uniqid
-set depspec_uniqid 0
-
-# Depspec class definition.
-global depspec_vtbl
-set depspec_vtbl(test) depspec_test
-set depspec_vtbl(run) depspec_run
-set depspec_vtbl(get) depspec_get
-set depspec_vtbl(set) depspec_set
-set depspec_vtbl(has) depspec_has
-set depspec_vtbl(append) depspec_append
-
-# constructor for abstract depspec class
-proc depspec_new {name} {
-    global depspec_uniqid
-    set id [incr depspec_uniqid]
-    
-    # declare the array of data
-    set data dpspc_data_${id}
-    set disp dpspc_disp_${id}
-    
-    global $data 
-    set ${data}(name) $name
-    set ${data}(_vtbl) depspec_vtbl
-    
-    eval "proc $disp {method args} { \n \
-			global $data \n \
-			eval return \\\[depspec_dispatch $disp $data \$method \$args\\\] \n \
-		}"
-    
-    return $disp
-}
-
-proc depspec_get {this prop} {
-    set data [$this _data]
-    global $data
-    if {[eval info exists ${data}($prop)]} {
-	eval return $${data}($prop)
-    } else {
-	return ""
-    }
-}
-
-proc depspec_set {this prop args} {
-    set data [$this _data]
-    global $data
-    eval "set ${data}($prop) \"$args\""
-}
-
-proc depspec_has {this prop} {
-    set data [$this _data]
-    global $data
-    eval return \[info exists ${data}($prop)\]
-}
-
-proc depspec_append {this prop args} {
-    set data [$this _data]
-    global $data
-    set vals [join $args " "]
-    eval lappend ${data}($prop) $vals
-}
-
-# is the only proc to get direct access to the object's data
-# so the _data accessor has to be defined here.  all other
-# methods are looked up in the virtual function table,
-# and are called with {$this $args}.
-proc depspec_dispatch {this data method args} {
-    global $data
-    if {$method == "_data"} { return $data }
-    eval set vtbl $${data}(_vtbl)
-    global $vtbl
-    if {[info exists ${vtbl}($method)]} {
-	eval set function $${vtbl}($method)
-	eval "return \[$function $this $args\]"
-    } else {
-	ui_error "unknown method: $method"
-    }
-    return ""
-}
-
-proc depspec_test {this} {
-    return 0
-}
-
-proc depspec_run {this} {
-    return 0
-}
-
-##### target depspec subclass #####
-
 # Target class definition.
-global target_vtbl
-array set target_vtbl [array get depspec_vtbl]
-set target_vtbl(run) target_run
-set target_vtbl(provides) target_provides
-set target_vtbl(requires) target_requires
-set target_vtbl(uses) target_uses
-set target_vtbl(deplist) target_deplist
-set target_vtbl(prerun) target_prerun
-set target_vtbl(postrun) target_postrun
-
-# constructor for target depspec class
+
+# constructor for target object
 proc target_new {name procedure} {
     global targets
-    set obj [depspec_new $name]
-    
-    $obj set _vtbl target_vtbl
-    $obj set procedure $procedure
-    
-    lappend targets $obj
-    
-    return $obj
-}
-
-proc target_provides {this args} {
+    set ditem [ditem_create]
+	
+	ditem_key $ditem name $name
+	ditem_key $ditem procedure $procedure
+    
+    lappend targets $ditem
+    
+    return $ditem
+}
+
+proc target_provides {ditem args} {
     global targets
     # Register the pre-/post- hooks for use in Portfile.
@@ -993,11 +771,11 @@
     # Thus if the user code breaks, dependent targets will not execute.
     foreach target $args {
-	set origproc [$this get procedure]
-	set ident [$this get name]
+	set origproc [ditem_key $ditem procedure]
+	set ident [ditem_key $ditem name]
 	if {[info commands $target] != ""} {
-	    ui_debug "[$this get name] registered provides \'$target\', a pre-existing procedure. Target override will not be provided"
+	    ui_debug "$ident registered provides \'$target\', a pre-existing procedure. Target override will not be provided"
 	} else {
 		eval "proc $target {args} \{ \n\
-			$this set procedure proc-${ident}-${target}
+			ditem_key $ditem procedure proc-${ident}-${target}
 			eval \"proc proc-${ident}-${target} \{name\} \{ \n\
 				if \{\\\[catch userproc-${ident}-${target} result\\\]\} \{ \n\
@@ -1012,5 +790,5 @@
 	}
 	eval "proc pre-$target {args} \{ \n\
-			$this append pre proc-pre-${ident}-${target}
+			ditem_append $ditem pre proc-pre-${ident}-${target}
 			eval \"proc proc-pre-${ident}-${target} \{name\} \{ \n\
 				if \{\\\[catch userproc-pre-${ident}-${target} result\\\]\} \{ \n\
@@ -1023,5 +801,5 @@
 		\}"
 	eval "proc post-$target {args} \{ \n\
-			$this append post proc-post-${ident}-${target}
+			ditem_append $ditem post proc-post-${ident}-${target}
 			eval \"proc proc-post-${ident}-${target} \{name\} \{ \n\
 				if \{\\\[catch userproc-post-${ident}-${target} result\\\]\} \{ \n\
@@ -1034,41 +812,42 @@
 		\}"
     }
-    eval "depspec_append $this provides $args"
-}
-
-proc target_requires {this args} {
-    eval "depspec_append $this requires $args"
-}
-
-proc target_uses {this args} {
-    eval "depspec_append $this uses $args"
-}
-
-proc target_deplist {this args} {
-    eval "depspec_append $this deplist $args"
-}
-
-proc target_prerun {this args} {
-    eval "depspec_append $this prerun $args"
-}
-
-proc target_postrun {this args} {
-    eval "depspec_append $this postrun $args"
-}
-
-##### variant depspec subclass #####
-
-# Variant class definition.
-global variant_vtbl
-array set variant_vtbl [array get depspec_vtbl]
-set variant_vtbl(run) variant_run
-
-# constructor for target depspec class
+    eval "ditem_append $ditem provides $args"
+}
+
+proc target_requires {ditem args} {
+    eval "ditem_append $ditem requires $args"
+}
+
+proc target_uses {ditem args} {
+    eval "ditem_append $ditem uses $args"
+}
+
+proc target_deplist {ditem args} {
+    eval "ditem_append $ditem deplist $args"
+}
+
+proc target_prerun {ditem args} {
+    eval "ditem_append $ditem prerun $args"
+}
+
+proc target_postrun {ditem args} {
+    eval "ditem_append $ditem postrun $args"
+}
+
+proc target_runtype {ditem args} {
+	eval "ditem_append $ditem runtype $args"
+}
+
+proc target_init {ditem args} {
+    eval "ditem_append $ditem init $args"
+}
+
+##### variant class #####
+
+# constructor for variant objects
 proc variant_new {name} {
-    set obj [depspec_new $name]
-    
-    $obj set _vtbl variant_vtbl
-    
-    return $obj
+    set ditem [ditem_create]
+    ditem_key $ditem name $name
+    return $ditem
 }
 
@@ -1091,32 +870,4 @@
 }
 
-##### portfile depspec subclass #####
-global portfile_vtbl
-array set portfile_vtbl [array get depspec_vtbl]
-set portfile_vtbl(run) portfile_run
-set portfile_vtbl(test) portfile_test
-
-proc portfile_new {name} {
-    set obj [depspec_new $name]
-    
-    $obj set _vtbl portfile_vtbl
-    
-    return $obj
-}
-
-# portfile primitive that calls portexec_int with newworkpath == ${workpath}
-proc portexec {portname target} {
-	global workpath
-	portexec_int $portname $target $workpath
-}
-
-# build the specified portfile with default workpath
-proc portfile_run {this} {
-    set portname [$this get name]
-    if {![catch {portexec_int $portname install} result]} {
-		portexec_int $portname clean 
-    }
-    return $result
-}
 
 # builds the specified port (looked up in the index) to the specified target
@@ -1157,14 +908,4 @@
 }
 
-proc portfile_test {this} {
-    set receipt [registry_exists [$this get name]]
-    if {$receipt != ""} {
-	ui_debug "Found Dependency: receipt: $receipt"
-	return 1
-    } else {
-	return 0
-    }
-}
-
 proc portfile_search_path {depregex search_path} {
     set found 0
@@ -1184,20 +925,4 @@
 }
 
-
-
-##### lib portfile depspec subclass #####
-# Search registry, then library path for regex
-global libportfile_vtbl
-array set libportfile_vtbl [array get portfile_vtbl]
-set libportfile_vtbl(test) libportfile_test
-
-proc libportfile_new {name match} {
-    set obj [portfile_new $name]
-    
-    $obj set _vtbl libportfile_vtbl
-    $obj set depregex $match
-    
-    return $obj
-}
 
 # XXX - Architecture specific
@@ -1243,19 +968,4 @@
 }
 
-##### bin portfile depspec subclass #####
-# Search registry, then binary path for regex
-global binportfile_vtbl
-array set binportfile_vtbl [array get portfile_vtbl]
-set binportfile_vtbl(test) binportfile_test
-
-proc binportfile_new {name match} {
-    set obj [portfile_new $name]
-    
-    $obj set _vtbl binportfile_vtbl
-    $obj set depregex $match
-    
-    return $obj
-}
-
 proc binportfile_test {this} {
     global env prefix 
@@ -1275,19 +985,4 @@
 	return [portfile_search_path $depregex $search_path]
     }
-}
-
-##### path portfile depspec subclass #####
-# Search registry, then search specified absolute or
-# ${prefix} relative path for regex
-global pathportfile_vtbl
-array set pathportfile_vtbl [array get portfile_vtbl]
-set pathportfile_vtbl(test) pathportfile_test
-
-proc pathportfile_new {name match} {
-    set obj [portfile_new $name]
-    
-    $obj set _vtbl pathportfile_vtbl
-    $obj set depregex $match
-    return $obj
 }
 
