With GNU Make and one of the compilers in gcc: Is it possible to execute commands if (and only if) the compiling fails?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you prefix a command with
-, make keeps going even if the command returns a nonzero error code. But there’s no way to access the error code from the first command in the second command.You can write arbitrarily complex shell scripts in a single make command. For example, here is how to call two recovery commands if the C compiler fails, running the second one only if the first one fails, and then stopping the build process if the C compiler failed.