delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/05/01:37:48

From: "Vyacheslav O. Myskin" <V DOT O DOT Myskin AT inp DOT nsk DOT su>
Organization: BINP RAS, Novosibirsk, Russia
To: djgpp AT delorie DOT com
Date: Wed, 5 Mar 1997 12:30:14 +0600
Subject: Re: Another makefile question
Reply-To: V DOT O DOT Myskin AT inp DOT nsk DOT su
Message-Id: <149344140@csd.inp.nsk.su>

On  4 Mar 97 at 2:06, George Foot wrote:

[snip]
>
> --- makefile ---
> all : depend main.exe
>
> depend : *.c *.cc *.h
>     gcc -E -MD -o NUL *.c *.cc
>
> main.exe : file1.o file2.o
>     gcc -o main.exe file1.o file2.o
>
> DEPS := $(wildcard *.d)
> ifneq ($(DEPS),)
> include $(DEPS)
> endif
> ----------------

If I understand right, this makefile will cause recreation of *all* .d files
*every* time you run make, even if none of the sources has changed, because
there is no way to see that the 'depend' target is up-to-date (it doesn't
exist).

>
> As I said, my makefile programming is poor, but you can replace the
> main.exe rule with whatever it should be. This will first create .d
> files for all .c and .cc files whenever any of the .c, .cc or .h files
> changes. Then it proceeds as JMA's suggestion earlier.
>
> This worked in every circumstance I could think of, including changing
> any of the .c, .cc or .h files and/or deleting one or all of the .d
> files, etc. The only case in which it won't replace a missing .d file
> is if there weren't any changes to the source, in which case it isn't
> necessary. Recreating the .d files with every source change doesn't
> really hurt, because it's such a fast operation anyway, compared to the
> actually compilation and linking.
>
> If I have made any mistakes here, I'd like to hear them; if not, I'll
> adopt this style for all my future makefiles, and learn the proper
> syntax :)
>
> --
> George Foot <gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk>
> Merton College, Oxford.
>______________________________________________
Vyacheslav O. Myskin  <myskin AT inp DOT nsk DOT su>
Budker Institute of Nuclear Physics (BINP RAS)
Novosibirsk, Russia

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019