1999-09-14 02:03:19 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
2023-01-08 21:40:55 +00:00
|
|
|
$description = "Test the -e (environment overrides) option";
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{GOOGLE} = 'boggle';
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
run_make_test(q!
|
1999-09-14 02:03:19 +00:00
|
|
|
GOOGLE = bazzle
|
|
|
|
all:; @echo "$(GOOGLE)"
|
2020-04-01 05:58:33 +00:00
|
|
|
!,
|
|
|
|
'-e', "boggle\n");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2023-01-08 21:40:55 +00:00
|
|
|
# Ensure variables set on the command line have the origin correct
|
|
|
|
# See SV 61218
|
|
|
|
|
|
|
|
run_make_test(q!
|
|
|
|
$(info FOO [$(origin FOO)]: $(value FOO))
|
|
|
|
all: ;
|
|
|
|
recurse: ; @$(MAKE) -f #MAKEFILE#
|
|
|
|
!,
|
|
|
|
'-e --no-print-directory FOO=1 recurse',
|
|
|
|
"FOO [command line]: 1\nFOO [command line]: 1\n#MAKE#[1]: 'all' is up to date.");
|
|
|
|
|
2024-02-04 16:16:40 +00:00
|
|
|
# SV 64803.
|
|
|
|
# Test that the origin of an env variable is 'enviroment override' when -e
|
|
|
|
# is set and the makefile does not modify the variable.
|
|
|
|
# First run the test without -e and then with -e.
|
|
|
|
|
|
|
|
mkdir('lib', 0777);
|
|
|
|
|
|
|
|
create_file('lib/makefile',
|
|
|
|
'$(info in submake value=$(hello), origin=$(origin hello))
|
|
|
|
all:; @echo "value=$(hello), origin=$(origin hello)"'."\n");
|
|
|
|
|
|
|
|
# No -e.
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
'-s',
|
|
|
|
"value=world, origin=environment\nvalue=world, origin=environment\n".
|
|
|
|
"in submake value=world, origin=environment\nvalue=world, origin=environment");
|
|
|
|
|
|
|
|
# -e is specified on the command line.
|
|
|
|
my @opts = ('-e', '--environment-overrides');
|
|
|
|
for my $opt (@opts) {
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-s $opt",
|
|
|
|
"value=world, origin=environment override\nvalue=world, origin=environment override\n".
|
|
|
|
"in submake value=world, origin=environment override\nvalue=world, origin=environment override");
|
|
|
|
}
|
|
|
|
|
|
|
|
# MAKEFLAGS from env affects top level make.
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
$ENV{MAKEFLAGS} = 'e';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-s",
|
|
|
|
"value=world, origin=environment override\nvalue=world, origin=environment override\n".
|
|
|
|
"in submake value=world, origin=environment override\nvalue=world, origin=environment override");
|
|
|
|
|
|
|
|
# -e is passed to submake on the command line.
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -e -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-s",
|
|
|
|
"value=world, origin=environment\nvalue=world, origin=environment\n".
|
|
|
|
"in submake value=world, origin=environment override\nvalue=world, origin=environment override");
|
|
|
|
|
|
|
|
# MAKEFLAGS is reset for submake.
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib MAKEFLAGS=
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-se",
|
|
|
|
"value=world, origin=environment override\nvalue=world, origin=environment override\n".
|
|
|
|
"in submake value=world, origin=environment\nvalue=world, origin=environment");
|
|
|
|
|
|
|
|
# Some MAKEFLAGS in top make env.
|
|
|
|
# This MAKEFLAGS does not conform to the format that make itself produces for
|
|
|
|
# submake. However, make still parses and honors this MAKEFLAGS.
|
|
|
|
# This test checks that make does not confuse 'e' in 'extramk' with '-e'.
|
|
|
|
$ENV{MAKEFLAGS} = 'r -Iextramk -k bye=moon';
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-s",
|
|
|
|
"value=world, origin=environment\nvalue=world, origin=environment\n".
|
|
|
|
"in submake value=world, origin=environment\nvalue=world, origin=environment");
|
|
|
|
|
|
|
|
# Some MAKEFLAGS in top make env.
|
|
|
|
# This MAKEFLAGS does not conform to the format that make itself produces for
|
|
|
|
# submake. However, make still parses and honors this MAKEFLAGS.
|
|
|
|
# This test checks that make detects '-e' in this MAKEFLAGS.
|
|
|
|
$ENV{MAKEFLAGS} = 'r -Iextramk -ke bye=moon';
|
|
|
|
$ENV{hello} = 'world';
|
|
|
|
run_make_test(q!
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
$(info value=$(hello), origin=$(origin hello))
|
|
|
|
all:
|
|
|
|
> @echo "value=$(hello), origin=$(origin hello)"
|
|
|
|
> @$(MAKE) -C lib
|
|
|
|
.PHONY: lib all
|
|
|
|
!,
|
|
|
|
"-s",
|
|
|
|
"value=world, origin=environment override\nvalue=world, origin=environment override\n".
|
|
|
|
"in submake value=world, origin=environment override\nvalue=world, origin=environment override");
|
|
|
|
|
1999-09-14 02:03:19 +00:00
|
|
|
1;
|