bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make doesn't complain if target cannot be built


From: Christian Eggers
Subject: Re: make doesn't complain if target cannot be built
Date: Tue, 14 Jan 2014 06:56:06 +0100
User-agent: KMail/4.8.5 (Linux/3.8.0-rc6-2.20-desktop; KDE/4.8.5; x86_64; ; )

Am Montag, 13. Januar 2014, 17:20:43 schrieb Paul Smith:
> On Mon, 2014-01-13 at 22:23 +0100, Christian Eggers wrote:
> > In Makefile 2 my intention was to state that foo.o depends on some
> > generated header which must be generated first (might be in another
> > rule). But I didn't want to change the be behaviour if foo.o cannot be
> > built because e.g. there's no foo.c.
> 
> Unfortunately, this behavior is correct, and even required by the POSIX
> standard (and is implemented by every version of make).
> 
> Once a target is listed in the makefile it becomes "known" to 'make'.
> When make wants to build a target it will try to find an implicit rule
> for it.  However, if there is no implicit rule found it just means that
> there were no commands available for that target, not that the target
> couldn't be built.
> 
> According to the POSIX spec:
> 
>         If there are no commands listed for the target, the target shall
>         be treated as up-to-date.
> 
> This is actually useful behavior and is definitely taken advantage of in
> real makefiles.
> 

Is there a workaround for this? Using explicit rules seems to be difficult in 
my case because some objects are built from .c sources, other from .cpp.
Is there a better way instead of this:

SOURCES_C := foo.c
SOURCES_CPP := bar.cpp
SOURCES_ASM := ...

OBJS := $(SOURCES_C:%.c=%.o) $(SOURCES_CPP:%.cpp=%.o) ...

$(SOURCES_C:%.c=%.o):
        $(COMPILE.c) ...

$(SOURCES_CPP:%.cpp=%.o):
        $(COMPILE.cpp) ...

$(OBJS): generated.h

EOF

regards




reply via email to

[Prev in Thread] Current Thread [Next in Thread]