--- old/usr/src/cmd/make/bin/main.cc	2015-05-20 11:53:25.323701093 -0400
+++ new/usr/src/cmd/make/bin/main.cc	2015-05-20 11:53:25.336586922 -0400
@@ -34,12 +34,6 @@
  */
 #if defined(TEAMWARE_MAKE_CMN)
 #       include <avo/intl.h>
-#       include <avo/libcli.h>          /* libcli_init() */
-#	include <avo/cli_license.h>	/* avo_cli_get_license() */
-#	include <avo/find_dir.h>	/* avo_find_run_dir() */
-#	include <avo/version_string.h>
-#	include <avo/util.h>		/* avo_init() */
-#	include <avo/cleanup.h>
 #endif
 
 #include <bsd/bsd.h>		/* bsd_signal() */
@@ -90,8 +84,13 @@
 /*
  * Defined macros
  */
-#define	LD_SUPPORT_ENV_VAR	NOCATGETS("SGS_SUPPORT")
+#define MAKE_PREFIX		NOCATGETS("/usr")
+#define	LD_SUPPORT_ENV_VAR	NOCATGETS("SGS_SUPPORT_32")
+#define	LD_SUPPORT_ENV_VAR_32	NOCATGETS("SGS_SUPPORT_32")
+#define	LD_SUPPORT_ENV_VAR_64	NOCATGETS("SGS_SUPPORT_64")
 #define	LD_SUPPORT_MAKE_LIB	NOCATGETS("libmakestate.so.1")
+#define	LD_SUPPORT_MAKE_LIB_DIR	NOCATGETS("/lib")
+#define	LD_SUPPORT_MAKE_LIB_DIR_64	NOCATGETS("/64")
 
 /*
  * typedefs & structs
@@ -131,7 +130,6 @@
 	static	time_t		start_time;
 	static	int		g_argc;
 	static	char		**g_argv;
-	static  Avo_cleanup	*cleanup = NULL;
 #endif
 
 /*
@@ -174,7 +172,7 @@
 	extern	XDR 		xdrs_out;
 #endif
 #ifdef TEAMWARE_MAKE_CMN
-	extern	char		verstring[];
+	static const char	verstring[] = "illumos make";
 #endif
 
 jmp_buf jmpbuffer;
@@ -229,9 +227,6 @@
 
 	struct stat		out_stat, err_stat;
 	hostid = gethostid();
-#ifdef TEAMWARE_MAKE_CMN
-	avo_get_user(NULL, NULL); // Initialize user name
-#endif
 	bsd_signals();
 
 	(void) setlocale(LC_ALL, "");
@@ -243,22 +238,8 @@
 	}
 #endif
 
-
-	/*
-	 * avo_init() sets the umask to 0.  Save it here and restore
-	 * it after the avo_init() call.
-	 */
-#if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
-	um = umask(0);
-	avo_init(argv[0]);
-	umask(um);
-
-	cleanup = new Avo_cleanup(NOCATGETS("dmake"), argc, argv);
-#endif
-
 #if defined(TEAMWARE_MAKE_CMN)
 	catd = catopen(AVO_DOMAIN_DMAKE, NL_CAT_LOCALE);
-	libcli_init();
 #endif
 
 // ---> fprintf(stderr, catgets(catd, 15, 666, "--- SUN make ---\n"));
@@ -532,8 +513,6 @@
 		}
 #else
 		if(dmake_mode_type == distributed_mode) {
-			(void) fprintf(stdout, NOCATGETS("dmake: Distributed mode not implemented.\n"));
-			(void) fprintf(stdout, NOCATGETS("       Defaulting to parallel mode.\n"));
 			dmake_mode_type = parallel_mode;
 			no_parallel = false;
 		}
@@ -544,29 +523,7 @@
 
 #ifdef TEAMWARE_MAKE_CMN
 	parallel_flag = true;
-	/* XXX - This is a major hack for DMake/Licensing. */
-	if (getenv(NOCATGETS("DMAKE_CHILD")) == NULL) {
-		if (!avo_cli_search_license(argv[0], dmake_exit_callback, TRUE, dmake_message_callback)) {
-			/*
-			 * If the user can not get a TeamWare license,
-			 * default to serial mode.
-			 */
-			dmake_mode_type = serial_mode;
-			no_parallel = true;
-		} else {
-			putenv(NOCATGETS("DMAKE_CHILD=TRUE"));
-		}
-		start_time = time(NULL);
-		/*
-		 * XXX - Hack to disable SIGALRM's from licensing library's
-		 *       setitimer().
-		 */
-		value.it_interval.tv_sec = 0;
-		value.it_interval.tv_usec = 0;
-		value.it_value.tv_sec = 0;
-		value.it_value.tv_usec = 0;
-		(void) setitimer(ITIMER_REAL, &value, NULL);
-	}
+	putenv(strdup(NOCATGETS("DMAKE_CHILD=TRUE")));
 
 //
 // If dmake is running with -t option, set dmake_mode_type to serial.
