[comp.sys.sun] Make and heterogeneous architectures

will@genbank.bio.net (Will Nelson) (10/08/90)

I know that someone must have faced this problem before, so I thought I
would draw upon the net's collective wisdom before trying to re-invent the
wheel.

We have a single large source hierarchy that is NFS-mounted on both SUN3
and SPARC systems. This business of make clean followed by total rebuilds
is wearing thin fast. Can someone supply me with a sample Makefile that
supports maintaining .o files of different architectures in separate
subdirectories?

I have looked at the 4.1 "make User's Guide" in the SUN Programming
Utilities and Libraries documentation.  They have something similar in
Figures 5-10 and 5-11, and it's just about what I want, but not quite.

Thanks in advance.

Will Nelson			Internet: will@presto.ig.com
Intelligenetics, Inc.		Uucp:     ames!ig.com!presto!will
700 East El Camino Real		(415) 962-7363
Mountain View, CA  94040

dale@uunet.uu.net (Dale Mensch) (01/10/91)

In article <1990Oct7.224553.29464@rice.edu>, will@genbank.bio.net (Will Nelson) writes:
> We have a single large source hierarchy that is NFS-mounted on both SUN3
> and SPARC systems. This business of make clean followed by total rebuilds
> is wearing thin fast. Can someone supply me with a sample Makefile that
> supports maintaining .o files of different architectures in separate
> subdirectories?

Sorry for the delay time, but here's our hack:
Makefile:

	#	Get architecture type/directory name
	include ../ilib/make$(TARGET_ARCH)type
	# it grabs make-sun3type or make-sun4type

	SRC = xxx.c yyy.c zzz.c aaa.c

	OBJECTS = $(M_PTH)xxx.o $(M_PTH)yyy.o $(M_PTH)zzz.o

	$(OBJECTS): $$(@F:.o=.c)
		$(CC) -c $(@F:.o=.c) -o $@

	# multiple-object program
	$(M_PTH)zzz: $(OBJECTS) $(LOCAL_LIBS)
		$(CC) $(M_PTH)$@.o $(OBJECTS) $(LIBS) -o $@

	# single-object program
	$(M_PTH)aaa: $$(@F).c $(M_PTH)$$(@F).o $(LOCAL_LIBS)
		$(CC) $(M_PTH)$(@F).o $(LIBS) -o $@

	.DEFAULT:
		@make -$(MAKEFLAGS) $(M_PTH)$(@F)

make-sun4type:
	# Kill off all automatic suffix rules: they mess up our ./ vs.
	# ./(ARCH) rules using the ".DEFAULT :" rules
	.SUFFIXES :

	COG		=	-g
	M_PTH	=	SPARC/
	CCFL	=	$(COG) -DSUNOS4

Of course, the horrible kludge here is the ".SUFFIXES" line.  What
happens is that I type 
% make zzz
and all rules fail, there are no suffix rules left, and the DEFAULT
rule takes over, attempting to 
% make SPARC/zzz
or
% make MC68K/zzz
depending on the $(TARGET_ARCH).

The fatality of the horrible kludge shows up if I 
% make www
at which point I wind up in a DEFAULTS rule loop trying to
% make SPARC/www
which keeps looping until (apparently) I run out of memory.

It ain't elegant, but I stopped fixing it as soon as it worked...

Dale Mensch-Xerox Corp/Intran Operation.-Mpls. MN.- uunet!intran!dale