make/tests/scripts/options/dash-C
Paul Smith 76d2e5d98d [SV 63552] Change directories before constructing include paths
* src/makeint.h (reset_makeflags): New function to handle changing
MAKEFLAGS from within makefiles.  Remove decode_env_switches().
* src/variable.c (set_special_var): Call reset_makeflags() instead
of various internal methods.
* src/main.c (decode_env_switches): Only internal now so make static.
(decode_switches): Don't invoke construct_include_path() yet.
(reset_makeflags): Decode env switches and construct include paths.
(main): Construct include paths after we process -C options.
* tests/scripts/options/dash-C: Rewrite to use new test constructs.
Add a test using both -C and -I together.
Add a test for multiple -C options.
2022-12-24 10:52:43 -05:00

52 lines
1.3 KiB
Perl

# -*-perl-*-
$description = "Test the -C option to GNU make.";
use File::Spec;
# Pre-set $makefile to be in a subdirectory
$makefile = 'Makefile';
my $_srcdir = 'src';
mkdir($_srcdir, 0775);
my $_incdir = 'inc';
mkdir($_incdir, 0775);
my $_mkpath = File::Spec->catfile($_srcdir, $makefile);
create_file($_mkpath, "include \$(file)\nall: ;\n");
# TEST #1
# -------
run_make_test('', "-C $_srcdir --no-print-directory",
"#MAKE#: 'all' is up to date.");
# TEST #2
# -------
# Do it again with trailing "/"; this should work the same
run_make_test(undef, "-C $_srcdir/ --no-print-directory",
"#MAKE#: 'all' is up to date.");
# Test stringing together multiple -C options
run_make_test(undef, "-C $_incdir -C .. -C $_srcdir --no-print-directory",
"#MAKE#: 'all' is up to date.");
# SV 63552 - Ensure -I is considered after -C
my $_incfile = 'test';
my $_incpath = File::Spec->catfile($_incdir, $_incfile);
create_file($_incpath, '$(info included)');
my $_incopt = File::Spec->catfile('..', $_incdir);
run_make_test(undef, "-C src -I $_incopt --no-print-directory file=$_incfile",
"included\n#MAKE#: 'all' is up to date.");
unlink($_incpath);
rmdir($_incdir);
unlink($_mkpath);
rmdir($_srcdir);
1;