help-make
[Top][All Lists]
Advanced

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

Re: execution of rules in included Makefiles


From: Paul Smith
Subject: Re: execution of rules in included Makefiles
Date: Tue, 9 Nov 2010 16:22:34 -0500

On Tue, 2010-11-09 at 16:00 -0500, Chris Cross wrote:
> I have a makefiles of the form:
> 
> #Makefile
> 
> .PHONY: all
> all: foo
> 
> foo: foo.o
>         $(CC) $< $(LIBS) -o $@
> 
> include Makefile.rules
> include Makefile.gen
> 
> # end Makefile
> 
> Makefile.rules contains some pattern rules. Makefile.gen contains a
> rule and that recipe is being executed before before the recipe for
> foo in the outer Makefile. I'm probably not reading close enough, but
> the manual doesn't seem to address execution of rules in included
> Makefiles. Do rules in included Makefiles get executed in the read
> pass of the outer Makefile?

Not sure what you mean: make is not a procedural language.  Make always
reads all the makefiles, which includes all "include"d makefiles, into
an internal dependency graph.  No targets are built during the read
pass.

Only after everything is read in and processed does make start walking
the graph to determine what to build.

Now, you don't give enough information about what you're seeing to say
for sure, but one thing to note is that make will try to rebuild any
included makefiles.  So if your makefiles have rules that might apply to
the included makefiles ("Makefile", "Makefile.rules", or "Makefile.gen")
then those might be run before the first target is built.




reply via email to

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