help-make
[Top][All Lists]
Advanced

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

Re: Automatic dependencies and clean rule


From: Nick Andrik
Subject: Re: Automatic dependencies and clean rule
Date: Thu, 28 Mar 2013 04:53:01 +0100

>> My problem is that every time that I run make clean, the rules for
>> creating DEPS are executed again.
>> Is there any way to tell the Makefile to ignore the final include line
>> (or empty the DEPS var) when I run make clean?
>
> The really short answer is that you should read
>         http://make.paulandlesley.org/autodep.html#advanced

I have laready been through that, but I found no way to get rid of the
.d generation when I call clean

>
>> In my case I need the .d files before I generate the .o ones since I
>> use generated files from flex/bison and I need to respect the
>> dependencies.
>
> When there are file that require two stages to build, the second of
> which may require dependencies that you cannot calculate until the
> first is done (the lexer.c file might not be compilable without the
> parser.tab.h file generated by bison).  So, to auto-generate
> dependencies for the .o files you'll need to previously inform make of
> the relevant ".c: .y" and ".c: .l" dependencies.

Sorry for not being clear up front. I do have rules for generating all
the .cpp .hh .hpp files needed for the other rules. I didn't include
these rules in my initial example because I wanted to keep it kind of
simple. We can consider that there are rules for every generated c++
and header files.

> My preference is to declare the generated .h files to be order-only
> dependencies of *all* the .o files.  That way make will know that it
> has to generate the .h before it tries to compile the .o's, but once
> the .h exists the .o's will only be recompiled if the auto-dependency
> bits generate a *real* dependency on the .h.
>
> ${OBJS} : | parser.tab.h
>
> (...or whatever the name of the generated .h file(s) are)

Hmm, that's an interesting approach, but I still need to use the
-include directive, no?
If I do, then my problem persists: .d files are created for each make
clean invocation

By the way, I might go on with some double calling of the makefile and
check if I can get away with the include directive

Thanks a lot for your answer,
Nick

--
=Do-
N.AND



reply via email to

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