Short answer:
The listed template rules apply. The suffix rules are listed but not used.
Long answer:
When you delete Create Internal Database with make -p -f /dev/null , it prints the predefined rules and variables. The output is structured into different sections. For example, my Make (v3.81) returns the following:
# GNU Make 3.81 # Copyright (C) 2006 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # This program built for i686-pc-linux-gnu make: *** No targets. Stop. # Make data base, printed on Fri May 31 12:48:50 2013 # Variables ... # Directories ... # Implicit Rules ... # Pattern-specific variable values ... # Files ... # VPATH Search Paths ....
Project management with GNU Make and GNU Make manual explains the various sections as follows:
The Variables section lists all the variables along with a descriptive comment. However, automatic variables are not specified.
The "Directories" section is more useful for developers than for creating users. It lists directories that Make checks, including SCCS and RCS subdirectories that may exist, but usually do not. For each directory, Make display details details, for example, device number, index, and statistics on matches to a file template.
The next is the Implicit Rules section. It contains all the built-in and user-defined template rules in the database.
The following section describes the template-specific variables defined in the makefile. Recall that template-dependent variables are definition variables whose scales are precisely the runtime of their associated template rule.
The Files section lists all the explicit and suffix rules that apply to a particular file. [A file in this context means a target]
The last section is marked as VPATH. It contains search paths and lists the VPATH value and all vpath templates.
So, the applicable rules are listed in the Implicit Rules section. The suffix rules are listed as part of the Files section.
Really long answer:
Everyone knows that the source is the only true documentation;) So, true to the spirit of GNU, I ventured into Source Source to try to figure out what was going on. Disclaimer: I walked about two hours - long enough to get a general overview of the Make architecture.
Initialization phase: main.c: line 1600 (I just deleted a couple of #ifdefs that deal with different platforms):
set_default_suffixes (); install_default_suffix_rules (); define_automatic_variables (); define_makeflags (0, 0); define_default_variables (); default_file = enter_file (strcache_add (".DEFAULT")); default_goal_var = define_variable_cname (".DEFAULT_GOAL", "", o_file, 0);
- The set_default_suffixes () function defines only the .SUFFIXES variable, nothing more.
- Next, the default suffix rules are defined using the install_default_suffix_rules () function. It adds inline suffix rules as targets.
- I will skip the following two functions: jump right to define_default_variables (), which is also very clear. It defines ARCH, AR, CC, CXX, etc. Basically, the default environment setting is now configured.
- After that, the goals .DEFAULT and .DEFAULT_GOAL are determined. They are described in Special-Targets and Special Variables , respectively.
- Makefiles are then processed by read_all_makefiles (). Assessment can be difficult. However, the basic idea is simple: iterate over the lines in a file. The strategy is to accumulate target names in FILENAMES, dependencies in DEPS, and commands in COMMANDS. They are used to define a rule when the beginning of the next rule (or eof) is encountered. In our case, this step can be ignored, because we called Make with
-f /dev/null . - Then snap_deps () associates the target with the dependencies. They are stored as a linked list of dep structures (defined in dep.h).
- Now comes the interesting part. Convert_to_pattern () looks at the suffixes defined in the .SUFFIXES list, converts equivalent template rules and adds them to the chain of exit from template rules. This is exactly what is described in the section that you quoted. Since all user-defined rules are already included in step 5, they are assigned the priority of the converted built-in suffix rules.
Build Phase:
Later, when Make tries to create a target, it searches only the rule database. Rules are searched in implicit.c.
Why are rules displayed twice in print-database output?
Finally, I looked at the logic of the --print-database switch.
main.c: line 3078:
static void print_data_base () { time_t when; when = time ((time_t *) 0); printf (_("\n# Make data base, printed on %s"), ctime (&when)); print_variable_data_base (); print_dir_data_base (); print_rule_data_base (); print_file_data_base (); print_vpath_data_base (); strcache_print_stats ("#"); when = time ((time_t *) 0); printf (_("\n# Finished Make data base on %s\n"), ctime (&when)); }
The print_rule_data_base () function just pretty prints all the "active" rules. All existing suffix rules have previously been converted to template rules.
The print_file_data_base () function lists all targets. Suffix rules are still present. In fact, there is no function to remove targets from the database. However, from what I have learned, suffix targets are not used otherwise.