From nnd@nnd.itfs.nsk.su  Wed Aug 13 00:41:41 1997
Received: from nnd.itfs.nsk.su (nnd.itfs.nsk.su [193.124.36.42])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id AAA02208
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 13 Aug 1997 00:41:33 -0700 (PDT)
Received: (from root@localhost)
	by nnd.itfs.nsk.su (8.8.7/8.8.5) id OAA07532;
	Wed, 13 Aug 1997 14:41:50 +0700 (NSS)
Message-Id: <199708130741.OAA07532@nnd.itfs.nsk.su>
Date: Wed, 13 Aug 1997 14:41:50 +0700 (NSS)
From: "Nickolay N. Dudorov" <nnd@nnd.itfs.nsk.su>
Reply-To: nnd@nnd.itfs.nsk.su
To: FreeBSD-gnats-submit@freebsd.org
Subject: /usr/bin/make - inconsistent -j<n> flag parsing
X-Send-Pr-Version: 3.2

>Number:         4291
>Category:       bin
>Synopsis:       /usr/bin/make - inconsistent -j<n> flag parsing
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 13 00:50:01 PDT 1997
>Closed-Date:    Wed Aug 13 21:46:28 PDT 1997
>Last-Modified:  Wed Aug 13 21:47:29 PDT 1997
>Originator:     Nickolay N. Dudorov
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
NTP Infoteka
>Environment:

	Current versions of FreeBSD - at least FreeBSD-3.0
	and FreeBSD-2.2-RELENG

>Description:

	/usr/bin/make can be used in two modes: with "parallel"
jobs (set with -j<n> flag) and in "compat mode" (-B flag).

	Currently "compat mode" is set by default (no -j nor -B
flags given) and if -B flag is given despite of presence/absence
of -j flag.

	BUT "compat mode" is also set without using -B flag
if -j<n> flag follows some "variable definition" on a command
line or in the MAKEFLAGS environment variable.

>How-To-Repeat:

1)
	make -j12 VAR=val all

will work in "parallel mode", whereas

	make VAR=val -j12 all

will set "compat mode".

2)
	setenv MAKEFLAGS "VAR=val -j12"
	make all

will set "compat mode", whereas

	setenv MAKEFLAGS "-j12 VAR=val"
	make all

will work in "parallel mode".

>Fix:
	
	The next patch corrects /usr/bin/make treatment of
-j<n> flag - i.e. make it "position independent".

diff -ru src/usr.bin/make/main.c src/usr.bin/make-patched/main.c
--- src/usr.bin/make/main.c	Fri Jul 25 10:16:42 1997
+++ src/usr.bin/make-patched/main.c	Wed Aug 13 13:23:47 1997
@@ -118,6 +118,7 @@
 static Boolean		printVars;	/* print value of one or more vars */
 static Lst		variables;	/* list of variables to print */
 int			maxJobs;	/* -j argument */
+static Boolean          forceJobs;      /* -j argument given */
 static int		maxLocal;	/* -L argument */
 Boolean			compatMake;	/* -B argument */
 Boolean			debug;		/* -d flag */
@@ -162,7 +163,6 @@
 	extern int optind;
 	extern char *optarg;
 	int c;
-	int forceJobs = 0;
 
 	optind = 1;	/* since we're called more than once */
 #ifdef REMOTE
@@ -315,13 +315,6 @@
 		}
 	}
 
-	/*
-	 * Be compatible if user did not specify -j and did not explicitly
-	 * turned compatibility on
-	 */
-	if (!compatMake && !forceJobs)
-		compatMake = TRUE;
-
 	oldVars = TRUE;
 
 	/*
@@ -559,6 +552,7 @@
 #else
 	maxJobs = maxLocal;
 #endif
+	forceJobs = FALSE;              /* No -j flag */
 	compatMake = FALSE;		/* No compat mode */
 
 
@@ -605,6 +599,13 @@
 #endif
 
 	MainParseArgs(argc, argv);
+
+	/*
+	 * Be compatible if user did not specify -j and did not explicitly
+	 * turned compatibility on
+	 */
+	if (!compatMake && !forceJobs)
+		compatMake = TRUE;
 
 	/*
 	 * Initialize archive, target and suffix modules in preparation for

>Release-Note:
>Audit-Trail:

From: Steve Passe <smp@csn.net>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: Re: bin/4291: /usr/bin/make - inconsistent -j<n> flag parsing 
Date: Wed, 13 Aug 1997 18:05:16 -0600

 Hi,
 
 > >Number:         4291
 > >Category:       bin
 > >Synopsis:       /usr/bin/make - inconsistent -j<n> flag parsing
 > >Description:
 > 
 > 	/usr/bin/make can be used in two modes: with "parallel"
 > jobs (set with -j<n> flag) and in "compat mode" (-B flag).
 > 
 > 	Currently "compat mode" is set by default (no -j nor -B
 > flags given) and if -B flag is given despite of presence/absence
 > of -j flag.
 > 
 > 	BUT "compat mode" is also set without using -B flag
 > if -j<n> flag follows some "variable definition" on a command
 > line or in the MAKEFLAGS environment variable.
 > 
 > >How-To-Repeat:
 > 
 > 1)
 > 	make -j12 VAR=val all
 > 
 > will work in "parallel mode", whereas
 > 
 > 	make VAR=val -j12 all
 > 
 > will set "compat mode".
 
 the supplied fix looks OK, but would this "fix" break any standard?
 Specifically, is there a standard we adhere to that says that all '-' options
 should preceed variable defines and other command line arguments?
 
 
 --
 Steve Passe	| powered by 
 smp@csn.net	|            Symmetric MultiProcessor FreeBSD
 
 
State-Changed-From-To: open->closed 
State-Changed-By: fsmp 
State-Changed-When: Wed Aug 13 21:46:28 PDT 1997 
State-Changed-Why:  
Fixed. 

>Unformatted:
