Merge remote-tracking branch 'origin/xdccore-A-sasha' into master_ggentree
diff --git a/src/packages/xdc/cfg/SourceDir.xs b/src/packages/xdc/cfg/SourceDir.xs
index 0ebde5b..934a3ac 100644
--- a/src/packages/xdc/cfg/SourceDir.xs
+++ b/src/packages/xdc/cfg/SourceDir.xs
@@ -43,18 +43,22 @@
 
         /* if not set in the environment, default to known layouts */
         if (outputDir == null) {
-	    if (xdc.om.$name == "cfg") {
-		/* default to CCS physical design */
-		outputDir = java.io.File(Program.build.cfgScript).parent;
-		this.toBuildDir = "..";
+            if (xdc.om.$name == "cfg") {
+                /* default to CCS physical design */
+                if (Program.build.cfgScript != null) {
+                    outputDir = java.io.File(Program.build.cfgScript).parent;
+                    this.toBuildDir = "..";
+                }
             }
             if (outputDir == null) {
-		/* if not in the cfg model, assume xdc physical design */
-		outputDir = ".";
-		this.toBuildDir = ".";
+                /* if not in the cfg model or no script is provided
+                 * assume xdc physical design 
+                 */
+                outputDir = ".";
+                this.toBuildDir = ".";
             }
             outputDir = outputDir + "/src";
-	}
+        }
         else {
             outputDir = unescape(outputDir);
         }
@@ -136,13 +140,13 @@
     /* try to use $XDCROOT/gmake, otherwise hope it's along user's path */
     var gmake = environment["xdc.root"] + "/gmake";
     if (!java.io.File(gmake).exists()) {
-	gmake = gmake + ".exe";
+        gmake = gmake + ".exe";
     }
     if (!java.io.File(gmake).exists()) {
         this.$logWarning("can't find gmake in XDCROOT ("
             + environment["xdc.root"]
             + "), trying gmake along your path ...", this);
-	gmake = "gmake";
+        gmake = "gmake";
     }
 
     /* do the build ... */
@@ -172,8 +176,8 @@
             envs: ["MAKEFLAGS=" + makeflags, "MAKELEVEL=0"],
             useEnv: true,
             merge: false,
-	    outStream: (verbose > 1) ? java.lang.System.out : null,
-	    errStream: (verbose > 1) ? java.lang.System.err : null,
+            outStream: (verbose > 1) ? java.lang.System.out : null,
+            errStream: (verbose > 1) ? java.lang.System.err : null,
             cwd   : genDir}, status);
 
     if (verbose) {
@@ -224,13 +228,13 @@
     var cTo = String(java.io.File(to).getCanonicalPath()).replace(/\\/g, '/');
     
     if (cFm == cTo) {
-	return ('.');
+        return ('.');
     }
 
     /* find longest common prefix */
     var len = cFm.length;
     for (var i = 0; i < cFm.length; i++) {
-	if (cFm[i] != cTo[i]) {
+        if (cFm[i] != cTo[i]) {
             /* cFm and cTo differ at j, backup to find closest '/' */
             for (var j = i - 1; j >= 0; j--) {
                 if (cFm[j] == '/') {
@@ -239,7 +243,7 @@
                 }
             }
             break;
-	}
+        }
     }
 
     /* get cTo suffix */
diff --git a/src/packages/xdc/cfg/makefile.xdt b/src/packages/xdc/cfg/makefile.xdt
index 7cae066..8f0f152 100644
--- a/src/packages/xdc/cfg/makefile.xdt
+++ b/src/packages/xdc/cfg/makefile.xdt
@@ -13,7 +13,7 @@
 %%}
 #
 # This file was generated based on the configuration script:
-#     `java.io.File(Program.build.cfgScript).getAbsolutePath()`
+#     `Program.build.cfgScript ? java.io.File(Program.build.cfgScript).getAbsolutePath() : "null"`
 #
 # This makefile may be included in other makefiles that need to build
 # the libraries containing the compiled source files generated as