On Wed, 2007-04-25 at 00:00 +0000, David Wuertele wrote: > I thought of that, but I also want to have another target use the\ > VERSION variable: > > /path/to/some/other/target-$(VERSION).img: $(dependencies); touch > $<at> > > The problem is that VERSION isn't getting set in time. I want to > create the file that VERSION depends on before this rule gets > evaluated.
You can't do that. Makefiles are read in before ANY targets are built, and target and prerequisites are fully expanded as they are read in. There is no way for make to run a rule before expanding all the makefiles. Except, by using include. Make has a very special feature that it will automatically try to rebuild all included files, and if any do get rebuilt then make will re-exec itself to read them in. So, you could do something like this: include version.mk version.mk : /path/to/some/file echo "VERSION = `grep VERSION $<`" > $@ Obviously that grep is not really what you want but you get the idea. Now, make will rebuild the version.mk file every time /path/to/some/file changes (and, /path/to/some/file itself will be tested to see if it also needs to be rebuilt first, just as any other target). If it does change, then make will re-exec itself to read in the new content of version.mk. -- ------------------------------------------------------------------------------- Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at: http://www.gnu.org http://make.paulandlesley.org "Please remain calm...I may be mad, but I am a professional." --Mad Scientist _______________________________________________ Help-make mailing list Help-make@gnu.org http://lists.gnu.org/mailman/listinfo/help-make