[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to exit the parent_make immediately when get an error in submake
From: |
Garrett Cooper |
Subject: |
Re: how to exit the parent_make immediately when get an error in submake |
Date: |
Thu, 27 Nov 2008 11:52:16 -0800 |
On Wed, Nov 26, 2008 at 1:07 AM, Tao T <address@hidden> wrote:
>
> unfortunately it dose not work. I change the code as you suggest:BUILDUNITS
> := $(shell $(foreach unit,$(ALL_UNITS),cd
> $(REPOSITORY_ROOT)/units/$(unit)/source/sc/beh && $(MAKE) $(MAKECMDGOALS)
> BUILD_TYPE=$(BUILD_TYPE) 1>&2 && true)) or BUILDUNITS := $(shell $(foreach
> unit,$(ALL_UNITS),cd $(REPOSITORY_ROOT)/units/$(unit)/source/sc/beh &&
> $(MAKE) $(MAKECMDGOALS) BUILD_TYPE=$(BUILD_TYPE) 1>&2;) && true)
> both doesn't work.
> maybe I write in a wrong way. do you have any other suggestion?
> Thank in advanced,
>
> Tao
>
>
> Greg Chicares-2 wrote:
>>
>> On 2008-11-25 15:12Z, Tao T wrote:
>>> for some reason it seems more complicated to get rid of shell.
>>> do you have any suggestion to use shell? thanks~
>>> currently my command have to change to :BUILDUNITS := $(shell $(foreach
>>> unit,$(ALL_UNITS),cd $(REPOSITORY_ROOT)/units/$(unit) && $(MAKE)
>>> $(MAKECMDGOALS) BUILD_TYPE=$(BUILD_TYPE) 1>&2;))
>>> It looks more complicated.
>>
>> The original question was how to stop on the first error. That's
>> the normal behavior of 'make'. But the $(shell) command simply
>> passes a string to a shell, and 'make' doesn't know what that
>> shell is doing until it returns. So, if you really want to use
>> $(shell) this way, you have to write the command so that it
>> stops on error. I guess you could write '&&' instead of ';', and
>> do something about the last '&&', e.g. add 'true' at the end:
>> $(shell command0 && command1 && ... && command99 && true)
Using `set -e', as others have suggested, is the cleanest way to deal
with exiting immediately after an error. Example:
target:
set -e; exec foo
The only catch is that it isn't portable on systems without a bourne
compatible shell.
I try and stray away from using $(shell ...), outside of setting
variables to the executed value, because there are usually workarounds
which are less error prone.
-Garrett
- Re: how to exit the parent_make immediately when get an error in submake, (continued)
- Re: how to exit the parent_make immediately when get an error in submake, Philip Guenther, 2008/11/24
- Re: how to exit the parent_make immediately when get an error in submake, Tao T, 2008/11/25
- Re: how to exit the parent_make immediately when get an error in submake, Greg Chicares, 2008/11/25
- Re: how to exit the parent_make immediately when get an error in submake, Tao T, 2008/11/25
- Re: how to exit the parent_make immediately when get an error in submake, Greg Chicares, 2008/11/25
- Re: how to exit the parent_make immediately when get an error in submake, Sam Ravnborg, 2008/11/25
- Re: how to exit the parent_make immediately when get an error in submake, Tao T, 2008/11/26
- Re: how to exit the parent_make immediately when get an error in submake, Tao T, 2008/11/26
- Re: how to exit the parent_make immediately when get an error in submake,
Garrett Cooper <=