tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: $(<) is used incorrectly in Makefile.kern.inc



On Tue, Aug 19, 2014 at 12:08:44AM +0000, David Holland wrote:
> On Mon, Aug 18, 2014 at 11:04:28PM +0300, Jarmo Jaakkola wrote:
>  > The variable $(<) (.IMPSRC) is used in Makefile.kern.inc in
>  > the NORMAL_C, NOPROF_C, and NORMAL_S macros.  These macros are then
>  > used in _explicit_ rules instead of suffix transformation rules.
>  > The variable is not supposed to be available, but as a side effect of
>  > a bug (PR 49086, issue 8), it has been available.
> 
> That is not a bug. Extending $(.IMPSRC) to work for all rules, like
> gmake has ~always done, was intentional a while back.
> 
> It may have been done wrong though.

Then it has been done wrong. :)  .IMPSRC is set by wasting time
doing a transformation rule search for targets which have an explicit
rule and also forcing incorrect dependencies on targets in the process.
Here's a "real life" example (there's a more abstract one in the PR):

    .SUFFIXES: .c .o
    .c.o: common.h
        cc -o $@ $<

    main.o: foo.c
        cc -o $@ foo.c

    foo.o: dir/foobar.c
        cc -o $@ dir/foobar.c

For foo.o the values of local variables will be:
    $(.IMPSRC): foo.c
    $(.ALLSRC): dir/foobar.c foo.c common.h
This is clearly wrong.

Also, in gmake:
    $<  The name of the first prerequisite. If the target got its recipe
        from an implicit rule, this will be the first prerequisite added
        by the implicit rule 

So the macros would still be wrong, even if it did work like gmake did.
I suppose it wouldn't be too difficult to make $(<) stand for "the first
prerequisite" in explicit rules.

-- 
Jarmo Jaakkola


Home | Main Index | Thread Index | Old Index