#
# $Header: Makefile,v 1.2 86/03/11 08:31:03 root Exp $
#
# $Log:	Makefile,v $
# Revision 1.2  86/03/11  08:31:03  root
# changed SHELL from csh to sh so make clean worked.
# 
# Revision 1.1  86/03/11  08:28:41  root
# Initial revision
# 
#
#	Makefile	4.6	83/07/02
#
# The system has two monitoring schemes, utilizing either ``prof''
# or ``gprof''. DFLMON determines the default profiler; mon.o
# specifies that ``prof'' is the default, gmon.o specifies that
# ``gprof'' is the default.
#
# Machine dependent routines are located in a subtree which parallels
# the top directories.  This subtree is identified by the machine name.
#
# Compatibility routines are kept in directories with a prefixing
# ``compat'' (so they all sort together).
# 
# The C run-time startup code is both machine and floating-point format
# dependent.  It is located is is68k{ieee,sky,dec}/csu
#
SHELL=	/bin/sh
DESTDIR=
INSTALL=install -m 644
DFLMON=	mon.o
MACHINE=is68k
COMPAT=	compat-4.1 compat-sys5
ALL=	gen inet net stdio ${MACHINE} ${COMPAT} is68kieee is68ksky is68kdec
IEEEALL=	gen inet net stdio ${MACHINE} ${COMPAT} is68kieee
SKYALL=		gen inet net stdio ${MACHINE} ${COMPAT} is68ksky
DECALL=		gen inet net stdio ${MACHINE} ${COMPAT} is68kdec
DECALL=		gen inet net stdio ${MACHINE} ${COMPAT} is68kdec

all:	libc.a libskyc.a libdecc.a

libc.a libc_p.a: ${IEEEALL} is68kieee/csu
	rm -rf tmp t1 t2
	-mkdir tmp
	for i in ${IEEEALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libc.a `cat t1` is68kieee/csu/${DFLMON}
	ar ma flsbuf.o libc.a exit.o
	ar ma exit.o libc.a fake_cleanup.o
	ar ma doprnt.o libc.a fprintf.o
	ar ma fprintf.o libc.a printf.o
	ar ma printf.o libc.a sprintf.o
	ar ma sprintf.o libc.a doprnt_nf.o
	ar ma doprnt_nf.o libc.a fltused.o
	rm -f t1 t2 tmp/*
	for i in ${IEEEALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libc_p.a `cat t1` is68kieee/csu/${DFLMON}
	ar ma flsbuf.o libc_p.a exit.o
	ar ma exit.o libc_p.a fake_cleanup.o
	ar ma doprnt.o libc_p.a fprintf.o
	ar ma fprintf.o libc_p.a printf.o
	ar ma printf.o libc_p.a sprintf.o
	ar ma sprintf.o libc_p.a doprnt_nf.o
	ar ma doprnt_nf.o libc_p.a fltused.o
	rm -rf t1 t2 tmp

libskyc.a libskyc_p.a: ${SKYALL} is68ksky/csu
	rm -rf tmp t1 t2
	-mkdir tmp
	for i in ${SKYALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libskyc.a `cat t1` is68ksky/csu/${DFLMON}
	ar ma flsbuf.o libskyc.a exit.o
	ar ma exit.o libskyc.a fake_cleanup.o
	ar ma doprnt.o libskyc.a fprintf.o
	ar ma fprintf.o libskyc.a printf.o
	ar ma printf.o libskyc.a sprintf.o
	ar ma sprintf.o libskyc.a doprnt_nf.o
	ar ma doprnt_nf.o libskyc.a fltused.o
	rm -f t1 t2 tmp/*
	for i in ${SKYALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libskyc_p.a `cat t1` is68ksky/csu/${DFLMON}
	ar ma flsbuf.o libskyc_p.a exit.o
	ar ma exit.o libskyc_p.a fake_cleanup.o
	ar ma doprnt.o libskyc_p.a fprintf.o
	ar ma fprintf.o libskyc_p.a printf.o
	ar ma printf.o libskyc_p.a sprintf.o
	ar ma sprintf.o libskyc_p.a doprnt_nf.o
	ar ma doprnt_nf.o libskyc_p.a fltused.o
	rm -rf t1 t2 tmp

libdecc.a libdecc_p.a: ${DECALL} is68kdec/csu
	rm -rf tmp t1 t2
	-mkdir tmp
	for i in ${DECALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libdecc.a `cat t1` is68kdec/csu/${DFLMON}
	ar ma flsbuf.o libdecc.a exit.o
	ar ma exit.o libdecc.a fake_cleanup.o
	ar ma doprnt.o libdecc.a fprintf.o
	ar ma fprintf.o libdecc.a printf.o
	ar ma printf.o libdecc.a sprintf.o
	ar ma sprintf.o libdecc.a doprnt_nf.o
	ar ma doprnt_nf.o libdecc.a fltused.o
	rm -f t1 t2 tmp/*
	for i in ${DECALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
	ls tmp/*.o | sort -t/ +1 > t1
	(lorder `cat t1`) > t2
	tsort t2 > t1
	ar cr libdecc_p.a `cat t1` is68kdec/csu/${DFLMON}
	ar ma flsbuf.o libdecc_p.a exit.o
	ar ma exit.o libdecc_p.a fake_cleanup.o
	ar ma doprnt.o libdecc_p.a fprintf.o
	ar ma fprintf.o libdecc_p.a printf.o
	ar ma printf.o libdecc_p.a sprintf.o
	ar ma sprintf.o libdecc_p.a doprnt_nf.o
	ar ma doprnt_nf.o libdecc_p.a fltused.o
	rm -rf t1 t2 tmp

${ALL}: FRC
	cd $@; make ${MFLAGS}

is68kieee/csu: FRC
	cd $@; make ${MFLAGS}

is68ksky/csu: FRC
	cd $@; make ${MFLAGS}

is68kdec/csu: FRC
	cd $@; make ${MFLAGS}

FRC:

clean:
	for i in is68kieee/csu is68ksky/csu is68kdec/csu ${ALL}; \
		 do (cd $$i; make ${MFLAGS} clean); done
	rm -f libc.a libc_p.a libskyc.a libskyc_p.a libdecc.a libdecc_p.a
	rm -f t1 t2 tmp/*.o
	-rmdir tmp

install: 
	${INSTALL} libc.a ${DESTDIR}/lib/libc.a
	ranlib ${DESTDIR}/lib/libc.a
	${INSTALL} libc_p.a ${DESTDIR}/usr/lib/libc_p.a
	ranlib ${DESTDIR}/usr/lib/libc_p.a
	${INSTALL} libskyc.a ${DESTDIR}/usr/lib/libskyc.a
	ranlib ${DESTDIR}/usr/lib/libskyc.a
	${INSTALL} libskyc_p.a ${DESTDIR}/usr/lib/libskyc_p.a
	ranlib ${DESTDIR}/usr/lib/libskyc_p.a
	${INSTALL} libdecc.a ${DESTDIR}/usr/lib/libdecc.a
	ranlib ${DESTDIR}/usr/lib/libdecc.a
	${INSTALL} libdecc_p.a ${DESTDIR}/usr/lib/libdecc_p.a
	ranlib ${DESTDIR}/usr/lib/libdecc_p.a
	cd is68kieee/csu; make DESTDIR=${DESTDIR} install
	cd is68ksky/csu; make DESTDIR=${DESTDIR} install
	cd is68kdec/csu; make DESTDIR=${DESTDIR} install
