[Top][All Lists]

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

Re: Fw: Recursive use of make vs stop

From: Paul D. Smith
Subject: Re: Fw: Recursive use of make vs stop
Date: Tue, 9 Sep 2003 21:37:25 -0400

%% "Johan Eriksson" <address@hidden> writes:

  >> I would like make to stop immediatelly if an error occurs. How can I
  >> make this happen in a recursive make builds ??

Make stops whenever a command it invokes fails, whether that command is
a compiler or a sub-make or whatever.

  >> I have a number of directories and sub-directories that I would
  >> like make to traverse. If an error occurs while compiling a file in
  >> one of the directories, make shall stop and not conitinue with the
  >> files in the next directory.
  >> To get make traverse I use a "for i in $DIRS" statement, where $DIRS
  >> contains the directories.

Don't do that.  If you have to do that, then you have to manage the exit
yourself, because make takes your entire script and hands it to shell,
then make sits around waiting for the shell to be done.  If you put a
loop into your command script, then the shell will execute it and
there's nothing make can do (or know) about whether it worked or not
until it's done.

If you have to do it in a list you should use something like:

    for i in $(DIRS); do $(MAKE) -C $$i || exit 1; done

But the better way is to not use a loop at all (this latter method also
allows you to make full use of parallel or distributed builds should you
want to):

    subdirs: $(DIRS)

            $(MAKE) -C $@

    .PHONY: subdirs $(DIRS)

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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