Makefile Continue On Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company
Makefile Catch Error
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs make error 1 ignored Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, makefile exit on error just like you, helping each other. Join them; it only takes a minute: Sign up How to ignore mv error? up vote 26 down vote favorite 3 I'm making a Makefile that moves an output file (foo.o)
Recipe For Target Failed Makefile
to a different directory (baz). The output file moves as desired to the directory. However since make won't recompile the output file if I type make again, mv gets an error when it tries to move the non-existent empty file to the directory baz. So this is what I have defined in my rule make all after all compilation: -test -e "foo.o" || mv -f foo.o ../baz Unfortunately, I'm still getting errors. makefile share|improve
Make Keep Going
this question edited Apr 10 '15 at 22:27 Willem Van Onsem 29k64695 asked Jun 29 '10 at 18:28 Sam 307267 1 Look at what altendky did: -mv foo.o ../baz –Malcolm Apr 2 '13 at 18:21 add a comment| 5 Answers 5 active oldest votes up vote 9 down vote accepted +@[ -d $(dir $@) ] || mkdir -p $(dir $@) is what I use to silently create a folder if it does not exist. For your problem something like this should work -@[ -e "foo.o" ] && mv -f foo.o ../baz share|improve this answer answered Jun 29 '10 at 18:42 Charles 2,52612038 i still get an ignored error when using this but was the best solution so far. thanks –Sam Jul 1 '10 at 17:42 yes you will still get the silent ignore error from make, which I dont quite agree with as @ should make it completely silent. –Charles Jul 1 '10 at 20:33 @ does not affect the output from make of from the command, it only tells make not to print the invokation itself. –JesperE Jul 2 '10 at 8:55 add a comment| up vote 80 down vote Errors in Recipes (from TFM) To ignore errors in a recipe line, write a - at the beginning of the line's text (after
in the recipe is executed in a new shell; after the last line is finished, the rule is finished. If there is an error (the exit makefile exit status status is nonzero), make gives up on the current rule, and perhaps
Makefile Exit Code
on all rules. Sometimes the failure of a certain recipe line does not indicate a problem. For example, you makefile stop on error may use the mkdir command to ensure that a directory exists. If the directory already exists, mkdir will report an error, but you probably want make to continue regardless. To http://stackoverflow.com/questions/3143635/how-to-ignore-mv-error ignore errors in a recipe line, write a ‘-’ at the beginning of the line’s text (after the initial tab). The ‘-’ is discarded before the line is passed to the shell for execution. For example, clean: -rm -f *.o This causes make to continue even if rm is unable to remove a file. When you run make with the ‘-i’ https://www.gnu.org/s/make/manual/html_node/Errors.html or ‘--ignore-errors’ flag, errors are ignored in all recipes of all rules. A rule in the makefile for the special target .IGNORE has the same effect, if there are no prerequisites. These ways of ignoring errors are obsolete because ‘-’ is more flexible. When errors are to be ignored, because of either a ‘-’ or the ‘-i’ flag, make treats an error return just like success, except that it prints out a message that tells you the status code the shell exited with, and says that the error has been ignored. When an error happens that make has not been told to ignore, it implies that the current target cannot be correctly remade, and neither can any other that depends on it either directly or indirectly. No further recipes will be executed for these targets, since their preconditions have not been achieved. Normally make gives up immediately in this circumstance, returning a nonzero status. However, if the ‘-k’ or ‘--keep-going’ flag is specified, make continues to consider the other prerequisites of the pending targets, remaking them if necessary, before it gives up
& Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers Search Forums Show Threads Show Posts Tag Search Advanced Search http://www.unix.com/unix-for-dummies-questions-and-answers/77084-forcing-makefile-ignore-errors.html Unanswered Threads Find All Thanked Posts Go to Page... learn unix and linux commands Forcing Makefile to Ignore Errors UNIX for Dummies Questions & Answers Thread Tools Search this Thread Display Modes #1 08-13-2008 http://serverfault.com/questions/153875/how-to-let-cp-command-dont-fire-an-error-when-source-file-does-not-exist SkySmart Registered User Join Date: Dec 2006 Last Activity: 19 October 2016, 5:43 PM EDT Posts: 806 Thanks: 611 Thanked 3 Times in 3 Posts Forcing Makefile to Ignore Errors Is there A way I can Force a on error makefile to ignore errors? i believe it is using gcc. i have a set of commands in the makefile that i want to run and each time the makefile gets to the point of this commands, it aborts because of the commands. how can i get the makefile to keep running despite the errors it comes across as a result of my newly inputted commands? thanks Remove advertisements Sponsored Links SkySmart View Public Profile Find all posts by SkySmart makefile continue on #2 08-13-2008 fpmurphy who? Join Date: Dec 2003 Last Activity: 12 June 2016, 11:03 PM EDT Location: /dev/ph Posts: 4,996 Thanks: 73 Thanked 475 Times in 437 Posts Unfortunately you did not tell us which particular make you are using - gmake, make, nmake, etc. Remove advertisements Sponsored Links fpmurphy View Public Profile Visit fpmurphy's homepage! Find all posts by fpmurphy #3 08-13-2008 jim mcnamara ...@... Join Date: Feb 2004 Last Activity: 19 October 2016, 9:50 PM EDT Location: NM Posts: 10,838 Thanks: 451 Thanked 971 Times in 902 Posts The concept of a make is that it is error free, warning free or it is no good. Remove your offending commands if the syntax is causing an error. make -i ignores all errors You can add a - (hyphen) as a prefix to a given command, this causes make to ignore the fact that it failed. I think -i and the - are pretty standard. But. If you have errors you did not have a good compile. IF the code runs correctly it is by accident. jim mcnamara View Public Profile Find all posts by jim mcnamara #4 08-13-2008 SkySmart Registered User Join Date: Dec 2006 Last Activity: 19 October 2016, 5:43 PM EDT Posts: 806 Thanks: 611 Thanked 3 Times in 3 Posts thanks everybody. this makefile is a shell script. i unde
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top How to let 'cp' command don't fire an error when source file does not exist? up vote 19 down vote favorite 4 I'm using Mac OS X. I'm trying to copying some files with cp command for a build script like this. cp ./src/*/*.h ./aaa But this command fires an error if there is no .h file in ./src directory. How to make the command don't fire the error? (silent failure) The error makes build result fail, but I just want to copy when only there are some header file. shell copy share|improve this question edited Nov 29 '14 at 20:16 Valentin Lorentz 1508 asked Jun 23 '10 at 2:55 Eonil 1,70982344 add a comment| 5 Answers 5 active oldest votes up vote 27 down vote accepted If you're talking about the error message, you can suppress that by sending it to the bit bucket: cp ./src/*/*.h ./aaa 2>/dev/null If you want to suppress the exit code and the error message: cp ./src/*/*.h ./aaa 2>/dev/null || : share|improve this answer answered Jun 23 '10 at 4:07 Dennis Williamson 41.2k966106 1 It would be nice to explain what : means in this context. –Piotr Dobrogost Feb 10 '14 at 15:35 7 @PiotrDobrogost: In Bash and some other shells the colon is a null utility (no-op). It's specified by POSIX. Since it always returns true, it's used here to suppress the exit code of a failed cp (should that be desired). The shell builtin true could be used instead and would be more readable. –Dennis Williamson Feb 10 '14 at 15:46 More about : – What Is the Purpose of the `:' (colon) GNU Bash Builtin? –Piotr Dobrogost Feb 10 '14 at 15:49 add a comment| up vote 6 down vote You're looking for something along the lines of if [ -e file ] then cp file /somewhere fi (Unfortunately, the -f option is not the droid you're looking for.) If you want to match a glob, that won't work; use find instead, e.g.: find ./src -name \*.h -exec cp {} ./destination \; share|improve this answer edited Jun 23 '10 at 3:27 answered Jun 23 '10 at 3:19 Brad