help-make
[Top][All Lists]
Advanced

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

Chain of pattern rule and non-terminal match-anything rule


From: Renaud Pacalet
Subject: Chain of pattern rule and non-terminal match-anything rule
Date: Thu, 10 Jan 2019 11:55:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

With the following Makefile:

# Makefile
%.dat: aa
        touch $@

%:
        mkdir -p $@

invoking `make -d aa/bb.dat` produces:

GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Updating makefiles....
 Considering target file 'Makefile'.
  Looking for an implicit rule for 'Makefile'.
  Trying pattern rule with stem 'Makefile'.
  Found an implicit rule for 'Makefile'.
  Finished prerequisites of target file 'Makefile'.
 No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'aa/bb.dat'.
 File 'aa/bb.dat' does not exist.
 Looking for an implicit rule for 'aa/bb.dat'.
 Trying pattern rule with stem 'bb'.
 Trying rule prerequisite 'aa'.
 Trying pattern rule with stem 'bb.dat'.
 Trying implicit prerequisite 'aa/bb.dat,v'.
 Trying pattern rule with stem 'bb.dat'.
 Trying implicit prerequisite 'aa/RCS/bb.dat,v'.
 Trying pattern rule with stem 'bb.dat'.
 Trying implicit prerequisite 'aa/RCS/bb.dat'.
 Trying pattern rule with stem 'bb.dat'.
 Trying implicit prerequisite 'aa/s.bb.dat'.
 Trying pattern rule with stem 'bb.dat'.
 Trying implicit prerequisite 'aa/SCCS/s.bb.dat'.
 Trying pattern rule with stem 'bb'.
 Trying rule prerequisite 'aa'.
 Looking for a rule with intermediate file 'aa'.
  Avoiding implicit rule recursion.
  Trying pattern rule with stem 'aa'.
  Trying implicit prerequisite 'aa,v'.
  Trying pattern rule with stem 'aa'.
  Trying implicit prerequisite 'RCS/aa,v'.
  Trying pattern rule with stem 'aa'.
  Trying implicit prerequisite 'RCS/aa'.
  Trying pattern rule with stem 'aa'.
  Trying implicit prerequisite 's.aa'.
  Trying pattern rule with stem 'aa'.
  Trying implicit prerequisite 'SCCS/s.aa'.
 No implicit rule found for 'aa/bb.dat'.
 Finished prerequisites of target file 'aa/bb.dat'.
Must remake target 'aa/bb.dat'.
make: *** No rule to make target 'aa/bb.dat'.  Stop.

If I change the non-terminal match-anything rule such that it is not
match-anything any more:

# Makefile
%.dat: aa
        touch $@

%a:
        mkdir -p $@

then I get:

$ make aa/bb.dat
mkdir -p aa
touch aa/bb.dat
rm aamake: unlink: aa: Is a directory

which I perfectly understand (I think). So, the problem with the first
Makefile has something to do with non-terminal match-anything rules.

I have read several times all sections of the GNU make manual that I
thought were relevant but I still don't understand why make does not use
the non-terminal match-anything rule to build `aa`. I suspect that this
has something to do with the "Avoiding implicit rule recursion" debug
message.

Does anybody know where this behaviour comes from or what part of the
GNU make manual explains this behaviour?
-- 
Renaud Pacalet
Télécom ParisTech - LabSoC, c/o EURECOM
Campus SophiaTech,
450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
Tel : +33 (0) 4 9300 8402
Web : http://www.telecom-paristech.fr/



reply via email to

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