Index: trunk/base/src/port1.0/portbuild.tcl
===================================================================
--- trunk/base/src/port1.0/portbuild.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portbuild.tcl	(revision 1015)
@@ -33,8 +33,8 @@
 package require portutil 1.0
 
-register com.apple.build target build_main
-register com.apple.build provides build 
-register com.apple.build requires main fetch extract checksum patch configure
-register com.apple.build deplist depends_build depends_lib
+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
 
 # define options
Index: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portchecksum.tcl	(revision 1015)
@@ -33,7 +33,7 @@
 package require portutil 1.0
 
-register com.apple.checksum target checksum_main
-register com.apple.checksum provides checksum
-register com.apple.checksum requires main fetch
+set com.apple.checksum [target_new com.apple.checksum checksum_main]
+${com.apple.checksum} provides checksum
+${com.apple.checksum} requires main fetch
 
 # define options
Index: trunk/base/src/port1.0/portclean.tcl
===================================================================
--- trunk/base/src/port1.0/portclean.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portclean.tcl	(revision 1015)
@@ -35,7 +35,8 @@
 package require portutil 1.0
 
-register com.apple.clean target clean_main always
-register com.apple.clean provides clean
-register com.apple.clean requires main
+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
 
 proc clean_main {args} {
Index: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portconfigure.tcl	(revision 1015)
@@ -33,8 +33,8 @@
 package require portutil 1.0
 
-register com.apple.configure target configure_main
-register com.apple.configure provides configure
-register com.apple.configure requires main fetch extract checksum patch
-register com.apple.configure deplist depends_build depends_lib
+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
 
 # define options
Index: trunk/base/src/port1.0/portextract.tcl
===================================================================
--- trunk/base/src/port1.0/portextract.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portextract.tcl	(revision 1015)
@@ -33,9 +33,9 @@
 package require portutil 1.0
 
-register com.apple.extract target extract_main
-register com.apple.extract init extract_init
-register com.apple.extract provides extract
-register com.apple.extract requires fetch checksum
-register com.apple.extract deplist depends_extract
+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
 
 # define options
Index: trunk/base/src/port1.0/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/portfetch.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portfetch.tcl	(revision 1015)
@@ -33,9 +33,9 @@
 package require portutil 1.0
 
-register com.apple.fetch target fetch_main
-register com.apple.fetch init fetch_init
-register com.apple.fetch provides fetch
-register com.apple.fetch requires main
-register com.apple.fetch deplist depends_fetch
+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
 
 # define options: distname master_sites
Index: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portinstall.tcl	(revision 1015)
@@ -33,8 +33,8 @@
 package require portutil 1.0
 
-register com.apple.install target install_main
-register com.apple.install provides install
-register com.apple.install requires main fetch extract checksum patch configure build 
-register com.apple.install deplist depends_run depends_lib
+set com.apple.install [target_new com.apple.install install_main]
+${com.apple.install} provides install
+${com.apple.install} requires main fetch extract checksum patch configure build 
+${com.apple.install} deplist depends_run depends_lib
 
 # define options
Index: trunk/base/src/port1.0/portmain.tcl
===================================================================
--- trunk/base/src/port1.0/portmain.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portmain.tcl	(revision 1015)
@@ -36,6 +36,6 @@
 package require portutil 1.0
 
-register com.apple.main target main
-register com.apple.main provides main
+set com.apple.main [target_new com.apple.main main]
+${com.apple.main} provides main
 
 # define options
Index: trunk/base/src/port1.0/portpackage.tcl
===================================================================
--- trunk/base/src/port1.0/portpackage.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portpackage.tcl	(revision 1015)
@@ -33,7 +33,8 @@
 package require portutil 1.0
 
-register com.apple.package target package_main always
-register com.apple.package provides packager
-register com.apple.package requires registry
+set com.apple.package [target_new com.apple.package package_main]
+${com.apple.package} set runtype always
+${com.apple.package} provides packager
+${com.apple.package} requires registry
 
 # define options
Index: trunk/base/src/port1.0/portpatch.tcl
===================================================================
--- trunk/base/src/port1.0/portpatch.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portpatch.tcl	(revision 1015)
@@ -33,8 +33,8 @@
 package require portutil 1.0
 
-register com.apple.patch target patch_main
-register com.apple.patch provides patch
-register com.apple.patch requires main fetch checksum extract 
-register com.apple.patch deplist depends_build depends_lib
+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
 
 set UI_PREFIX "---> "
Index: trunk/base/src/port1.0/portregistry.tcl
===================================================================
--- trunk/base/src/port1.0/portregistry.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portregistry.tcl	(revision 1015)
@@ -33,8 +33,8 @@
 package require portutil 1.0
 
-register com.apple.registry target registry_main
-register com.apple.registry provides registry
-register com.apple.registry requires main fetch extract checksum patch configure build install 
-register com.apple.registry deplist depends_run depends_lib
+set com.apple.registry [target_new com.apple.registry registry_main]
+${com.apple.registry} provides registry
+${com.apple.registry} requires main fetch extract checksum patch configure build install 
+${com.apple.registry} deplist depends_run depends_lib
 
 # define options
Index: trunk/base/src/port1.0/portuninstall.tcl
===================================================================
--- trunk/base/src/port1.0/portuninstall.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portuninstall.tcl	(revision 1015)
@@ -33,7 +33,8 @@
 package require portutil 1.0
 
-register com.apple.uninstall target uninstall_main always
-register com.apple.uninstall provides uninstall
-register com.apple.uninstall requires main
+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
 
 # define options
Index: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	(revision 1006)
+++ trunk/base/src/port1.0/portutil.tcl	(revision 1015)
@@ -384,141 +384,4 @@
 }
 
