Re: [HELP] PHONY pattern rule makes the file w/ the same name
Renaud Pacalet <[email protected]>
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <[email protected]> |
On 05/10/2023 12:27, Bahman Movaqar wrote: > > On Wed, 2023-10-04 at 10:55 -0400, Paul Smith wrote: >> Sorry but I don't really understand the problem. Maybe you can explain >> it more clearly: provide the shortest, simplest repro case and show >> both what happened and what you expected to see, and explain why you >> expected it. > > Good idea. Please see this repository: > https://github.com/throw-away-repos/make-pattern-rules > > >> That's not really right. What .PHONY means is that make will _always_ >> rebuild that target (if it is considered), regardless of whether or not >> the file exists on the disk or whether it's out of date with respect to >> its prerequisites. > > I see where I misunderstood .PHONY. > >> It also means that implicit rules are not searched, for PHONY targets. >> See: >> https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html > > I definitely needed to re-read this! That said, I'm still confused. > > I'm thinking that my understanding of implicit rule search combined w/ > .PHONY is not enough to explain the situation in the repository above. > > Could be related to https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles: > after reading in all makefiles make will consider each as a goal target, in the order in which they were processed, and attempt to update it So, in your case, make tries to update the 2 included makefiles (mk/scenario1.mk and mk/scenario2.mk). As you provide pattern rules for that, make will build: 1. foo1-by-scenario1 because mk/scenario1.mk depends on it 2. mk/scenario1.mk 3. foo2 because mk/scenario2.mk depends on it 4. mk/scenario2.mk 5. scenario1.first-scenario 6. sep 7. scenario2.second-scenario The out is thus normal. -- Renaud Pacalet Télécom Paris Campus SophiaTech 450 Route des Chappes, CS 50193 06904 Biot Sophia Antipolis cedex, FRANCE Tel : +33 (0) 4 9300 8402 Web : http://www.telecom-paris.fr/