[Top][All Lists]

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

Re: Catching the exit status into a make variable

From: Paul Smith
Subject: Re: Catching the exit status into a make variable
Date: Sun, 02 Jan 2011 10:46:39 -0500

On Sun, 2011-01-02 at 09:34 +0100, Karl wrote:
> Hello everybody,
> I have to convert an OpusMake file to gnu make.
> After lines like
> %.obj : %.cpp
>   - $(COMPILER) ...
> there is a variable $(STATUS) which contains the exit status.
> Dependent on it, the $(EDITOR) is called to allow the user to
> correct the errors in the source, and then a line "%abort" is
> called to terminate the make run.

I'm not quite sure how such a thing would be used in a makefile, since
make is not a procedural language.  At any rate, nothing like that is
available in GNU make.

In order to implement something like that you'd have to do it entirely
in shell code.  For example, in the above rule you could define the
COMPILER variable to be something like this:

  COMPILER = $(orig-COMPILER) || { $(EDITOR) $<; exit 1; }

(untested) where $(orig-COMPILER) is the original compilation command.
This says if the compilation command fails then invoke $(EDITOR) on the
first prerequisite and exit with a failure, which will cause make to

If your $(orig-COMPILER) value is a complex command, of course, you will
have to get more fancy.

 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]