diff --git a/main.c b/main.c index 323e1a05..dd06aa47 100644 --- a/main.c +++ b/main.c @@ -747,6 +747,14 @@ main (argc, argv, envp) set_default_suffixes (); + /* Define the file rules for the built-in suffix rules. These will later + be converted into pattern rules. We used to do this in + install_default_implicit_rules, but since that happens after reading + makefiles, it results in the built-in pattern rules taking precedence + over makefile-specified suffix rules, which is wrong. */ + + install_default_suffix_rules (); + /* Define some internal and special variables. */ define_automatic_variables (); @@ -785,17 +793,20 @@ main (argc, argv, envp) snap_deps (); - /* Install the default implicit rules. + /* Convert old-style suffix rules to pattern rules. It is important to + do this before installing the built-in pattern rules below, so that + makefile-specified suffix rules take precedence over built-in pattern + rules. */ + + convert_to_pattern (); + + /* Install the default implicit pattern rules. This used to be done before reading the makefiles. But in that case, built-in pattern rules were in the chain before user-defined ones, so they matched first. */ install_default_implicit_rules (); - /* Convert old-style suffix rules to pattern rules. */ - - convert_to_pattern (); - /* Compute implicit rule limits. */ count_implicit_rule_limits ();