Only change behavior when actually embedded in make

The change to enable embedding in make change the default behavior to
produce an Android.mk file, change the ninja builddir, and add the
-soong suffix to the end of target names. These don't make sense if
we're not building inside make, so detect if we're running under make
by checking for a .soong.in_make file in the builddir.

Change-Id: I1a0f4c1becb327c769b8a130cafef11d83eb49f4
diff --git a/common/module.go b/common/module.go
index 36710c5..bdaeb7a 100644
--- a/common/module.go
+++ b/common/module.go
@@ -331,9 +331,14 @@
 	}
 
 	if len(deps) > 0 {
+		suffix := ""
+		if ctx.Config().(Config).EmbeddedInMake() {
+			suffix = "-soong"
+		}
+
 		ctx.Build(pctx, blueprint.BuildParams{
 			Rule:      blueprint.Phony,
-			Outputs:   []string{ctx.ModuleName() + "-soong"},
+			Outputs:   []string{ctx.ModuleName() + suffix},
 			Implicits: deps,
 			Optional:  true,
 		})
@@ -568,10 +573,15 @@
 		}
 	})
 
+	suffix := ""
+	if ctx.Config().(Config).EmbeddedInMake() {
+		suffix = "-soong"
+	}
+
 	// Create a top-level checkbuild target that depends on all modules
 	ctx.Build(pctx, blueprint.BuildParams{
 		Rule:      blueprint.Phony,
-		Outputs:   []string{"checkbuild-soong"},
+		Outputs:   []string{"checkbuild" + suffix},
 		Implicits: checkbuildDeps,
 		Optional:  true,
 	})
@@ -583,7 +593,9 @@
 			Rule:      blueprint.Phony,
 			Outputs:   []string{filepath.Join("mm", dir)},
 			Implicits: dirModules[dir],
-			Optional:  true,
+			// HACK: checkbuild should be an optional build, but force it
+			// enabled for now in standalone builds
+			Optional:  ctx.Config().(Config).EmbeddedInMake(),
 		})
 	}
 }