Skip to main content
GameDev.net gamedev.net
🔒 Locked

check error codes in GNU makefile

Started by cpp forever Oct 8, 2007 at 2:12 AM 0 replies 1.7k views
Original Post
cpp forever
cpp forever
Hello. I want to create a GNU makefile target smth like this:

test:
       -printf "printf ok"
       echo "printf fails, echo ok"

But I want to execute
echo "printf fails, echo ok"
only when previous command (
-printf "printf ok"
) returns non-zero. How to do that IF checking? Does GNU makefile provides smth like this? ------ Under linux, bash.
ai-blog.org: AI is discussed here.
ToohrVyk
ToohrVyk
make uses sh internally to process its commands, so you can use any kind of sh operation you see fit. In this particular case:

test:       printf "printf ok" || echo "printf fails, echo ok"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.