How can I force make to exit if compiling one dependency fails?
I've posted the relevant bits of my makefile. When I run make all
on this makefile, there's a compilation error when compiling debugosd.o
. However, because make found a previously built debugosd.o
, it just continues on to build dialup.otz
.
Without deleting all the .o's, how can I force debugosd.o
to become out-of-date - and so force make
to stop as soon as it hits the compilation error in debugosd.o
?
The rule to build .o files is:
%.o: %.c
$(TITLE)
$(CC) $(COMPILE) $(C_OPTIONS) -c $<
And the makefile snippet is:
all: shared0.flw shared1.flw shared2.flw shared3.flw
debugosd.o: debugosd.c debugosd.h
xdialler_interface_new.o: xdialler_interface.h
dialup.ooo: xdialler_interface_new.o debu开发者_如何转开发gosd.o xDialler.a
$(TITLE)
$(MAKE_OOO)
dialup.otz: dialup.ooo
$(BIN)opress $<
shared1.dir: dialup.otz
$(TITLE)
$(BIN)dirbuild $(SHAREDDIR1_OPTIONS)
shared1.flw: shared1.dir
$(TITLE)
$(BIN)flwbuild $(SHAREDFLW_OPTIONS1)
Actually, I figured out what the problem was. I was forcing the rebuild of shared1.flw
using a phony target. I think this was then forcing make
to continue regardless of errors.
You have no specific subcommands listed for debugosd.o
so I'm assuming it's using the default, somewhere (such as .c.o
).
Make should exit if any of the subcommands return a non-zero exit code, unless the command begins with -
. Check the actual command that's being used for the dubugosd.o
target.
Whether there's a previously built file shouldn't matter, make
should not carry on after an error condition.
精彩评论