From: "Vyacheslav O. Myskin" 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 > Merton College, Oxford. >______________________________________________ Vyacheslav O. Myskin Budker Institute of Nuclear Physics (BINP RAS) Novosibirsk, Russia