LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-19-2003, 12:36 PM   #1
gkhattak
LQ Newbie
 
Registered: Aug 2002
Posts: 3

Rep: Reputation: 0
Question Catching Make error


I have a target in my makefile that does a make in a bunch of directories. Even if the make finds an error it continues to the next directory since it is in a for loop. How can I catch an exit status of Make and stop it, or at least record the status and print it out after the loop is finished?

The loop looks like this....

all:
for d in $(DIRS) ; \
do \
( \
cd $$d; \
$(MAKE) $@; \
); \
done
 
Old 02-19-2003, 02:57 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
In a shell script this will work. I didn't test in a make file.
Code:
if ! $(MAKE) $@; then exit 1; fi
 
Old 02-19-2003, 06:28 PM   #3
gkhattak
LQ Newbie
 
Registered: Aug 2002
Posts: 3

Original Poster
Rep: Reputation: 0
Catching Make error in loop

that works, if I put an echo statement instead of exit, i see it fine...but it exits the make, but keeps going through the for loop still. How can i break out of that for loop I guess is my question.
 
Old 02-20-2003, 09:55 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
You can get the return value of the last executed command from the $? variable. You could use that to break out of your loop.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
catching signals alaios Programming 3 11-16-2007 05:05 AM
catching a keypress on X MD3 Programming 0 02-14-2005 02:07 PM
lopster v1.2.2 make error: No rule to make target `m4/glibc21.m4' Kropotkin Fedora 0 10-31-2004 11:19 AM
Catching a Hacker... Shr00mBoXx Linux - Security 14 06-30-2004 09:59 PM
make: cc: command not found make: *** [gzip.o]error 127 zyjk Linux - Newbie 5 02-08-2002 09:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration