Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!xadmx!rbj@dsys.icst.nbs.gov From: rbj@dsys.icst.nbs.gov (Root Boy Jim) Newsgroups: comp.unix.questions Subject: help with make needed Message-ID: <19392@adm.BRL.MIL> Date: 1 May 89 17:43:06 GMT Sender: news@adm.BRL.MIL Lines: 50 ? From: Svante Lindahl ? I have a makefile in a directory were I keep the source files for a ? library. The makefile compiles a source file if it is newer than the ? corresponding archive member, replaces the archive member and deletes ? the newly compiled object file. In make notation: ? TARGET = libfoo.a ? OBJECTS = $(TARGET)(a0.o) $(TARGET)(a1.o) ? .c.a: ? $(CC) $(CFLAGS) -c $< ? ar rv $@ $*.o ? rm -f $*.o ? $(TARGET): $(OBJECTS) ? ranlib $@ ? (The .c.a rule is default in the make I use, but I am showing it here ? for clarity). ? This works fine, but there is one more thing I'd like to do; If the ? makefile is newer than the library, the library should be deleted and ? rebuilt from scratch. I can do this, by changing the last part of the ? makefile like this: ? $(TARGET): Makefile $(OBJECTS) ? ranlib $@ ? Makefile: FRC ? -@if newer Makefile $(TARGET) ; then rm -f $(TARGET); fi ? FRC: How about a double colon rule? $(TARGET):: Makefile rm -f $@ $(TARGET):: $(OBJECTS) ranlib $@ Note: I have not tested this. I also don't believe in using the construct "foo.a(bar.o)", but I suppose that's a personal aversion. ? Thanks, ? Svante.Lindahl@front.se (!-net: ...!uunet!front.se!svante) ? (non-mx: Svante.Lindahl%front.se@uunet.uu.net) Root Boy Jim is what I am Are you what you are or what?