Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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 (Chancellor) 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 (Deacon) 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]
NodeReaper snacks on some Soylent Green

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-06-29 15:15 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (671 votes). Check out past polls.