draughn@iitcs.UUCP (Mark Draughn) (07/11/85)
This is probably a case of stupidity on my part, but here is my problem: I'm trying to use make to maintain an archive of .o files. I want the archive modules to depend directly on the source files, so I don't need to keep the object files around. From the documentation, I thought a dependency declaration like this would work in the makefile: library.a(module.o) : module.c cc -c module.c ar r library.a module.o rm module.o The problem is that the commands are executed every time, even if the module is up to date. The problem also arises if I make the module depend on the .o file. I tried it like this: library.a(module.o) : cc -c module.c ar r library.a module.o rm module.o and it still fails which means that make doesn't even realize it exists. Is this a problem with make or am I just being a luser who isn't abusing make properly? Any help would be appreciated. Mark Draughn
mj@husky.uucp (Mark A. Johnson) (07/16/85)
A recent letter to net.unix from draughn@iitcs.UUCP (Mark Draughn) was asking about a problem with make: how do you make objects INSIDE archives depend on their sources (so the objects don't have to keep lying around)? For a description of the problem, see Mark Draughn's letter (145@iitcs.UUCP). I only posted this so that whoever responded would either post to the net or Cc: a response to the address below... Thanks In Advance. ------------------------------------------------------------------------------- Mark A. Johnson -- Eastman Kodak Company -- Information Products UUCP:...rochester!ritcv!husky!mj W:(716) 726-9952 H:(716) 227-2356 (The Name Says It All) -- ------------------------------------------------------------------------------- Mark A. Johnson -- Eastman Kodak Company -- Information Products UUCP:...rochester!ritcv!husky!mj W:(716) 726-9952 H:(716) 227-2356 (The Name Says It All)
joe@wateng.UUCP (Joe Morrison) (07/18/85)
In article <145@iitcs.UUCP> draughn@iitcs.UUCP (Mark draughn) writes: >I'm trying to use make to maintain an archive of .o files. I want >the archive modules to depend directly on the source files, so I don't >need to keep the object files around. Since adding something to an archive updates the timestamp, you could use a makefile like the one below. This lists in one place the fact that the archive is dependent on all the files. If any files change, the ones that have changed (this is what $? does) are recompiled and stuffed back into the archive. --------------------------------------------------------------------------- FILES = routine1.c \ routine2.c \ routine3.c stuff.a: $(FILES) cc -c -O $? ar rv stuff.a *.o ranlib stuff.a rm *.o --------------------------------------------------------------------------- -- Joe Morrison Systems on Silicon Group @ University of Waterloo -- -- -- -- decvax ! -- -- -- -- allegra ! watmath ! wateng ! joe -- -- -- -- -- ihnp4 !
dave@lsuc.UUCP (David Sherman) (07/19/85)
In article <165@husky.uucp> mj@husky.uucp (Mark A. Johnson) writes: || || A recent letter to net.unix from draughn@iitcs.UUCP || (Mark Draughn) was asking about a problem with make: || how do you make objects INSIDE archives depend on their || sources (so the objects don't have to keep lying around)? Here's a usable makefile, stripped down from one of our system makefiles: CC = cc CFLAGS = -O CFILES = file1.c file2.c OFILES = file1.o file2.o lib.a: $(CFILES) $(CC) $(CFLAGS) $? ar ruv lib.a rm -f $(OFILES) all: $(CFILES) $(CC) $(CFLAGS) $(CFILES) make mklib rm -f $(OFILES) mklib: ar cr lib.a $(OFILES) This lets make compile those .c files which have later dates than the archive ($?), and then uses the "ru" feature of ar to update only those .o files which have later dates than the archive. Presto. Dave Sherman The Law Society of Upper Canada Toronto -- { ihnp4!utzoo pesnta utcs hcr decvax!utcsri } !lsuc!dave
fnf@unisoft.UUCP (07/24/85)
In article <723@lsuc.UUCP> dave@lsuc.UUCP (David Sherman) writes: >> how do you make objects INSIDE archives depend on their >> sources (so the objects don't have to keep lying around)? > >Here's a usable makefile, stripped down from one of our system makefiles: There are a couple of bugs in your example, no "-c" in the $(CC) line and no objects to archive in the ar line. A partial solution to this problem is found in the "AUGMAKE" section of the system V Support Tools Guide. Unfortunately, the example there is missing a couple of critical lines to suppress the built in rule that augmake (augmented make) has for maintaining archives. A correct example (for system V with the new augmented make) follows: .SUFFIXES: .a .c # Suppress built in rule, VERY important. .c.a:; LIB = lib.a $(LIB): $(LIB)(file1.o) $(LIB)(file2.o) $(CC) -c $(CFLAGS) $(?:.o=.c) ar rv $@ $? rm $? Note that the built in rule is EXTREMELY SLOW for large archives since it does each object (compile, replace in archive) one at a time. This one does all the compilations first then replaces all the out of date objects in one ar operation. -Fred =========================================================================== Fred Fish UniSoft Systems Inc, 739 Allston Way, Berkeley, CA 94710 USA {ucbvax,decvax}!unisoft!fnf (415) 644 1230 TWX 11 910 366-2145 ===========================================================================