[go] build specified targets or first target if not given.
diff --git a/cmd/kati/main.go b/cmd/kati/main.go
index be78703..2aee26e 100644
--- a/cmd/kati/main.go
+++ b/cmd/kati/main.go
@@ -321,7 +321,7 @@
 	if err != nil {
 		return err
 	}
-	err = ex.Exec(g)
+	err = ex.Exec(g, req.Targets)
 	if err != nil {
 		return err
 	}
diff --git a/exec.go b/exec.go
index 8aa7a0e..adf1c10 100644
--- a/exec.go
+++ b/exec.go
@@ -151,8 +151,8 @@
 	return ex, nil
 }
 
-// Exec executes to build roots.
-func (ex *Executor) Exec(g *DepGraph) error {
+// Exec executes to build targets, or first target in DepGraph.
+func (ex *Executor) Exec(g *DepGraph, targets []string) error {
 	ex.ctx = newExecContext(g.vars, g.vpaths, false)
 
 	// TODO: Handle target specific variables.
@@ -169,7 +169,24 @@
 	}
 
 	startTime := time.Now()
-	for _, root := range g.nodes {
+	var nodes []*DepNode
+	if len(targets) == 0 {
+		if len(g.nodes) > 0 {
+			nodes = append(nodes, g.nodes[0])
+		}
+	} else {
+		m := make(map[string]*DepNode)
+		for _, n := range g.nodes {
+			m[n.Output] = n
+		}
+		for _, t := range targets {
+			n := m[t]
+			if n != nil {
+				nodes = append(nodes, n)
+			}
+		}
+	}
+	for _, root := range nodes {
 		err := ex.makeJobs(root, nil)
 		if err != nil {
 			break