help-make
[Top][All Lists]
Advanced

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

Re: Canonical method of rebuilding makefiles?


From: Paul D. Smith
Subject: Re: Canonical method of rebuilding makefiles?
Date: Thu, 7 Mar 2002 09:20:18 -0500

%% "Miller, Bryan" <address@hidden> writes:

Please always specify what version of GNU make you are using, and the
OS and version you're using it on.  Thanks...

  mb> I have read and re-read section 3.5 "How Makefiles are Remade" in
  mb> the GNU make manual but I am still wrestling with correctly
  mb> rebuilding a makefile to include updated dependency files.  When I
  mb> turn on -d I can see the makefile being regenerated and the
  mb> include files being read but I am not able to see the updated
  mb> variables.

  mb> .PHONY: all

  mb> -include base_deps.mk
  mb> -include app_deps.mk

  mb> all: base_deps.mk
  mb>   @echo $(app_deps)

  mb> # regenerate the dependency files...
  mb> base_deps.mk:
  mb>   cqperl get_depends.pl

Since you don't provide the get_depends.pl or an example of the contents
of base_deps.mk after it's been run, it's hard to guess what the problem
is.  I changed your makefile to not require any external files:

  .PHONY: all

  -include base_deps.mk
  -include app_deps.mk

  all: base_deps.mk
        @echo $(app_deps)

  # regenerate the dependency files...
  base_deps.mk:
        echo 'app_deps = foo bar baz' > $@

and this works fine:

  $ ls base_deps.mk
  ls: base_deps.mk: No such file or directory

  $ make
  echo 'app_deps = foo bar baz' > base_deps.mk
  foo bar baz

  mb> The *_deps.mk files are generated by get_depends.pl.  Since they
  mb> need to be generated everytime I have added one of them as a
  mb> dependency to the default target.

The above makefile won't do what you say.

When make is deciding to rebuild a target it doesn't care at all what
other targets _depend on it_, it only cares what targets _it depends
on_.

So, saying that base_deps.mk is a prerequisite of all won't cause
base_deps.mk to rebuild every time--it will only be rebuilt if it
needs to based on its prerequisites.  Since it doesn't have any
prerequisites, it will only be rebuilt if it doesn't already exist.

  mb> Is there a better way to do this (double colon rule?)?  I have
  mb> read section 3.5 (How Makefiles are Remade) of the GNU Make book
  mb> (3.77) but it really muddies the waters quite a bit.  It suggests
  mb> that make will consider all makefiles (and include.mk files) as
  mb> targets and will rebuild them if a rule is provide.

Why is that muddy?  That is _exactly_ what will happen.

  mb> I have not found that to be true in clearmake GNU compat mode.

Aha!!

You are not using GNU make, you are using clearmake -C gnu.

That explains everything.

Clearmake does _NOT_ support this feature (rebuild/re-exec if included
files change), even in GNU emulation mode.  In fact, there are quite a
number of GNU make features that clearmake -C gnu does not support.
Clearmake -C gnu is essentially a strict subset of GNU make.

If you have questions about behaviors please try them with vanilla GNU
make first, and if it doesn't work there feel free to ask on these
lists.  If it does work there but not in clearmake -C gnu you should
file a bug against clearmake :).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]