View | Details | Raw Unified | Return to bug 17188
Collapse All | Expand All

(-)main.c (-11 / +22 lines)
Lines 122-127 Link Here
122
static Boolean		noBuiltins;	/* -r flag */
122
static Boolean		noBuiltins;	/* -r flag */
123
static Lst		makefiles;	/* ordered list of makefiles to read */
123
static Lst		makefiles;	/* ordered list of makefiles to read */
124
static Boolean		printVars;	/* print value of one or more vars */
124
static Boolean		printVars;	/* print value of one or more vars */
125
static Boolean		expandVars;	/* fully expand printed variables */
125
static Lst		variables;	/* list of variables to print */
126
static Lst		variables;	/* list of variables to print */
126
int			maxJobs;	/* -j argument */
127
int			maxJobs;	/* -j argument */
127
static Boolean          forceJobs;      /* -j argument given */
128
static Boolean          forceJobs;      /* -j argument given */
Lines 175-183 Link Here
175
176
176
	optind = 1;	/* since we're called more than once */
177
	optind = 1;	/* since we're called more than once */
177
#ifdef REMOTE
178
#ifdef REMOTE
178
# define OPTFLAGS "BD:E:I:L:PSV:d:ef:ij:km:nqrstv"
179
# define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
179
#else
180
#else
180
# define OPTFLAGS "BD:E:I:PSV:d:ef:ij:km:nqrstv"
181
# define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv"
181
#endif
182
#endif
182
rearg:	while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
183
rearg:	while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
183
		switch(c) {
184
		switch(c) {
Lines 193-207 Link Here
193
			break;
194
			break;
194
		case 'V':
195
		case 'V':
195
			printVars = TRUE;
196
			printVars = TRUE;
196
			p = malloc(strlen(optarg) + 1 + 3);
197
			(void)Lst_AtEnd(variables, (ClientData)optarg);
197
			if (!p)
198
				Punt("make: cannot allocate memory.");
199
                        /* This sprintf is safe, because of the malloc above */
200
			(void)sprintf(p, "${%s}", optarg);
201
			(void)Lst_AtEnd(variables, (ClientData)p);
202
			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
198
			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
203
			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
199
			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
204
			break;
200
			break;
201
		case 'X':
202
			expandVars = FALSE;
203
			break;
205
		case 'B':
204
		case 'B':
206
			compatMake = TRUE;
205
			compatMake = TRUE;
207
			Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
206
			Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
Lines 619-624 Link Here
619
	makefiles = Lst_Init(FALSE);
618
	makefiles = Lst_Init(FALSE);
620
	envFirstVars = Lst_Init(FALSE);
619
	envFirstVars = Lst_Init(FALSE);
621
	printVars = FALSE;
620
	printVars = FALSE;
621
	expandVars = TRUE;
622
	variables = Lst_Init(FALSE);
622
	variables = Lst_Init(FALSE);
623
	beSilent = FALSE;		/* Print commands as executed */
623
	beSilent = FALSE;		/* Print commands as executed */
624
	ignoreErrors = FALSE;		/* Pay attention to non-zero returns */
624
	ignoreErrors = FALSE;		/* Pay attention to non-zero returns */
Lines 826-835 Link Here
826
826
827
		for (ln = Lst_First(variables); ln != NILLNODE;
827
		for (ln = Lst_First(variables); ln != NILLNODE;
828
		    ln = Lst_Succ(ln)) {
828
		    ln = Lst_Succ(ln)) {
829
			char *value = Var_Subst(NULL, (char *)Lst_Datum(ln),
829
			char *value;
830
					  VAR_GLOBAL, FALSE);
830
			if (expandVars) {
831
831
				p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
832
				if (!p1)
833
					Punt("make: cannot allocate memory.");
834
				/* This sprintf is safe, because of the malloc above */
835
				(void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
836
				value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE);
837
			} else {
838
				value = Var_Value((char *)Lst_Datum(ln),
839
						  VAR_GLOBAL, &p1);
840
			}
832
			printf("%s\n", value ? value : "");
841
			printf("%s\n", value ? value : "");
842
			if (p1)
843
				free(p1);
833
		}
844
		}
834
	}
845
	}
835
846
(-)make.1 (-1 / +6 lines)
Lines 40-46 Link Here
40
.Nd maintain program dependencies
40
.Nd maintain program dependencies
41
.Sh SYNOPSIS
41
.Sh SYNOPSIS
42
.Nm make
42
.Nm make
43
.Op Fl BPSeiknqrstv
43
.Op Fl BPSXeiknqrstv
44
.Op Fl D Ar variable
44
.Op Fl D Ar variable
45
.Op Fl d Ar flags
45
.Op Fl d Ar flags
46
.Op Fl E Ar variable
46
.Op Fl E Ar variable
Lines 212-217 Link Here
212
.It Fl v
212
.It Fl v
213
Be extra verbose.
213
Be extra verbose.
214
For multi-job makes, this will cause file banners to be generated.
214
For multi-job makes, this will cause file banners to be generated.
215
.It Fl X
216
When using the
217
.Fl V
218
option to print the values of variables,
219
do not recursively expand the values.
215
.It Ar variable Ns No = Ns Ar value
220
.It Ar variable Ns No = Ns Ar value
216
Set the value of the variable
221
Set the value of the variable
217
.Ar variable
222
.Ar variable

Return to bug 17188