-########### External Dependancy Manipulation Procedures ###########
-# register
-# Creates a target in the global target list using the internal dependancy
-#     functions
-# Arguments: <identifier> <mode> <args ...>
-# The following modes are supported:
-#	<identifier> target <procedure to execute> [run type]
-#	<identifier> init <procedure to execute>
-#	<identifier> prerun <procedure to execute>
-#	<identifier> postrun <procedure to execute>
-#	<identifier> provides <list of target names>
-#	<identifier> requires <list of target names>
-#	<identifier> uses <list of target names>
-#	<identifier> deplist <list of deplist names>
-#	<provides> preflight <proc name>
-#	<provides> postflight <proc name>
-proc register {name mode args} {
-    global targets target_uniqid
-    
-    set obj [dlist_get_by_name $targets $name]
-    if {$obj == ""} {
-	set obj [target_new $name]
-	lappend targets $obj
-    }
-    
-    if {$mode == "target"} {
-        set procedure [lindex $args 0]
-        if {[$obj has procedure]} {
-            ui_debug "Warning: target '$name' re-registered (new procedure: '$procedure')"
-        }
-        $obj set procedure $procedure
-	
-	# Set runtype {always,once} if available
-	if {[llength $args] >= 2} {
-	    $obj set runtype [lindex $args 1]
-	}
-    } elseif {$mode == "init"} {
-	set init [lindex $args 0]
-	if {[$obj has init]} {
-	    ui_debug "Warning: target '$name' re-registered init procedure (new procedure: '$init')"
-	}
-	$obj set init $init
-    } elseif {$mode == "prerun"} {
-	set prerun [lindex $args 0]
-	if {[$obj has prerun]} {
-	    ui_debug "Warning: target '$name' re-registered pre-run procedure (new procedure: '$prerun')"
-	}
-	$obj prerun $prerun
-    } elseif {$mode == "postrun"} {
-	set postrun [lindex $args 0]
-	if {[$obj has postrun]} {
-	    ui_debug "Warning: target '$name' re-registered post-run procedure (new procedure: '$postrun')"
-	}
-	$obj set postrun $postrun
-    } elseif {$mode == "requires" || $mode == "uses" || $mode == "provides"} {
-	$obj append $mode $args
-        
-        if {$mode == "provides"} {
-            # If it's a provides, register the pre-/post- hooks for use in Portfile.
-            # Portfile syntax: pre-fetch { puts "hello world" }
-            # User-code exceptions are caught and returned as a result of the target.
-            # Thus if the user code breaks, dependent targets will not execute.
-            foreach target $args {
-		if {[info commands $target] != ""} {
-		    ui_error "$name attempted to register provide \'$target\' which is a pre-existing procedure. Ignoring register."
-		    continue;
-		}
-                set ident [lindex [depspec_get_matches $targets provides $args] 0]
-                set origproc [$ident get procedure]
-		set ident [$ident get name]
-                eval "proc $target {args} \{ \n\
-					global target_uniqid \n\
-					set id \[incr target_uniqid\] \n\
-                    register $ident target proc-$target\$id \n\
-                    eval \"proc proc-$target\$id \{name\} \{ \n\
-                        if \\\[catch userproc-$target\$id result\\\] \{ \n\
-							ui_info \\\$result \n\
-							return 1 \n\
-						\} else \{ \n\
-							return 0 \n\
-						\} \n\
-                    \}\" \n\
-                    eval \"proc do-$target \{\} \{ $origproc $target\}\" \n\
-                    makeuserproc userproc-$target\$id \$args \}"
-                eval "proc pre-$target {args} \{ \n\
-					global target_uniqid \n\
-					set id \[incr target_uniqid\] \n\
-                    register $target preflight pre-$target\$id \n\
-                    eval \"proc pre-$target\$id \{name\} \{ \n\
-                        if \\\[catch userproc-pre-$target\$id result\\\] \{ \n\
-							ui_info \\\$result \n\
-							return 1 \n\
-						\} else \{ \n\
-							return 0 \n\
-						\} \n\
-                    \}\" \n\
-                    makeuserproc userproc-pre-$target\$id \$args \}"
-                eval "proc post-$target {args} \{ \n\
-					global target_uniqid \n\
-					set id \[incr target_uniqid\] \n\
-                    register $target postflight post-$target\$id \n\
-                    eval \"proc post-$target\$id \{name\} \{ \n\
-                        if \\\[catch userproc-post-$target\$id result\\\] \{ \n\
-							ui_info \\\$result \n\
-							return 1 \n\
-						\} else \{ \n\
-							return 0 \n\
-						\} \n\
-                    \}\" \n\
-                    makeuserproc userproc-post-$target\$id \$args \}"
-            }
-        }
-	
-    } elseif {$mode == "deplist"} {
-	$obj append $mode $args
-	
-    } elseif {$mode == "preflight"} {
-	# Find target which provides the specified name, and add a preflight.
-	# XXX: this only returns the first match, is this what we want?
-	set obj [lindex [depspec_get_matches $targets provides $name] 0]
-	$obj append pre $args
-	
-    } elseif {$mode == "postflight"} {
-	# Find target which provides the specified name, and add a preflight.
-	# XXX: this only returns the first match, is this what we want?
-	set obj [lindex [depspec_get_matches $targets provides $name] 0]
-	$obj append post $args
-    }
-}
-
-
-# unregister
-# Unregisters a target in the global target list
-# Arguments: target <target name>
-proc unregister {mode target} {
-}
-
 ########### Internal Dependancy Manipulation Procedures ###########
 
