[comp.unix.misc] Makefile question

ibekhaus@athena.mit.edu (Ira B. Ekhaus) (04/09/91)

hello,
	I currently have my directory mounted to two machines with  different
cpu's, ie DEC and Sun.
What is  the easiest way to set up my makefiles, to use the current CPU to 
decide whether an object file should be updated.  It would be great if 
libraries could be set up for both types of cpu's, and only updated if the
source code was newer, but a separate object file would be susceptible to 
updating whenever a make command on a different CPU type than the object file.
thanks,
ira ekhaus
ibekhaus@athena.mit.edu

evans@decvax.DEC.COM (Marc Evans) (04/09/91)

In article <1991Apr9.050652.10199@athena.mit.edu>, ibekhaus@athena.mit.edu (Ira B. Ekhaus) writes:
|> hello,
|> 	I currently have my directory mounted to two machines with  different
|> cpu's, ie DEC and Sun.
|> What is  the easiest way to set up my makefiles, to use the current CPU to 
|> decide whether an object file should be updated.  It would be great if 
|> libraries could be set up for both types of cpu's, and only updated if the
|> source code was newer, but a separate object file would be susceptible to 
|> updating whenever a make command on a different CPU type than the object file.

I would consider using something like:

	LIB  = libfoo.a

	invoke :
		exec $(MAKE) $(MAKEFLAGS) ARCH=${ARCH-`machine`} $(LIB)
	$(LIB) : $(ARCH)/$(LIB)
	$(ARCH)/$(LIB)(foo1.o) :: foo1.c
	$(ARCH)/$(LIB)(foo2.o) :: foo2.c
	$(ARCH)/$(LIB)(foo3.o) :: foo3.c

By doing this you eliminate the .o files all together, and instead just reference
the contents of each archive. The default rules should *do the right thing*, but
for efficiency you may want to change the .c.o and .c.a rules.

- Marc
-- 
===========================================================================
Marc Evans - WB1GRH - evans@decvax.DEC.COM  | Synergytics     (603)635-8876
      Unix and X Software Consultant        | 21 Hinds Ln, Pelham, NH 03076
===========================================================================