Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have GNU make explicitly test for failure?

People also ask

What is $$ in makefile?

$$ means be interpreted as a $ by the shell. the $(UNZIP_PATH) gets expanded by make before being interpreted by the shell.

What does GNU make do?

GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files.

What is $( make in makefile?

And in your scenario, $MAKE is used in commands part (recipe) of makefile. It means whenever there is a change in dependency, make executes the command make --no-print-directory post-build in whichever directory you are on.

What is ?= IN make?

?= indicates to set the KDIR variable only if it's not set/doesn't have a value. For example: KDIR ?= "foo" KDIR ?= "bar" test: echo $(KDIR) Would print "foo"


Put a - before the command, e.g.:

-myProg bad_input >> test.log

GNU make will then ignore the process exit code.


Try running it as

make -i

or

make --ignore-errors

which ignores all errors in all rules.

I'd also suggest running it as

make -i 2>&1 | tee results

so that you got all the errors and output to see what happened.

Just blindly continuing on after an error is probably not what you're really wanting to do. The make utility, by its very nature, is usually relying on successful completion of previous commands so that it can use the artefacts of those commands as pre-requisites for commands to be executed later on.

BTW I'd highly recommend getting a copy of the O'Reilly book on make. The first edition has an excellent overview of the basic nature of make, specifically its backward chaining behaviour. Later editions are still good but the first ed. still has the clearest explanation of what's actually happening. In fact, my own copy is the first thing I pass to people who come to me to ask "WTF? questions" about make! (-:


The proper solution if you want to require the target to fail is to negate its exit code.

# Makefile
# 
test:
    myProg -h > test.log              # Display help
    myProg good_input >> test.log     # should run fine
    ! myProg bad_input1 >> test.log      # Error 1
    ! myProg bad_input2 >> test.log      # Error 2

Now, it is an error to succeed in those two cases.