[Top][All Lists]

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

Re: Pre-including a generated file

From: Paul Smith
Subject: Re: Pre-including a generated file
Date: Wed, 12 Aug 2009 12:22:27 -0400

On Wed, 2009-08-12 at 11:46 -0300, 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.

This is not how it works with automatic dependencies: as John points out
make always reads all its makefiles, then it tries to rebuild them all,
then (if it rebuilds any of them) it re-execs itself.

There is no way to change this such that it won't read any makefiles
before trying to rebuild them.

If you really want that command run every single time, probably simpler
is to remove the rule to build it and just use $(shell ...), like this:

        __dummy := $(shell ./gen_file)
        include file

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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