diff --git a/NEWS b/NEWS
index 3f363a8fa943931ddffce70b99f0af515ceec9bd..071e935925839b9bd4e6549fe225d4b8cb947b39 100644
--- a/NEWS
+++ b/NEWS
@@ -108,6 +108,8 @@ documents those changes that are of interest to users and admins.
  -- Fixed torque wrappers to look in the correct spot for the perl api
  -- Do not treat user resetting his time limit to the current value as
     an error.
+ -- Set correct executable names for Totalview when --multi-prog option 
+    is used and more than one node is allocated to the job step.
 
 * Changes in SLURM 1.2.20
 =========================
diff --git a/auxdir/x_ac_perl.m4 b/auxdir/x_ac_perl.m4
index 1182d657105cf531a7cc9e4c0b30602bb38bd70d..443c088f1ea2e8fa32c3911bcb9d467c66100c2c 100644
--- a/auxdir/x_ac_perl.m4
+++ b/auxdir/x_ac_perl.m4
@@ -42,7 +42,7 @@ AC_DEFUN([X_AC_PERL],
 		      [],[ac_perl="Not Found"])
          
         LIBS="$save_LIBS"
-        CFLAGSS="$save_CFLAGS"
+        CFLAGS="$save_CFLAGS"
         if test "$ac_perl" != "Not Found"; then
             AC_MSG_RESULT([PERL test program built properly.])    
             AC_DEFINE_UNQUOTED(PERL_SITE_DIR, "$perl_dir", [Define location of PERL directory])
diff --git a/configure b/configure
index dc9a1a0fc690bdb681c22a12d807e018aa055b41..643303d176a5dbb161d6b8e316c247b583433749 100755
--- a/configure
+++ b/configure
@@ -21787,7 +21787,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 
         LIBS="$save_LIBS"
-        CFLAGSS="$save_CFLAGS"
+        CFLAGS="$save_CFLAGS"
         if test "$ac_perl" != "Not Found"; then
             { echo "$as_me:$LINENO: result: PERL test program built properly." >&5
 echo "${ECHO_T}PERL test program built properly." >&6; }
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 81af4fa9cb10006454cd03e247728c90c09e4d68..35c9cc9a4e857b33b37b677230fb3afd674f504f 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -10,7 +10,7 @@ build_unsetenv_src = unsetenv.c unsetenv.h
 extra_unsetenv_src = 
 endif
 
-INCLUDES     = -I$(top_srcdir) $(SSL_CPPFLAGS) 
+INCLUDES     = -I$(top_srcdir) $(SSL_CPPFLAGS) $(PERL_INCLUDES)
 
 CPPFLAGS = $(PGSQL_CFLAGS)
 
@@ -107,7 +107,7 @@ libspank_la_SOURCES = \
 
 libcommon_la_LIBADD   = $(SSL_LIBS) -ldl $(PGSQL_LIBS) $(MYSQL_LIBS)
 
-libcommon_la_LDFLAGS  = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
+libcommon_la_LDFLAGS  = $(LIB_LDFLAGS) $(SSL_LDFLAGS) $(PERL_LIBS)
 
 global_defaults.c : $(top_builddir)/config.h Makefile
 	@( echo "/* This file autogenerated by src/common/Makefile */"; \
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 9a58842a3b4d484c1e4012479a6e2e5bbb3989a5..f97b3d9f621bf3c2843faed756659c6ce282a463 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -321,7 +321,7 @@ AUTOMAKE_OPTIONS = foreign
 @HAVE_UNSETENV_TRUE@build_unsetenv_src = 
 @HAVE_UNSETENV_FALSE@extra_unsetenv_src = 
 @HAVE_UNSETENV_TRUE@extra_unsetenv_src = unsetenv.c unsetenv.h
-INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) 
+INCLUDES = -I$(top_srcdir) $(SSL_CPPFLAGS) $(PERL_INCLUDES)
 noinst_LTLIBRARIES = \
 	libcommon.la 			\
 	libdaemonize.la 		\
@@ -414,7 +414,7 @@ libspank_la_SOURCES = \
 	optz.c      optz.h
 
 libcommon_la_LIBADD = $(SSL_LIBS) -ldl $(PGSQL_LIBS) $(MYSQL_LIBS)
-libcommon_la_LDFLAGS = $(LIB_LDFLAGS) $(SSL_LDFLAGS)
+libcommon_la_LDFLAGS = $(LIB_LDFLAGS) $(SSL_LDFLAGS) $(PERL_LIBS)
 all: all-am
 
 .SUFFIXES:
diff --git a/src/common/optz.h b/src/common/optz.h
index 76bb301526ebdd80f13ce3d29e28dabebfc17d9e..4898b4d6e10059d0013e482bd9e46773145e71c5 100644
--- a/src/common/optz.h
+++ b/src/common/optz.h
@@ -41,7 +41,9 @@
 #  include <config.h>
 #endif
 
