Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!munnari!basser!metro!rossc From: rossc@metro.oz (Ross Cartlidge) Newsgroups: net.unix-wizards Subject: Re: make questions Message-ID: <144@metro.oz> Date: Wed, 19-Feb-86 01:15:18 EST Article-I.D.: metro.144 Posted: Wed Feb 19 01:15:18 1986 Date-Received: Fri, 21-Feb-86 07:03:22 EST References: <14900040@uiucdcsb> Reply-To: rossc@metro.UUCP (Ross Cartlidge) Followup-To: make questions Organization: Uni Computing Centre, Uni of Sydney. Australia. Lines: 30 Keywords: make In article <14900040@uiucdcsb> mcdaniel@uiucdcsb.CS.UIUC.EDU writes: >(2) A friend would like to perform the following task > > for each *.c file younger than gen.a > cc -c -g that file > ar ruv gen.a *.o > ranlib gen.a > rm *.o > >He has a shell script of about 15 lines; I'd like to see if it can be >done in make (BSD 4.2). Is it possible, easy and efficient, or is it >better to use the shell script? (Notes: there are about 500 .c files, >and more may be added later: the makefile should not have to be edited >just for more source files, and make variable storage may overflow. >Only .o files for newly-edited .c files will exist, and then only for a >few moments.) The makefile below will maintain a directory of .c files used to create a archive. I can only see it failing if $(OBJS) is larger than 5120 characters. So as long as average namelength is less than 10 you should be ok. Also the algorithm described above will not compile .c's which are older than gen.a but newer than gen.a(~.c) PS. This was tested on Sys V.2 - whats the 'u' option on ar? LIB=gen.a CFLAGS=-g all: @$(MAKE) OBJS="`ls *.c | sed 's/\(.*\).c/$(LIB)(\1.o)/'`" $(LIB) $(LIB): $(OBJS) ranlib $(LIB)