help-make
[Top][All Lists]
Advanced

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

Re: shell script return on a makefile.


From: German Escallon
Subject: Re: shell script return on a makefile.
Date: Mon, 14 Jun 2010 12:24:46 -0400
User-agent: Thunderbird 2.0.0.24 (X11/20100411)

Thanks!!!
Both answers were extremely helpful.

German.



Brown, Michael wrote:
There isn't a need to do that.  We've discovered that all is needed is that the 
shell get set with the -e option.  For example:
program : $(PROGRAM_OBJECTS)
        @set -e; \
    if [ -f $(BIN_DIR)/$@ ] ; then\
        mv $(BIN_DIR)/$@ $(BIN_DIR)/address@hidden; \
    fi;
        $(LINK_PREFIX) $(CC) -g $(LDFLAGS) -o $(BIN_DIR)/$@ main.c \
            $(PROGRAM_OBJECTS) $(LIBS) $(PINN_LIB_LIST); \
    if [ -f $(BIN_DIR)/Program ] ; then\
        rm $(BIN_DIR)/Program; \
    fi; \
    if [ -f main.o ] ; then\
        rm main.o; \
    fi; \
    ln -s $@ $(BIN_DIR)/Program;

No matter how far down into the directory structure one goes, the build process 
will bail.
MB
 --
You design it, I'll build it
e-mail: address@hidden
desk: 608-288-6969
cell: 608-206-6843

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf
Of John Calcote
Sent: Monday, June 14, 2010 10:47 AM
To: German Escallon
Cc: address@hidden
Subject: Re: shell script return on a makefile.

German,

This is easier than you think. Just remove the $(shell ... ) from around
your shell call and add the call to a target like this:

check_code:
        /path/to/my/script.sh

Then put the check_code target in your dependency graph somewhere.
Scripts return values to the shell. If you call these as commands
instead of having the make $(shell) macro invoke them, the exit code
becomes the command status to make.

John

On 6/14/2010 9:34 AM, German Escallon wrote:
Hello all,

How can I stop a build process based on the outcome of a shell script?
What I want to do is to run a script that verifies some of my code.
If the script succeeds, then I would continue to the next step, but if
it fails, I want to stop the make process.

First things first.  How can I know if my script succeeded or not??
I've tried reading and printing the $? environment variable.  Here's
what I've tried with a script that should always fail.

e.g:
  @$(shell /path/to/my/script.sh)
  @echo "result: $$?"

The line always prints "result: 0", regardless of the result. When I
run this same script on the console, and then echo the $? variable, I
always get the error code I'm hoping for.
If you have any suggestions on how to know the outcome of a script
w/out using the $? environment variable, please let me know.  Thank
you in advance.


German


_______________________________________________
Help-make mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-make

_______________________________________________
Help-make mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-make

The information contained in this message may be confidential and legally 
protected under applicable law. The message is intended solely for the 
addressee(s). If you are not the intended recipient, you are hereby notified 
that any use, forwarding, dissemination, or reproduction of this message is 
strictly prohibited and may be unlawful. If you are not the intended recipient, 
please contact the sender by return e-mail and destroy all copies of the 
original message.




reply via email to

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