bug-make
[Top][All Lists]
Advanced

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

Recipes of pattern rules with multiple targets executed multiple times


From: Jarmo Jaakkola
Subject: Recipes of pattern rules with multiple targets executed multiple times
Date: Thu, 16 Mar 2023 01:05:29 +0200
User-agent: Mutt/1.8.0 (2017-02-23)

The recipe of a pattern rule with multiple targets gets executed once
for each target if

    a) the pattern isn't a prefix of the target, and
    b) the pattern stem contains a directory.

The rule should only be executed once:

    Multiple target patterns in pattern rules are always treated as
    grouped targets (see Multiple Targets in a Rule) regardless of
    whether they use the : or &: separator.

Here is an example:

    $ cat GNUmakefile <<END
    all: dir/axa dir/bxb
    dir/cxc:
    a%a b%b: c%c; echo "Executed only once!"
    END
    $ make
    echo "Executed only once!"
    Executed only once!
    echo "Executed only once!"
    Executed only once!

The problem is that when populating also_make, the % is expanded
incorrectly, and as a result the also made targets won't match to other
targets.  Specifically, the pattern is replaced with the entire stem,
instead of with the file part of the stem and then prepending the
directory to that.

    $ make -p
    ...
    dir/axa: dir/cxc
    ...
    #  Also makes: bdir/xb
    ...

Here the also_make should be "dir/bxb".

Please find attached the reproducing makefile and a patch to fix it.

-- 
Jarmo Jaakkola

Attachment: GNUmakefile
Description: Text document

Attachment: 0001-Fix-also_make-of-non-prefix-patterns.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]