On 2012-01-27 11:43:10 (+0530), Manavendra Nath Manav <mnm.kernel@gmail.com> wrote:
I have developed a Makefile which recursively builds the code spread across multiple directories, each having it's own Makefile.
build_all: targetA \ targetB \ target C
Now, the problem is that even when the Makefile of targetA fails, the master Makefile continues building with targetB and targetC. I can also see the make errors being printed on console. I want the make to stop immediately at the first error encountered in any target Makefile. How to do this?
It would be a lot easier to help you if you'd post the relevant bits of your Makefile. Dusting off my crystal ball, I see in the mists that your makefile looks something like this: build: for d in $(DIRS) ; \ do \ $(MAKE) -C $$d $@ ; \ done The problem here is that make considers the whole for loop as one and doesn't get the exit status of each sub-make, but only of the last one. Try something like this instead: build: for d in $(DIRS) ; \ do \ $(MAKE) -C $$d $@ || exit $? ; \ done Regards, Kristof