Dear Unix experts,
I would like to maintain a library consisting of several files with different
compilation options. That is, I would like to keep e.g., two different archive
files, libtest.a and libtest-dbg.a compiled with -O and -g flags respectively.
Suppose I have two files in the library, a.c and b.c. In this case, what is the
best strategy to maintain these libraries?
One example might be:
SRCS = a.c b.c
OBJS = $(SRCS:%.c=%.o)
OBJDIR = obj
HDRS = a.h b.h
CFLAGS = -O
%.o: %.c
.KEEP_STATE:
.INIT: $(HDRS)
all: $(OBJS)
mv *.o $(OBJDIR)
ar r libtest.a $(OBJDIR)/$(OBJS)
debug:= CFLAGS=-g
debug:= OBJDIR=obj-dbg
debug: $(OBJS)
mv *.o $(OBJDIR)
ar r libtest-dbg.a $(OBJDIR)/$(OBJS)
------
However, everytime I say make debug (even without modifiying or touching *.[ch] files)
it tries to recompile again. What's wrong here? I would appreciate if you could
give a better strategy to maintain various versions of library such as above.
Best regards and thanks in advance,
---
Schlumberger-Doll Research