@@ -874,13 +831,6 @@
 	}
 	/* Write .make.state */
 	write_state_file(1, (Boolean) 1);
-
-#ifdef TEAMWARE_MAKE_CMN
-	// Deleting the usage tracking object sends the usage mail 
-	cleanup->set_exit_status(exit_status);
-	delete cleanup;
-#endif
-
 /*
 #ifdef DISTRIBUTED
     }
@@ -1869,46 +1819,80 @@
  *	  if it's not already in there.
  *	The SGS_SUPPORT env var and libmakestate.so.1 is used by
  *	  the linker ld to report .make.state info back to make.
+ *
+ * In the new world we always will set the 32-bit and 64-bit versions of this
+ * variable explicitly so that we can take into account the correct isa and our
+ * prefix. So say that the prefix was /opt/local. Then we would want to search
+ * /opt/local/lib/libmakestate.so.1:libmakestate.so.1. We still want to search
+ * the original location just as a safety measure.
  */
 static void
 set_sgs_support()
 {
 	int		len;
-	char		*newpath;
-	char		*oldpath;
-	static char	*prev_path;
+	char		*newpath, *newpath64;
+	char		*oldpath, *oldpath64;
+	static char	*prev_path, *prev_path64;
 
-	oldpath = getenv(LD_SUPPORT_ENV_VAR);
+	oldpath = getenv(LD_SUPPORT_ENV_VAR_32);
 	if (oldpath == NULL) {
-		len = strlen(LD_SUPPORT_ENV_VAR) + 1 +
-			strlen(LD_SUPPORT_MAKE_LIB) + 1;
+		len = snprintf(NULL, 0, "%s=%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_32,
+		    MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR,
+		    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB) + 1;
 		newpath = (char *) malloc(len);
-		sprintf(newpath, "%s=", LD_SUPPORT_ENV_VAR);
+		sprintf(newpath, "%s=%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_32,
+		    MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR,
+		    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB);
 	} else {
-		len = strlen(LD_SUPPORT_ENV_VAR) + 1 + strlen(oldpath) + 1 +
-			strlen(LD_SUPPORT_MAKE_LIB) + 1;
+		len = snprintf(NULL, 0, "%s=%s:%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_32, oldpath, MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB,
+		    LD_SUPPORT_MAKE_LIB) + 1;
 		newpath = (char *) malloc(len);
-		sprintf(newpath, "%s=%s", LD_SUPPORT_ENV_VAR, oldpath);
-	}
-
-#if defined(TEAMWARE_MAKE_CMN)
-
-	/* function maybe_append_str_to_env_var() is defined in avo_util library
-	 * Serial make should not use this library !!!
-	 */
-	maybe_append_str_to_env_var(newpath, LD_SUPPORT_MAKE_LIB);
-#else
-	if (oldpath == NULL) {
-		sprintf(newpath, "%s%s", newpath, LD_SUPPORT_MAKE_LIB);
+		sprintf(newpath, "%s=%s:%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_32, oldpath, MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB,
+		    LD_SUPPORT_MAKE_LIB);
+	}
+
+	oldpath64 = getenv(LD_SUPPORT_ENV_VAR_64);
+	if (oldpath64 == NULL) {
+		len = snprintf(NULL, 0, "%s=%s/%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_64, MAKE_PREFIX, LD_SUPPORT_MAKE_LIB_DIR,
+		    LD_SUPPORT_MAKE_LIB_DIR_64, LD_SUPPORT_MAKE_LIB,
+		    LD_SUPPORT_MAKE_LIB) + 1;
+		newpath64 = (char *) malloc(len);
+		sprintf(newpath64, "%s=%s/%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_64, MAKE_PREFIX, LD_SUPPORT_MAKE_LIB_DIR,
+		    LD_SUPPORT_MAKE_LIB_DIR_64, LD_SUPPORT_MAKE_LIB,
+		    LD_SUPPORT_MAKE_LIB);
 	} else {
-		sprintf(newpath, "%s:%s", newpath, LD_SUPPORT_MAKE_LIB);
+		len = snprintf(NULL, 0, "%s=%s:%s/%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_64, oldpath64, MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB_DIR_64,
+		    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB) + 1;
+		newpath64 = (char *) malloc(len);
+		sprintf(newpath64, "%s=%s:%s/%s/%s/%s:%s",
+		    LD_SUPPORT_ENV_VAR_64, oldpath64, MAKE_PREFIX,
+		    LD_SUPPORT_MAKE_LIB_DIR, LD_SUPPORT_MAKE_LIB_DIR_64,
+		    LD_SUPPORT_MAKE_LIB, LD_SUPPORT_MAKE_LIB);
 	}
-#endif
+
 	putenv(newpath);
 	if (prev_path) {
 		free(prev_path);
 	}
 	prev_path = newpath;
+
+	putenv(newpath64);
+	if (prev_path64) {
+		free(prev_path64);
+	}
+	prev_path64 = newpath64;
 }
 
 /*
