Mail Archives: djgpp/1997/03/05/01:37:48
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 -