|
From: | John Calcote |
Subject: | Re: Pre-including a generated file |
Date: | Wed, 12 Aug 2009 09:28:59 -0600 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Thunderbird/3.0b3 |
Hi Leandro, On 8/12/2009 8:46 AM, Leandro Lucarella wrote:
Hi. I would like to be able to include a generated file each time I run make. I have a small script that generates some make rules. The file should be generated *always*, and the results of the file should be included by make. I tried something like this: file: ./gen_file include file .PHONY: file But it doesn't work. It seems that make first includes the (old) file, then regenerate it. I tried to add a rule like Makefile: file to tell make to remake the Makefile itself when "file" is changed but it doesn't work either. This usually works with "automatic dependencies", so I guess there should be any way to get arround, but I tried and tried and came up with nothing.
First, you'll probably want to use sinclude, rather than include, as include will fail the build if the file is missing, which it will be the first time around. The way make works is to read the makefile, including whatever it's told to, new, old, or non-existent. Then it follows the rules to update these files. Any targets with the makefile as a dependency are updated first. If any of them must be rebuilt, then make rebuilds them (or executes the commands for those rules) and then -- and here's the magic -- it restarts the whole make process again.
- - - - - - - - - - - - file: ./gen_file Makefile: file sinclude file - - - - - - - - - - - -Don't use .PHONY on file. It's a real file, so you should tell make it's not, as it will get confused.
Regards, John
[Prev in Thread] | Current Thread | [Next in Thread] |