Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pause GNU Make in a Windows console if an error occurs

Part of the install for an app I am responsible for, compiles some C code libraries. This is done in a console using GNU Make.

So, as part of the install, a console window pops open, you see the make file output wiz by as it compiles and links, when finished the console window closes and the installer continues.

All good, unless there is a compilation error. Then the make file bugs out and the console window closes before you have a chance to figure out what is happening.

So, what I'd like to happen is have the console window pause with a 'press a key to continue' type functionality, if there is an error from the makefile so that the console stays open. Otherwise, just exit as normal and close the console.

I can't work out how to do this in a GNU Makefile or from a batch file that could run the Make.

like image 583
Simon Peverett Avatar asked Sep 18 '08 09:09

Simon Peverett


2 Answers

this should do the trick:

if not ERRORLEVEL 0 pause

type help if in DOS for more info on errorlevel usage.

like image 97
Amir Arad Avatar answered Oct 02 '22 12:10

Amir Arad


This is what you're looking for:

if ERRORLEVEL 1 pause

If you type

HELP IF

you get this info: ERRORLEVEL number | Specifies a true condition if the last program run returned an exit code equal to or greater than the number specified.

like image 25
Benja Avatar answered Oct 02 '22 12:10

Benja