[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Submake question
From: |
Paul D. Smith |
Subject: |
Re: Submake question |
Date: |
Tue, 15 Oct 2002 11:15:30 -0400 |
%% address@hidden writes:
j> distall:
j> @for dir in $(GEN_MAKES_DIR); do \
j> make -C $$dir distall; \
j> done
First, _never_ use "make" to invoke submakes. You should _always_ use
the variable $(MAKE).
Second, this is not a good way to do sub-makes; better is to create a
target for each directory and have the rule for it build that one
subdirectory. Then you won't need a loop at all and if the sub-make
fails the build will fail, unless you specify -k.
There's an example of this in the GNU make manual section on "Phony
Targets".
j> My question is : How can i stop the process if i get some error in
j> a make ? I have read in 'make' manual, chapter 9, that the exit
j> status is not equal to 0 if any error is found, but how can i
j> access this value?
This is a shell question, not a make question. The contents of the
command script are shell commands.
j> distall:
j> @for dir in $(GEN_MAKES_DIR); do \
j> result = make -C $$dir distall; \
j> ifneq $result 0
j> $(error Subproject not made! )
j> endif
j> done
Well, you cannot use the make $(error ...) function because that will
always be evaluated before the shell script is even invoked.
You can do this two ways:
distall:
@set -e; \
for dir in $(GEN_MAKES_DIR); do \
$(MAKE) -C $$dir distall; \
done
or:
distall:
@for dir in $(GEN_MAKES_DIR); do \
$(MAKE) -C $$dir distall || exit 1; \
done
See your documentation for the Bourne shell (sh) for more info.
Note neither of these is optimal because now you have the opposite
problem: even if you run "make -k" it will still stop after the first
failure.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> 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