-#define _GNU_SOURCE
+#ifndef   _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
 
 #if HAVE_GETOPT_H
 #  include <getopt.h>
diff --git a/src/common/parse_time.c b/src/common/parse_time.c
index 24c4a809e561c45ab17a8f50e6a1f6a96666b113..da64636512c0ab3323e4b3071c49c95d45e2f25e 100644
--- a/src/common/parse_time.c
+++ b/src/common/parse_time.c
@@ -39,7 +39,9 @@
 #include <stdio.h>
 #include <time.h>
 #include <strings.h>
-#define __USE_ISOC99 /* isblank() */
+#ifndef   __USE_ISOC99
+#  define __USE_ISOC99 /* isblank() */
+#endif
 #include <ctype.h>
 
 #include <slurm/slurm.h>
diff --git a/src/common/plugstack.h b/src/common/plugstack.h
index 24b81e1e3292e747b12f3b0234bc5f1eedb18cc4..7a7f57a8023cc81a7b5f8b8a29d36fe3f795389f 100644
--- a/src/common/plugstack.h
+++ b/src/common/plugstack.h
@@ -40,7 +40,9 @@
 #  include <config.h>
 #endif
 
-#define _GNU_SOURCE
+#ifndef   _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
 
 #if HAVE_GETOPT_H
 #  include <getopt.h>
diff --git a/src/common/stepd_api.c b/src/common/stepd_api.c
index f588313e8b07f3011d4bc9cecc7ecb01fd43f855..46f7d1b49670460a2288d14add0281a70b229469 100644
--- a/src/common/stepd_api.c
+++ b/src/common/stepd_api.c
@@ -36,7 +36,10 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#define _GNU_SOURCE
+#ifndef   _GNU_SOURCE
+#  define _GNU_SOURCE
+#endif
+
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
diff --git a/src/srun/multi_prog.c b/src/srun/multi_prog.c
index 334c8bdb2fe0cc2c47fa8ed7c887d2504f6ffa3e..c80548a3d3a144b47215e4a806de2c76430e4dd7 100644
--- a/src/srun/multi_prog.c
+++ b/src/srun/multi_prog.c
@@ -127,45 +127,46 @@ _set_range(int low_num, int high_num, char *exec_name)
 static void
 _set_exec_names(char *ranks, char *exec_name, int ntasks)
 {
-	char *range = NULL, *p = NULL;
-	char *ptrptr = NULL, *exec_path = NULL, *upper = NULL;
-	int low_num, high_num;
+	char *ptrptr = NULL, *exec_path = NULL;
+	int low_num, high_num, num, i;
 
-	if (ranks[0] == '*' && ranks[1] == '\0') {
+	exec_path = _build_path(exec_name);
+	if ((ranks[0] == '*') && (ranks[1] == '\0')) {
 		low_num = 0;
 		high_num = ntasks - 1;
-		_set_range(low_num, high_num, exec_name);
+		_set_range(low_num, high_num, exec_path);
 		return;
 	}
-	exec_path = _build_path(exec_name);
 
-	for (range = strtok_r(ranks, ",", &ptrptr); range != NULL;
-			range = strtok_r(NULL, ",", &ptrptr)) {
-		p = range;
-		while (*p != '\0' && isdigit (*p))
-			p ++;
+	ptrptr = ranks;
+	for (i=0; i<ntasks; i++) {
+		if (!isdigit(ptrptr[0]))
+			goto invalid;
 
-		if (*p == '\0') { /* single rank */
-			low_num  = MAX(0, atoi(range));
-			high_num = MIN((ntasks-1), atoi(range));
+		num = strtol(ptrptr, &ptrptr, 10);
+
+		if ((ptrptr[0] == ',') || (ptrptr[0] == '\0')) {
+			low_num = MAX(0, num);
+			high_num = MIN((ntasks-1), num);
 			_set_range(low_num, high_num, exec_path);
-		} else if (*p == '-') { /* lower-upper */
-			upper = ++ p;
-			while (isdigit (*p))
-				p ++;
-			if (*p != '\0') {
-				error ("Invalid task range specification (%s) "
-					"ignored.", range);
-				continue;
-			}
-			low_num  = MAX(0, atoi (range));
-			high_num = MIN((ntasks-1), atoi(upper));
+		} else if (ptrptr[0] == '-') {
+			low_num = MAX(0, num);
+			num = strtol(ptrptr+1, &ptrptr, 10);
+			if ((ptrptr[0] != ',') && (ptrptr[0] != '\0'))
+				goto invalid; 
+			high_num = MIN((ntasks-1), num);
 			_set_range(low_num, high_num, exec_path);
-		} else {
-			error ("Invalid task range specification (%s) ignored.",
-				range);
-		}
+		} else
+			goto invalid;
+		if (ptrptr[0] == '\0')
+			break;
+		ptrptr++;
 	}
+	return;
+
+  invalid:
+	error ("Invalid task range specification (%s) ignored.", ranks);
+	return;
 }
 
 extern int