@@ -974,5 +837,5 @@
 	set data [$this _data]
 	global $data
-	eval set ${data}($prop) $args
+	eval "set ${data}($prop) \"$args\""
 }
 
@@ -1022,12 +885,96 @@
 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
-proc target_new {name} {
-    set obj [depspec_new $name]
+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} {
+	global targets
+	# Register the pre-/post- hooks for use in Portfile.
+	# Portfile syntax: pre-fetch { puts "hello world" }
+	# User-code exceptions are caught and returned as a result of the target.
+	# Thus if the user code breaks, dependent targets will not execute.
+	foreach target $args {
+		if {[info commands $target] != ""} {
+			ui_error "$name attempted to register provide \'$target\' which is a pre-existing procedure. Ignoring register."
+			continue;
+		}
+		set origproc [$this get procedure]
+		set ident [$this get name]
+		eval "proc $target {args} \{ \n\
+			$this set procedure proc-${ident}-${target}
+			eval \"proc proc-${ident}-${target} \{name\} \{ \n\
+				if \{\\\[catch userproc-${ident}-${target} result\\\]\} \{ \n\
+					ui_info \\\$result \n\
+					return 1 \n\
+				\} else \{ \n\
+					return 0 \n\
+				\} \n\
+			\}\" \n\
+			eval \"proc do-$target \{\} \{ $origproc $target\}\" \n\
+			makeuserproc userproc-${ident}-${target} \$args \n\
+		\}"
+		eval "proc pre-$target {args} \{ \n\
+			$this append pre proc-pre-${ident}-${target}
+			eval \"proc proc-pre-${ident}-${target} \{name\} \{ \n\
+				if \{\\\[catch userproc-pre-${ident}-${target} result\\\]\} \{ \n\
+					ui_info \\\$result \n\
+					return 1 \n\
+				\} else \{ \n\
+					return 0 \n\
+				\} \n\
+			\}\" \n\
+			makeuserproc userproc-pre-${ident}-${target} \$args \n\
+		\}"
+		eval "proc post-$target {args} \{ \n\
+			$this append post proc-post-${ident}-${target}
+			eval \"proc proc-post-${ident}-${target} \{name\} \{ \n\
+				if \{\\\[catch userproc-post-${ident}-${target} result\\\]\} \{ \n\
+					ui_info \\\$result \n\
+					return 1 \n\
+				\} else \{ \n\
+					return 0 \n\
+				\} \n\
+			\}\" \n\
+			makeuserproc userproc-post-${ident}-${target} \$args \n\
+		\}"
+	}
+	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"
 }
 
