Re: Strange behavior with Make dependencies...
- From: "toby" <toby@xxxxxxxxxxxxxxxxxxx>
- Date: 18 Dec 2006 16:57:59 -0800
João Jerónimo wrote:
toby wrote:
When I do make in the directory where *this* makefile is, Make tells me:I've just solved my problem by telling that bootsect was a dependency of
make: Nothing to be done for `all'.
Whether I've updated some file inside any of the two subdirectories or
not... so, when I update some file, it's not propagated, which is wrong...
The makefile should always run "make -C bootsect" and "make -C bootldr",
but it never runs it, unless I'd run "make clean" before...
bootsect.MBR :
bootsect.MBR: bootsect
Then, Make will check if the timestamp of the bootsect directory is
later than the bootsect.MBR's and run the target if so...
This is an unreliable workaround. (One reason is because the directory
timestamp does not reflect all changes to files inside it - it will
update when files are added or removed, but you can change contents of
a file without this being reflected in the parent dir's timestamp.)
On Linux it worked well...
But I know the importance of portability!
It's not a portability issue; it's a correctness issue.
But still it doesn't make sense, cause when a target has no
dependencies, it is always run... at least AFAIK...
NOT if it exists[1]. The build command is being skipped because make
sees that 'bootsect.MBR' already exists and is satisfied. Because the
rule has no pre-requisites, it has no way to know if it is out of date.
It's strange that I said a so-stupid-thing, because a while before I had
concluded that it's only executed if the file doesn't exist...
It is executed if the target does not exist, or if it is out of date.
Without specifying prerequisites, make cannot determine if it is out of
date, so simple existence will skip the commands.
The first "version" of the bootldr's Makefile was a "dummy" one... it
only created a file with many zeros using dd:
---------------------------------
all: bootldr.sys
bootldr.sys:
dd if=/dev/zero of=bootldr.sys count=somecount bs=somevalue
cp bootldr.sys ..
---------------------------------
So the file would only be created if it had been deleted...
This rule in fact perfectly correct, because it *has* no
pre-requisites; the file cannot be "out of date" except with respect to
commands in the Makefile itself (if you were being very correct, you'd
add a dependency on the Makefile).
The correct fix to your problem is to add the correct prerequisite(s)
to your rule for bootsect.MBR - which are the input files used by the
rule's command(s). The same needs to be done for 'bootldr.sys' rule.
The problem of this is that it breaks structure... The idea is that this
Makefile should not need to know anything about how the file is
generated... it only needs to invoke make inside bootsect/ and see if it
was updated...
This is a problem you have to solve. Currently, you're not giving make
enough information for it to work properly. It will probably be helpful
to avoid sub-makes, although a correct solution can still be recursive.
[2]
http://members.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html
It's not very important, but I could figure out this document's date...
In the abstract it says 1997 but the other pages in the PDF say it's 29
March 2006!
JJ
.
- Follow-Ups:
- Re: Strange behavior with Make dependencies...
- From: João Jerónimo
- Re: Strange behavior with Make dependencies...
- References:
- Strange behavior with Make dependencies...
- From: João Jerónimo
- Re: Strange behavior with Make dependencies...
- From: João Jerónimo
- Re: Strange behavior with Make dependencies...
- From: toby
- Re: Strange behavior with Make dependencies...
- From: João Jerónimo
- Strange behavior with Make dependencies...
- Prev by Date: Re: Strange behavior with Make dependencies...
- Next by Date: Re: question on passed values and pointer assignments
- Previous by thread: Re: Strange behavior with Make dependencies...
- Next by thread: Re: Strange behavior with Make dependencies...
- Index(es):
Relevant Pages
|