Paul D. Smith wrote:
%% Joost Leeuwesteijn <[EMAIL PROTECTED]> writes:

jl> You can check if make is run from the root directory by including a jl> first/default rule in the dir1 makefile that stops the build. Something jl> like:
  jl> ----------------------------------------
  jl> .PHONY : dir1_default_rule
  jl> dir1_default_rule :
  jl>       echo "ERROR: only run the toplevel makefile"
  jl>       <not sure what's the best way to bail out (exit 1?, $$(error ...)>

jl> and/or check on a variable that must be set by the toplevel makefile and jl> call $(error ...)
  jl> ----------------------------------------

You could instead check the MAKELEVEL variable to see whether this is
the top-level make, or a recursive invocation.

If you also want to rule out the single (sub)makefile "execution" you can't use MAKELEVEL, I believe. If you run 'make -f submakefile' the MAKELEVEL would still indicate toplevel make (right?), but I was trying to force execution of the toplevel makefile only. By bailing out in the default rule, or checking a variable that should be set by the toplevel makefile before including the submakefiles. If you execute the submakefile on it's own, I need to bail out because of variables that are supposed to be set from the toplevel makefile.

I was talking about the include situation, not recursion. My build environment doesn't use recursion; seems to be harmful ;-)

Regards,
Joost


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to