make and archives - dependency problem

G.TOMASEVICH grt at hocda.UUCP
Tue Apr 17 07:48:17 AEST 1984


This is in part a reply to mail.  Yes, is is more efficient to use archives
rather than directories of files, but somebody should fix 'make'.
On systems I have used (USG UNIX pre PWB/UNIX through USG 4.2, PDP11 & VAX)
apparently 'make' only looks at the age of an archive.  It ought to open
the archive and read the ages of the constituent files, according to which
ones are named in the dependency.  Because it does not, I fake out 'make'
in the following way:

1. Indicate that an object archive depends on the .c files.  Example:

	ar.a:: part1.c
		make obj FILE=part1
	ar.a:: part2.c
		make obj FILE=part2

2. The execution code this invokes is

	obj:	$(FILE).o

	$(FILE).o:	$(FILE).c
		$(CC) $(FILE).c

3. The final dependency for the archive is like

	ar.a:: artmp

	artmp:;	$(ARCH)

   At the top of the makefile, ARCH is defined to call a shell script.

4. The script checks to see whether any .o files have been made; if so
   the archive is updated and then the .o files are deleted.  This is a
   real kludge now; somewhere along the line from the Mashey to the Bourne
   shell and the latter's evolution, the shell script broke several times.

5. Note that when the archive does not exist, as for a port to a new UNIX
   release, it is necessary to get all .o files made before the archive
   be created the first time.  Once made, the archive will be newer than the
   .c files.  If any compilation errors occur, get through them before
   lettting the archive get made.  This is very slow on restarting for my
   graphics program after about 30 of the .o files exist, since 'make'
   goes through all of the 'make obj' steps every time it is restarted.

6. Sample ARCH for my graphics program on VAX and PDP USG UNIX 4.2:

	ARCH = ../fpt.a.sh edcx?.o

  Contents of ../fpt.a.sh:

	if [ "$*" != 'edcx?.o' ]
	then
		echo fpt.a:
		ar rv fpt.a $*
		echo rm -f $*
		rm -f $*
	fi
	exit 0

   In an earlier Bourne shell 'edcx?.o' was passable without metacharacter
   expansion, but no more.

	George Tomasevich, AT&T Bell Laboratories



More information about the Comp.unix mailing list