mirror of
https://github.com/mirror/make.git
synced 2024-12-29 14:30:42 +08:00
Ensure that MAKEFLAGS is set when invoking $(shell ...)
* src/main.c (main): Don't reset the jobserver if the number of slots has not changed. (define_makeflags): Add all normal flags even when ALL is not set. * tests/scripts/functions/shell: Test invoking make in $(shell ...). * tests/scripts/variables/MAKEFLAGS: Test the value of MAKEFLAGS in $(shell ...).
This commit is contained in:
parent
2fe96e4a41
commit
77881d2281
40
src/main.c
40
src/main.c
@ -1088,7 +1088,7 @@ main (int argc, char **argv, char **envp)
|
|||||||
PATH_VAR (current_directory);
|
PATH_VAR (current_directory);
|
||||||
unsigned int restarts = 0;
|
unsigned int restarts = 0;
|
||||||
unsigned int syncing = 0;
|
unsigned int syncing = 0;
|
||||||
int argv_slots;
|
int argv_slots; /* The jobslot info we got from our parent process. */
|
||||||
#ifdef WINDOWS32
|
#ifdef WINDOWS32
|
||||||
const char *unix_path = NULL;
|
const char *unix_path = NULL;
|
||||||
const char *windows32_path = NULL;
|
const char *windows32_path = NULL;
|
||||||
@ -2013,7 +2013,7 @@ main (int argc, char **argv, char **envp)
|
|||||||
if (arg_job_slots == INVALID_JOB_SLOTS || argv_slots != INVALID_JOB_SLOTS)
|
if (arg_job_slots == INVALID_JOB_SLOTS || argv_slots != INVALID_JOB_SLOTS)
|
||||||
arg_job_slots = old_arg_job_slots;
|
arg_job_slots = old_arg_job_slots;
|
||||||
|
|
||||||
else if (jobserver_auth)
|
else if (jobserver_auth && arg_job_slots != old_arg_job_slots)
|
||||||
{
|
{
|
||||||
/* Makefile MAKEFLAGS set -j, but we already have a jobserver.
|
/* Makefile MAKEFLAGS set -j, but we already have a jobserver.
|
||||||
Make us the master of a new jobserver group. */
|
Make us the master of a new jobserver group. */
|
||||||
@ -3395,22 +3395,19 @@ define_makeflags (int all, int makefile)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case positive_int:
|
case positive_int:
|
||||||
if (all)
|
if ((cs->default_value != 0
|
||||||
|
&& (*(unsigned int *) cs->value_ptr
|
||||||
|
== *(unsigned int *) cs->default_value)))
|
||||||
|
break;
|
||||||
|
if (cs->noarg_value != 0
|
||||||
|
&& (*(unsigned int *) cs->value_ptr ==
|
||||||
|
*(unsigned int *) cs->noarg_value))
|
||||||
|
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if ((cs->default_value != 0
|
char *buf = alloca (30);
|
||||||
&& (*(unsigned int *) cs->value_ptr
|
sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
|
||||||
== *(unsigned int *) cs->default_value)))
|
ADD_FLAG (buf, strlen (buf));
|
||||||
break;
|
|
||||||
if (cs->noarg_value != 0
|
|
||||||
&& (*(unsigned int *) cs->value_ptr ==
|
|
||||||
*(unsigned int *) cs->noarg_value))
|
|
||||||
ADD_FLAG ("", 0); /* Optional value omitted; see below. */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *buf = alloca (30);
|
|
||||||
sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
|
|
||||||
ADD_FLAG (buf, strlen (buf));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3430,12 +3427,9 @@ define_makeflags (int all, int makefile)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case string:
|
case string:
|
||||||
if (all)
|
p = *((char **)cs->value_ptr);
|
||||||
{
|
if (p)
|
||||||
p = *((char **)cs->value_ptr);
|
ADD_FLAG (p, strlen (p));
|
||||||
if (p)
|
|
||||||
ADD_FLAG (p, strlen (p));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case filename:
|
case filename:
|
||||||
|
@ -140,6 +140,21 @@ all: ; @echo '$(.SHELLSTATUS): $(out)'
|
|||||||
!,
|
!,
|
||||||
'', "127: $_\n");
|
'', "127: $_\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If we're using pipes for jobserver, then we will close them and not
|
||||||
|
# allow them to be available to sub-makes invoked via $(shell ...)
|
||||||
|
run_make_test(q!
|
||||||
|
ifeq ($(ELT),)
|
||||||
|
default:; @$(MAKE) -f #MAKEFILE# ELT=1
|
||||||
|
else ifeq ($(ELT),1)
|
||||||
|
OUTPUT := $(shell $(MAKE) -f #MAKEFILE# ELT=2)
|
||||||
|
$(info $(OUTPUT))
|
||||||
|
default:;: $(ELT)
|
||||||
|
else
|
||||||
|
default:;: $(ELT)
|
||||||
|
endif
|
||||||
|
!,
|
||||||
|
'--no-print-directory -j2', "#MAKE#[2]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.\n: 2\n: 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -129,4 +129,14 @@ all:; $(info makeflags='$(MAKEFLAGS)')
|
|||||||
'-Onone -l2.5 -l2.5 -Onone -I/tmp -iknqrswd -i -n -s -k -I/tmp',
|
'-Onone -l2.5 -l2.5 -Onone -I/tmp -iknqrswd -i -n -s -k -I/tmp',
|
||||||
"/makeflags='Bdiknqrsw -I/tmp -l2.5 -Onone --trace --warn-undefined-variables'/");
|
"/makeflags='Bdiknqrsw -I/tmp -l2.5 -Onone --trace --warn-undefined-variables'/");
|
||||||
|
|
||||||
|
# Verify MAKEFLAGS are all available to shell functions
|
||||||
|
$ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables';
|
||||||
|
run_make_test(q!
|
||||||
|
MAKEFLAGS := iknqrsw -I/tmp -I/tmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
|
||||||
|
XX := $(shell echo "$$MAKEFLAGS")
|
||||||
|
all:; $(info makeflags='$(XX)')
|
||||||
|
!,
|
||||||
|
'-Onone -l2.5 -l2.5 -Onone -I/tmp -iknqrs -i -n -s -k -I/tmp',
|
||||||
|
"makeflags='iknqrsw -I/tmp -I/tmp -Onone -Onone -l2.5 -l2.5 --no-print-directory'");
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user