--- old/usr/src/cmd/make/Makefile.com	2015-05-20 11:53:23.789186992 -0400
+++ new/usr/src/cmd/make/Makefile.com	2015-05-20 11:53:23.800839701 -0400
@@ -12,7 +12,7 @@
 # Copyright 2015, Richard Lowe.
 
 MAKE_INCLUDE= $(SRC)/cmd/make/include
-MAKE_DEFS= -DSYSV -DINTER
+MAKE_DEFS= -DSYSV -DINTER -DTEAMWARE_MAKE_CMN
 $(RELEASE_BUILD)MAKE_DEFS += -DNDEBUG
 CFLAGS += $(CCVERBOSE)
 CPPFLAGS += -I$(MAKE_INCLUDE) $(MAKE_DEFS)
--- old/usr/src/cmd/make/bin/Makefile	2015-05-20 11:53:24.188496166 -0400
+++ new/usr/src/cmd/make/bin/Makefile	2015-05-20 11:53:24.200106776 -0400
@@ -22,7 +22,6 @@
 	implicit.o	\
 	macro.o		\
 	main.o		\
-	make.o		\
 	misc.o		\
 	nse_printdep.o	\
 	parallel.o	\
@@ -36,7 +35,7 @@
 include ../Makefile.com
 
 LDLIBS += ../lib/mksh/libmksh.a ../lib/mksdmsi18n/libmksdmsi18n.a ../lib/vroot/libvroot.a
-LDLIBS += ../lib/bsd/libbsd.a -lc
+LDLIBS += ../lib/bsd/libbsd.a -lc -lnsl -lumem
 
 CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
--- old/usr/src/cmd/make/bin/doname.cc	2015-05-20 11:53:24.605504455 -0400
+++ new/usr/src/cmd/make/bin/doname.cc	2015-05-20 11:53:24.617895745 -0400
@@ -33,9 +33,6 @@
  * Included files
  */
 #include <alloca.h>		/* alloca() */
-#if defined(TEAMWARE_MAKE_CMN)
-#include <avo/util.h>		/* avo_get_user(), avo_hostname() */
-#endif
 
 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
 #	include <avo/strings.h>	/* AVO_STRDUP() */
@@ -3301,11 +3298,9 @@
 	Chain			cond_name;
 	Chain			cond_chain;
 
-#ifdef DISTRIBUTED
 	if (target->dont_activate_cond_values) {
 		return;
 	}
-#endif
 
 	saved_conditional_macro_used = conditional_macro_used;
 
@@ -3362,11 +3357,9 @@
 	register Property	this_conditional;
 	Chain			cond_chain;
 
-#ifdef DISTRIBUTED
 	if (target->dont_activate_cond_values) {
 		return;
 	}
-#endif
 
 	/* Scan the list of conditional properties and restore the old value */
 	/* to each one Reverse the order relative to when we assigned macros */
--- 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;
 }
 
 /*
--- old/usr/src/cmd/make/bin/misc.cc	2015-05-20 11:53:26.485850745 -0400
+++ new/usr/src/cmd/make/bin/misc.cc	2015-05-20 11:53:26.497925289 -0400
@@ -137,7 +137,7 @@
  */
 /*VARARGS*/
 void
