2006-02-16 07:54:42 +08:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test the --warn-undefined-variables option.";
|
|
|
|
|
|
|
|
$details = "Verify that warnings are printed for referencing undefined variables.";
|
|
|
|
|
2022-12-24 23:30:13 +08:00
|
|
|
# Verify that make's special variables don't warn even if they're not set
|
|
|
|
run_make_test(q!
|
|
|
|
vars := $(.VARIABLES) $(MAKECMDGOALS) $(MAKE_RESTARTS) $(CURDIR)
|
|
|
|
vars += $(GNUMAKEFLAGS) $(MAKEFLAGS) $(MFLAGS) $(MAKE_COMMAND) $(MAKE)
|
|
|
|
vars += $(MAKEFILE_LIST) $(MAKEOVERRIDES) $(-*-command-variables-*-)
|
|
|
|
vars += $(.RECIPEPREFIX) $(.LOADED) $(.FEATURES)
|
|
|
|
vars += $(SHELL) $(.SHELLFLAGS) $(MAKE_TERMOUT) $(MAKE_TERMERR)
|
|
|
|
vars += $(.DEFAULT) $(.DEFAULT_GOAL) $(-*-eval-flags-*-) $(SUFFIXES)
|
|
|
|
vars += $(VPATH) $(GPATH)
|
|
|
|
all:;
|
|
|
|
!,
|
|
|
|
'--warn-undefined-variables', "#MAKE#: 'all' is up to date.");
|
|
|
|
|
2006-02-16 07:54:42 +08:00
|
|
|
# Without --warn-undefined-variables, nothing should happen
|
|
|
|
run_make_test('
|
|
|
|
EMPTY =
|
|
|
|
EREF = $(EMPTY)
|
|
|
|
UREF = $(UNDEFINED)
|
|
|
|
|
|
|
|
SEREF := $(EREF)
|
|
|
|
SUREF := $(UREF)
|
|
|
|
|
|
|
|
all: ; @echo ref $(EREF) $(UREF)',
|
|
|
|
'', 'ref');
|
|
|
|
|
|
|
|
# With --warn-undefined-variables, it should warn me
|
|
|
|
run_make_test(undef, '--warn-undefined-variables',
|
2012-03-04 08:24:20 +08:00
|
|
|
"#MAKEFILE#:7: warning: undefined variable 'UNDEFINED'
|
|
|
|
#MAKEFILE#:9: warning: undefined variable 'UNDEFINED'
|
2006-02-16 07:54:42 +08:00
|
|
|
ref");
|
|
|
|
|
2023-01-03 15:14:24 +08:00
|
|
|
# sv 63609.
|
|
|
|
# Test for buffer overrun in warn_undefined.
|
|
|
|
run_make_test(q!
|
|
|
|
all:;
|
|
|
|
X := $(averyveryverylongvariablename)
|
|
|
|
!,
|
|
|
|
'--warn-undefined-variables',
|
|
|
|
"#MAKEFILE#:3: warning: undefined variable 'averyveryverylongvariablename'
|
|
|
|
#MAKE#: 'all' is up to date.\n"
|
|
|
|
);
|
|
|
|
|
2006-02-16 07:54:42 +08:00
|
|
|
1;
|