I’m wondering if there’s a way to implement trap in GNU make, similar to that built into BASH?
If the user presses CTRL-C, or if make itself fails (non-zero exit), I’d like to call a particular target or macro.
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.
No. GNU make’s signal handling already leaves a lot to be desired. From within its signal handler, it calls functions like
printfthat are not safe to be called from within a signal handler. I have seen this cause problems, for example.DELETE_ON_ERRORrules don’t always run ifstderris redirected tostdout.For example, on a CentOS 7.4 box:
Create the following
Makefile:Open it in
vimand run:make,Vim/make prints
Make was sent an interrupt signal, but
foostill exists.