|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Make: target not updated until run againI'm trying to create an "archive" (copy of the project) as follows:
The top level Makefile creates the directory and copies some stuff into it. Then it recurses into subdirectories, and tells them to add their own files to the directory it created. If the subdirectory Makefiles decide to actually add anything to the directory, they touch it to make it up to date. Then I've got another rule to "package" the archive into a tar file, which has the archive directory as a dependent, so it should only run if the directory is more up to date than the tar. The problem is, if the recursive Makefiles update the archive, but the top level doesn't, the tar rule doesn't run, until I run the target a second time. I hope the Makefile below illustrates my situation. Basically, the "archive" phony target is used to create the archive: it calls the "my_archive" target which is like the top-level archive rule (it only runs if the file "source" is more up to date than the my_archive dir), and then it calls the update_my_archive, which is meant to simulate the recursive makefiles: it updates the my_archive dir. "after- archive" is meant to take the place of the tar file: it should run whenever my_archive changes. the default target is "top", which calls the "archive" target to update the archive, and then calls after-archive. The "archive" target always (in this case) leads to my_archive being updated, so I would expect after-archive to have to run as well. But as I said, it only runs if I run make twice. Below is the makefile, and following that is a terminal transcript showing the output when I run make consecutive times. If anyone can explain why after-archive is considered up to date compared to my_archive, when a previous dependency updates my_archive, I would really appreciate it. Especially if you can also help me figure out how to fix it. Running GNU Make 3.81, on Fedora 9: Linux 2.6.26.5-45.fc9.i686 Thanks, -Brian ### Makefile: ###### .PHONY:top top: archive after-archive @echo Ran "top" .PHONY:archive archive: my_archive update_my_archive @echo Ran "archive" my_archive: source @echo Updating my_archive because source changed touch my_archive .PHONY:update_my_archive update_my_archive: @echo Further modifying my_archive... touch my_archive after-archive: my_archive @echo my_archive changed: touch after-archive ### End Makefile ######### ##### Terminal: ########## $ make top Further modifying my_archive... touch my_archive Ran archive my_archive changed: touch after-archive Ran top $ make top Further modifying my_archive... touch my_archive Ran archive Ran top $ make top Further modifying my_archive... touch my_archive Ran archive my_archive changed: touch after-archive Ran top $ make top Further modifying my_archive... touch my_archive Ran archive Ran top |
|
|
|
|
|
Re: Make: target not updated until run againHello Brian,
* mearns.b@... wrote on Fri, Oct 03, 2008 at 12:04:04AM CEST: > I'm trying to create an "archive" (copy of the project) as follows: > The top level Makefile creates the directory and copies some stuff > into it. Then it recurses into subdirectories, and tells them to add > their own files to the directory it created. Sounds like you're more or less doing manually what Automake provides with its 'distdir' rule. > If the subdirectory > Makefiles decide to actually add anything to the directory, they touch > it to make it up to date. That's the problem, AFAICS: you cannot have several rules updating the same file, that will confuse make. Whenever you can't express the dependencies between files as a directed tree, you have to either use stamp files, and/or reinvoke make within a rule to let it recompute the set of needed rules based on updated timestamps. For example, post-update actions can typically be realized like this: target: deps... update_target $(MAKE) post-action-for-target Hope that helps to get you going (otherwise please report back). Cheers, Ralf |
|
|
|
|
|
Re: Make: target not updated until run again* mearns.b@... wrote on Sun, Oct 05, 2008 at 11:48:24PM CEST:
> FYI, I'm not using automake because I'm trying to keep my project > easily cross-platform: I'm not sure if there's an easy to use set of > auto tools for windows. If you know of such a set, that'd be great. autotools work fine on w32, for example using Cygwin or using MinGW. Cheers, Ralf |
|
|
Re: Make: target not updated until run againBrilliant, Ralf! I got so caught up in why it wasn't working the way I
wanted it to, I couldn't come up with an alternate solution. "Recursively" calling Make with the post-update target worked just fine. I'm also pleased to hear autotools work so well on win32. I've seen that there are ports, but for some reason, I didn't have luck with them before. Probably because I assumed it was too much hassle. But it sounds like now would be a good time to learn how to use them. Thanks, so much. -Brian On Mon, Oct 6, 2008 at 2:09 AM, Ralf Wildenhues <Ralf.Wildenhues@...> wrote: > * mearns.b@... wrote on Sun, Oct 05, 2008 at 11:48:24PM CEST: >> FYI, I'm not using automake because I'm trying to keep my project >> easily cross-platform: I'm not sure if there's an easy to use set of >> auto tools for windows. If you know of such a set, that'd be great. > > autotools work fine on w32, for example using Cygwin or using MinGW. > > Cheers, > Ralf > |
| Free Forum Powered by Nabble | Forum Help |