make: Check target name in dependencies - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 61c6638246049b2085f1ef70e5b478c088d1f7da
 (DIR) parent 5bc57804faae91164edcd9f3aec054da4825b423
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
       Date:   Mon, 17 Mar 2025 16:58:03 +0100
       
       make: Check target name in dependencies
       
       A target can have (and usually they have) dependencies with
       other files, so we cannot assume that if we have a dependency
       with build actions then we have a rule that is able to build
       the target, because the build actions can be for other target.
       
       Diffstat:
         M src/cmd/scc-make/rules.c            |      12 ++++++++----
       
       1 file changed, 8 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/scc-make/rules.c b/src/cmd/scc-make/rules.c
       @@ -506,7 +506,7 @@ rebuild(Target *tp, int *buildp)
                        q = *p;
                        debug("checking dependency %s", q->name);
        
       -                if (q->actions)
       +                if (strcmp(q->name, tp->name) == 0 && q->actions)
                                def = 1;
        
                        build = 0;
       @@ -526,10 +526,14 @@ rebuild(Target *tp, int *buildp)
                        }
                }
        
       -        if (tp->stamp == -1)
       -                need = 1;
       -        else if (!def && inference(tp, NOFORCE))
       +        if (tp->stamp == -1) {
                        need = 1;
       +        } else if (!def)  {
       +                debug("no action found for %s, looking a inference rule",
       +                      tp->name);
       +                if (inference(tp, NOFORCE))
       +                        need = 1;
       +        }
        
                if (err) {
                        warning("target %s not remade because of errors", tp->name);