-fatal(char * message, ...)
+fatal(const char *message, ...)
 {
 	va_list args;
 
--- old/usr/src/cmd/make/bin/parallel.cc	2015-05-20 11:53:27.034936970 -0400
+++ new/usr/src/cmd/make/bin/parallel.cc	2015-05-20 11:53:27.048791514 -0400
@@ -41,7 +41,6 @@
 #endif
 #include <errno.h>		/* errno */
 #include <fcntl.h>
-#include <avo/util.h>		/* avo_get_user(), avo_hostname() */
 #include <mk/defs.h>
 #include <mksh/dosys.h>		/* redirect_io() */
 #include <mksh/macro.h>		/* expand_value() */
@@ -52,6 +51,7 @@
 #include <sys/utsname.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <netdb.h>
 
 
 
@@ -145,11 +145,8 @@
 
 	if ((pmake_max_jobs == 0) &&
 	    (dmake_mode_type == parallel_mode)) {
-		if (user_name[0] == '\0') {
-			avo_get_user(user_name, NULL);
-		}
 		if (local_host[0] == '\0') {
-			strcpy(local_host, avo_hostname());
+			(void) gethostname(local_host, MAXNAMELEN);
 		}
 		MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
 		dmake_name = GETNAME(wcs_buffer, FIND_LENGTH);
@@ -669,7 +666,7 @@
 		warning(catgets(catd, 1, 339, "Encountered max jobs auto adjustment error - disabling auto adjustment."));
 
 		/* switch off job adjustment for the children */
-		putenv(NOCATGETS("DMAKE_ADJUST_MAX_JOBS=NO"));
+		putenv(strdup(NOCATGETS("DMAKE_ADJUST_MAX_JOBS=NO")));
 
 		/* and for this dmake */
 		job_adjust_mode = ADJUST_NONE;
@@ -1736,16 +1733,6 @@
 	rp->target = target;
 	rp->true_target = true_target;
 	rp->command = command;
-	Property spro_val = get_prop(sunpro_dependencies->prop, macro_prop);
-	if(spro_val) {
-		rp->sprodep_value = spro_val->body.macro.value;
-		spro_val->body.macro.value = NULL;
-		spro_val = get_prop(sunpro_dependencies->prop, env_mem_prop);
-		if(spro_val) {
-			rp->sprodep_env = spro_val->body.env_mem.value;
-			spro_val->body.env_mem.value = NULL;
-		}
-	}
 	rp->recursion_level = recursion_level;
 	rp->do_get = do_get;
 	rp->implicit = implicit;
--- old/usr/src/cmd/make/include/mk/defs.h	2015-05-20 11:53:27.816052444 -0400
+++ new/usr/src/cmd/make/include/mk/defs.h	2015-05-20 11:53:27.827888820 -0400
@@ -371,7 +371,7 @@
 extern	Doname		execute_parallel(Property line, Boolean waitflg, Boolean local = false);
 extern	Doname		execute_serial(Property line);
 extern	timestruc_t&  	exists(register Name target);
-extern	void		fatal(char *, ...);
+extern	void		fatal(const char *, ...);
 extern	void		fatal_reader(char *, ...);
 extern	Doname		find_ar_suffix_rule(register Name target, Name true_target, Property *command, Boolean rechecking);
 extern	Doname		find_double_suffix_rule(register Name target, Property *command, Boolean rechecking);
--- old/usr/src/cmd/make/lib/mksdmsi18n/libmksdmsi18n_init.cc	2015-05-20 11:53:28.521743038 -0400
+++ new/usr/src/cmd/make/lib/mksdmsi18n/libmksdmsi18n_init.cc	2015-05-20 11:53:28.536651224 -0400
@@ -39,7 +39,6 @@
 	char		name[20];
 
 	if (getenv(NOCATGETS("NLSPATH")) == NULL) {
-		fprintf(stderr, NOCATGETS("Internal error: Set NLSPATH before opening catalogue file\n"));
 		return 1;
 	}
 	sprintf(name, NOCATGETS("libmksdmsi18n_%d"), I18N_VERSION);
--- old/usr/src/cmd/make/lib/mksh/dosys.cc	2015-05-20 11:53:29.371989572 -0400
+++ new/usr/src/cmd/make/lib/mksh/dosys.cc	2015-05-20 11:53:29.385335084 -0400
@@ -37,7 +37,6 @@
 #include <alloca.h>		/* alloca() */
 
 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL) /* tolik */
-#	include <avo/strings.h>	/* AVO_STRDUP() */
 #if defined(DISTRIBUTED)
 #	include <dm/Avo_CmdOutput.h>
 #	include <rw/xdrstrea.h>
@@ -635,7 +634,7 @@
 	SEND_MTOOL_MSG(
 		make_output_msg = new Avo_CmdOutput();
 		(void) sprintf(tmp_buf, "%d", job_msg_id);
-		make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
+		make_output_msg->appendOutput(strdup(tmp_buf));
 	);
 
 	tmp_buf[0] = (int) nul_char;
@@ -678,7 +677,7 @@
 		(void) fprintf(stdout, "\n");
 		(void) fflush(stdout);
 		SEND_MTOOL_MSG(
-			make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
+			make_output_msg->appendOutput(strdup(tmp_buf));
 		);
 	}
 	SEND_MTOOL_MSG(
--- old/usr/src/cmd/make/lib/mksh/mksh.cc	2015-05-20 11:53:29.856338780 -0400
+++ new/usr/src/cmd/make/lib/mksh/mksh.cc	2015-05-20 11:53:29.868229401 -0400
@@ -33,10 +33,6 @@
 /*
  * Included files
  */
-#if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL) /* tolik */
-#	include <avo/util.h>
-#endif
-
 #include <mksh/dosys.h>		/* redirect_io() */
 #include <mksh/misc.h>		/* retmem() */
 #include <mksh/mksh.h>
