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. 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