# @(#)Makefile	1.1	86/02/03	SMI
#
# HISTORY:
# 15-Jul-87  Michael Jones (mbj) at Carnegie-Mellon University
#	Changed rules for mcrt0.o, gcrt0.o to compile crt0.s with -DMCRT0 
#	and -DGCRT0 respectively.  Changed "rm" uses to "$(RM)".
#
#  12-Feb-87  Mary Thompson
#	Changed DESTDIR to DSTDIR
#
#	crt0	Normal C run time startoff
#	mcrt0	C run time start off for profiling, ``prof'' conventions
#	gcrt0	C run time start off for profiling, ``gprof'' conventions
#	f?crt0	C run time start off with sky board initialization.
#
DSTDIR= /usr/mach
DIR=${DSTDIR}/lib
LD= ld
CPP= /lib/cpp
SRCS=   crt0.s  mon.c mcount.s gmon.c gmcount.s gmon.h
OBJS=	crt0.o mcrt0.o gcrt0.o mon.o gmon.o
CFLAGS= -O -m68010 -fsoft
ASFLAGS= -10
I=-c -d -m 644


all: ${OBJS}

install: ${OBJS}
	-@mach_install $I crt0.o ${DIR}/crt0.o
	-@mach_install $I mcrt0.o ${DIR}/mcrt0.o
	-@mach_install $I gcrt0.o ${DIR}/gcrt0.o


crt0.o:	crt0.s
	$(CPP) crt0.s >tmp.s
	$(AS) $(ASFLAGS) -o crt0.o tmp.s
	$(LD) -x -r crt0.o
	mv a.out crt0.o

mcrt0.o: crt0.s mon.o
	$(CPP) -DMCRT0 crt0.s >tmp.s
	$(AS) $(ASFLAGS) -o mcrt0.o tmp.s
	$(LD) -x -r mcrt0.o mon.o
	mv a.out mcrt0.o

gcrt0.o: crt0.s gmon.o
	$(CPP) -DGCRT0 crt0.s >tmp.s
	$(AS) $(ASFLAGS) -o gcrt0.o tmp.s
	$(LD) -x -r gcrt0.o gmon.o
	mv a.out gcrt0.o

.s.o:
	$(CPP) $*.s >tmp.s
	$(AS) $(ASFLAGS) -o $*.o tmp.s
	$(LD) -x -r $*.o
	mv a.out $*.o
	
gmon.o: gmon.c gmcount.s
	$(CC) -S $(CFLAGS) gmon.c && cat gmcount.s >>gmon.s
	$(AS) $(ASFLAGS) -o gmon.o gmon.s  && rm -f gmon.s
	$(LD) -x -r gmon.o && mv a.out gmon.o
	
mon.o: mon.c mcount.s
	$(CC) -S $(CFLAGS) mon.c && cat mcount.s >> mon.s
	$(AS) $(ASFLAGS) -o mon.o mon.s  && rm -f mon.s
	$(LD) -x -r mon.o && mv a.out mon.o
	

