Reputation: 15
I was compiling a program using makefile and wanted to display a message to the user if there is any error in the program. I searched for this and found that the exit status is zero if make is successful else it is non-zero. How to use these values of exit status to accomplish the above task or is there any other way of doing so ?
Upvotes: 2
Views: 1149
Reputation: 1898
You have to create a bash script and call make command in that, you can check result of each command(or which command you want to check if successful) and print a message using echo if it fails as
#!/bin/bash
cd <YOUR_DIRECTORY_CONTAINING_MAKEFILE>
make
if [ $? -ne "0" ]; then
echo "Make failed"
exit 1
fi
echo "make Successful"
$? holds result of last command.
Now, to make your program and see result, you have to run this bash script
Upvotes: 1