Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

perl from makefile

by bhasky76 (Initiate)
on Jun 13, 2013 at 07:08 UTC ( #1038692=perlquestion: print w/replies, xml ) Need Help??
bhasky76 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am using a makefile to do the following things 1. perl script to parse a C file. Then 2. using gcc to compile the same C file. Now in case there is a gcc compilation error it stops the make utility at that point. But I am unable to stop the make if there is any compilation/runtime error while executing the perl script. Please shed some light.

The makefile is like
@echo Parsing tmp.c; \ perl arg1 arg2;\ echo Compiling tmp.c;\ gc tmp.c

Replies are listed 'Best First'.
Re: perl from makefile
by choroba (Bishop) on Jun 13, 2013 at 07:31 UTC
    Makefile stops, if the command returns a non-zero exit status. In a command list (i.e. simple commands separarated by semicolons), the exit status is the status of the last command in the list. You have two options:
    1. Remove the semicolons and backslashes. Make will run each line separately and stop if there is a problem.
    2. Replace each semicolon with a &&. That way, the shell will stop on the first error (short circuiting the "and").
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: perl from makefile
by aitap (Curate) on Jun 13, 2013 at 07:27 UTC
    This is Makefile question, not a Perl question. Your Makefile says: "run a command consisting of four lines without printing it". Remove backslashes, and you'll have four different commands, and make will be able to stop the execution if Perl parser fails. You can also add set -e; \ before perl ..., this will make the subshell which is running your multi-line command fail if any of the following commands fail.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038692]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-05-27 16:10 GMT
Find Nodes?
    Voting Booth?