Problem with Make

David Sherman dave at lsuc.UUCP
Sat Jul 20 03:55:11 AEST 1985


In article <165 at husky.uucp> mj at husky.uucp (Mark A. Johnson) writes:
||
||	A recent letter to net.unix from draughn at 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



More information about the Comp.unix mailing list