# Copyright (c) 1993 Xerox Corporation.  All rights reserved.
#
# PCR top-level makefile
#

include config/config.mk

#
# compilation flags, etc.
#


CPPFLAGS = $(INCLUDE) $(CONFIG←CPPFLAGS) \
	-DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR
CFLAGS	=-c $(CONFIG←CFLAGS)

ASPPFLAGS  = $(INCLUDE) $(CONFIG←ASPPFLAGS) \
	-DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR -DASM

ASFLAGS	= $(CONFIG←ASFLAGS)

LDRFLAGS = $(CONFIG←LDRFLAGS)

LDFLAGS = $(CONFIG←LDFLAGS)

#
# standard commands and default rules
#


INSTALL = cp -p


.s.o:
	$(ASPP) $(ASPPFLAGS) $< > tmp.s ; $(AS) $(ASFLAGS) tmp.s -o $@ ; \
		rm -f tmp.s

.c.o:
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $<  -o $@


COMPONENTS = config \
	base cmd dbg emu exec gc il io mm rpc shm sig th vd

default: pcr

pcr: buildpcr

buildpcr:
	rm -f pcr
	-for x in $(COMPONENTS) ; do \
		( cd $$x ; $(MAKE) ) ; \
	done
	( cd base; $(MAKE) pcr.o PCR←BaseMain.o )
	$(LD) $(LDFLAGS) -o pcr base/pcr.o base/PCR←BaseMain.o \
		$(SOCKLIB) $(MATHLIB) $(DLLIB)

xrpcr: mkxrpcr

mkxrpcr:
	rm -f xrpcr
	-for x in $(COMPONENTS) xr ; do \
		( cd $$x ; $(MAKE) ) ; \
	done
	( cd base; $(MAKE) pcr.o PCR←BaseMain.o )
	$(LD) $(LDFLAGS) -o xrpcr base/pcr.o base/PCR←BaseMain.o xr/xr.o \
		$(SOCKLIB) $(MATHLIB) $(DLLIB)

tstpcr: mktstpcr

mktstpcr:
	rm -f tstpcr
	-for x in $(COMPONENTS) tst ; do \
		( cd $$x ; $(MAKE) ) ; \
	done
	( cd base; $(MAKE) pcr.o PCR←BaseMain.o )
	$(LD) $(LDFLAGS) -o tstpcr base/pcr.o base/PCR←BaseMain.o tst/tst.o \
		$(SOCKLIB) $(MATHLIB) $(DLLIB)

clean:
	rm -f core a.out *.a *.o *.nm *.bak *.BAK *.CKP *~ pcr
	-for x in $(COMPONENTS) tst xr ; do \
		( cd $$x ; $(MAKE) clean ) ; \
	done

depend install:
	-for x in $(COMPONENTS) tst xr ; do \
		( cd $$x ; $(MAKE) $@ ) ; \
	done

$(COMPONENTS):
	( cd $@ ; $(MAKE) )

TAGS:
	y=''; \
	for x in $(COMPONENTS) ;  do \
		y=$$x/'*.[c,h] '$$y ; \
	done ; \
	etags $$y