Mail Archives: djgpp/1997/06/29/11:07:21
Nate Eldredge wrote:
>
> Does anyone know of a way to have `make' rebuild only the changed members of
> a .a library? For example, I have a library libfoo.a containing func1.o,
> func2.o ... func(n).o. Each .o member is built from a .c source. The easy
> way is to do this:
> --cut--
> OBJS = func1.o func2.o [...] func(n).o
>
> libfoo.a : libfoo.a($(OBJS))
> --cut--
> and let implicit rules handle the rest. This is described in the Archives
> section of the docs. But what happens when I make is, if the library is not
> up-to-date, every source file is recompiled, and every member re-inserted.
> This can take a loooong time if `n' is large.
>
> So what I want is:
> for (each source file newer than libfoo.a) do
> compile source file
> gcc -o funcx.o funcx.c
> re-insert member
> ar -r libfoo.a funcx.c
>
> How do I get `make' to do this? Is it even possible?
There are two ways that I can think of.
Method 1:
OBJS = func1.o func2.o [...] func(n).o
libfoo.a : $(OBJS)
%.o : %.c
$(CC) -c $(CFLAGS) $<
$(AR) rs libfoo.a $@
This has the advantage of doing exactly what you want, but it would take
a long time if several source files were updated. A faster way would
be...
Method 2:
OBJS = func1.o func2.o [...] func(n).o
libfoo.a : $(OBJS)
$(AR) rs $@ $^
This compiles only the necessary library members and then rebuilds the
entire library.
I don't know why make isn't working right when you use the archive
member format to specify dependencies.
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| Descent 2: The Infinite Abyss - The greatest Internet game of all |
| time just got better! This time, you're going all the way down...|
---------------------------------------------------------------------
- Raw text -