help-make
[Top][All Lists]
Advanced

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

Re: prerequisite ignored when running 'make' (alone)


From: Federico Bruni
Subject: Re: prerequisite ignored when running 'make' (alone)
Date: Tue, 09 May 2017 15:18:54 +0200



Il giorno mar 9 mag 2017 alle 14:29, Paul Smith <address@hidden> ha scritto:
On Tue, 2017-05-09 at 14:06 +0200, Federico Bruni wrote:
 ### Makefile ###
 all: doc

 dependencies = $(shell find docs -type f)

 doc: $(dependencies)
         echo "Something has changed in the docs/ directory!"

 ### end ###


 It looks up the files in the docs/ directory and executes the doc
 target if any file is changed.

As written here, that's not what it does.

 If I run 'make doc', it behaves as expected.
 If I run 'make', the target is executed every time, even if no file
 changed in docs/.

I can't explain the difference in behavior.  In fact, the behavior of
"make" (target is executed every time) is what I expect to happen no
matter how you invoke make.

Why?  Because make decides whether or not to rebuild something by
comparing _file timestamps_.

In this makefile you'll compare the timestamps of all the files under
the "docs" directory to... what?


Ok, that's the point, of course.
In my real project I was confused because I happened to name the default target like the directory built by another target (not run by 'make') and by other stuff specific of my project that I won't explain here.






reply via email to

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