make/tests/scripts/options/print-targets

33 lines
598 B
Text
Raw Normal View History

[SV 64571] Add --print-targets option Add an option to print a list of targets defined in the makefiles. Don't print targets of implicit rules, or special targets. To support this remember which files are deemed suffix rule targets. Add a missing warning for single-suffix targets with prerequisites. Suggested by many. Sample implementation by Tim <tdhutt@gmail.com>. * NEWS: Announce the new option and single-suffix warning. * doc/make.1: Add --print-targets to the man page. * doc/make.texi: Add --print-targets to the documentation. Clean up the text around the definition of suffix rules. * src/main.c (print_targets_flag): New variable for --print-targets. (switches): Add a new long option --print-targets. (main): If the option was provided call print_targets() and exit. * src/filedef.h (struct file): Add a "suffix" boolean value. Remove print_prereqs() since it's static. Add new print_targets(). * src/file.c (rehash_file): Merge the new suffix value. (print_prereqs): Used only locally: change to static. (print_target): Print targets which are not suffix rule targets and are not special targets. (print_targets): Call print_target() on each file. * src/rule.c (convert_to_pattern): Make maxsuffix local; it doesn't need to be static. Emit ignoring prerequisites for single-suffix rules as well as double-suffix rules. Remember which files are actually suffix rules. * tests/scripts/features/suffixrules: Test single-suffix behavior. * tests/scripts/options/print-targets: Add tests for --print-targets.
2024-01-09 04:14:57 +00:00
# -*-perl-*-
$description = "Test the --print-targets option to GNU Make.";
# Define various things and verify the output
run_make_test(q!
.PHONY: all
all: ;@:
# "special" target
.BOGUS: ;@:
# Check various forms of suffix rule
.SUFFIXES: .q
.q: ;@:
.c.o: ;@:
# Not a suffix rule
.x.z: ;@:
# Verify included files aren't built / don't fail
include badfile
include goodfile
submake: ; $(MAKE) all
always: ; +echo always
goodfile: ; touch goodfile
!,
"--print-targets", "submake\n.x.z\nalways\nall\ngoodfile\n");
1;