help-make
[Top][All Lists]
Advanced

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

Re: Issue with automatic dependency generation in gmake


From: Leandro Lucarella
Subject: Re: Issue with automatic dependency generation in gmake
Date: Fri, 11 Sep 2009 11:40:34 -0300
User-agent: mutt-ng/devel-r804 (Debian)

Varambally, Dheeraj B, el 10 de septiembre a las 11:06 me escribiste:
> Hi,
> 
> I'm trying to automatically generate the dependency files from my
> C compiler and including it using the -include directive But gmake does
> not seem to abort upon encountering the first compile error in
> a C source file. It seems to continue building the rest of the files
> . How can we make gmake abort upon encountering the first error.  It
> works fine if I do not include the dependency file.
> 
> Here is a snapshot of what I'm trying to do
> 
> Target : src
>               $(CC) -c  $(CFLAGS) -makedep $(DEPFILE)
> 
> 
> -include $(DEPFILE)

I have something like this working with GCC as follows:

SRC = file1.c file2.c
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)

%.o: %.c
        $(CC) -c $(CFLAGS) -MMD -MP -o $@ $<

-include $(DEP)

(-MMD option generates a .d file with make dependencies)
I had the same problem you mention when I used this rule instead:

%.o %.d: %.c
        $(CC) -c $(CFLAGS) -MMD -MP -o $@ $<

Because Make wanted to build the dependency files to update the Makefile,
and at that phase, if the compilation failed, make didn't stop (because of
the *optional* include, I guess). Fortunately removing the %.d does the
trick, because I want to use only the existent dependency files and ignore
the missing ones. I don't want the .d files get generated because the
corresponding .c files has to be compiled anyways if the .d is not
present, and in that case I don't care about the dependencies.

Maybe you have some extra rule on how to build the $(DEPFILE) and that is
what's triggering the compilation when updating the Makefile like it
happened to me?

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Wenn ist das nunstück git und slotermeyer? Ja!
Beiherhund das oder die Flipperwaldt gersput!
        -- Monty Python (no leer si sabés alemán)





reply via email to

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