help-gnu-utils
[Top][All Lists]
Advanced

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

Re: Help with GNU Makefile


From: Henrik Carlqvist
Subject: Re: Help with GNU Makefile
Date: Thu, 22 Jun 2006 08:07:05 +0200
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

g35rider@gmail.com wrote:
> $(OUT_LIB_DIR)/$(OUT_LIB): $(SRCS)
>         $(COMPILE) $(CFLAGS) -c $?
>         $(MKLIB) $(OUT_LIB_DIR)/$(OUT_LIB) $(OBJS)
>         $(RM) $(OBJS)

> This seems to work just fine for source file changes. But I cant seem to
> figure out how to add header file dependencies to it?

I can see 3 different ways:

1) Recompile all sources if any header file change.

2) List object dependencies in Makefile and recompile only whats necessary.

3) Let gcc do the job of way 2) by using the -M flag to create dependency
   files for include in your Makefile.

> The reason I didnt put the OBJ file rule in the makefile is because I
> dont want the .o files, I create an .a file out of all the .o's so I
> delete the .o's. So I skipped that step, thats y compiling and archiving
> are in one step.

> Now if I add $(INCLUDES) in the OUT_LIB target then if I change the
> header file, it tries to compile it, and I can see y it does that. I
> want when the header file is changed it should remake all the $(SRCS)
> files or a subset of those that depend on it.

You can't both have your cake and eat it. Say that your .a file contains
two .o files which depend on different .h files. If one .h file is changed
you have the choice between recompoling all .o files or only the .o file
that needs to be recompiled. To find out which .o file needs to be
recompiled gnu make must know the time stamp of the .o file and the .h
file. Gnu make will not know the time stamp of the .o file if it is hidden
in the .a file. To only recompile the .o file that depends on a .h file
you must leave the .o files visible to gnu make.

regards Henrik
-- 
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
root@variousus.net root@localhost




reply via email to

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