[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about error detection
From: |
Paul Smith |
Subject: |
Re: Question about error detection |
Date: |
Thu, 02 Oct 2014 15:35:29 -0400 |
On Thu, 2014-10-02 at 15:11 -0400, Cooper, Robert (Ftg Ops) wrote:
> (I don’t see how one replies directly to the thread, so I clicked on
> the button to email you, apologies if that is inconvenient.)
You just reply to the mailing list (put it into the To: or CC: line of
your message).
> We are running Make 4.0 on Red Hat Linux --
>
> My primary makefile build recipe –
>
> build : $(VERSION_FILE) rel_dirs shlib vendor_libs
> $(QUIET) echo "SPM: Constructing release directory tree"
> $(QUIET) for dir in $(BLD_DIRS); do \
> $(MAKE) -f Makefile.gnu --directory $$dir build TYPE=$(TYPE)
> VERSION=$(VERSION) VERBOSE=$(VERBOSE) ; \
> done
> $(QUIET) $(FLAG_FULL_BUILD)
Yep, that's it.
You have a loop across all the subdirectories and in each one you run
make. But you never check whether each make succeeded or failed, so any
make failure in a directory other than the last one will be ignored.
Only failures in the very last directory will be seen.
Make just hands the entire for-loop to the shell and waits to see what
the shell exits with; it's up to you to make sure it exits with an error
code if there's an error.
Use something like this instead:
for dir in $(BLD_DIRS); do \
$(MAKE) -f ... || exit 1; \
done
Note the addition of the "|| exit 1" so that if that make command fails
we exit immediately with an error.
In general, doing loops in a shell like this is very un-make-like. For
example, if you wanted to use parallel build support it won't work as
well as it could here: each of those sub-makes will be run serially by
the shell regardless of how much parallelism you enable (inside the
sub-make you'll get parallelism, of course). Also, if you run make with
"-k" (keep going) it won't do what you want here, because the loop exits
out always the first time it hits an error.
This can be fixed, but I won't go into it unless you're interested.