#
#	c68/c386 master makefile
#
#	This is the master makefile for building up the c68/c386 compiler
#	from scratch.
#

all:
	@echo "please specify which version of the compiler you wish"
	@echo "to build by using one of the following:"
	@echo "	make c68"
	@echo "	make c386"
	@echo "N.B.  It is assumed that you have set up the config.h file"
	@echo "	    in the src sub-directory to suit your requirements".

c68:
	cd lib68k; make install
	cd libmffp; make install
	cd libieee; make install
	cd src; make c68

c386:
	cd lib386; make install
	cd src; make c386


#	Build up the files for distribution via email

MISC=	README Makefile cc68
misc.uue:	${MISC}
	@echo "----- Building archive 'misc' -----"
	@tar c misc.tar ${MISC}
	@compress -b13 misc.tar
	@rm misc.tar
	@uue misc.tar.Z
	@rm misc.tar.Z

DOCS=	docs/BUGS docs/TODO docs/c68.man docs/compiler.doc docs/install.doc
docs.uue:	${DOCS}
	@echo "----- Building archive 'docs' -----"
	@tar c docs.tar ${DOCS}
	@compress -b13 docs.tar
	@rm docs.tar
	@uue docs.tar.Z
	@rm docs.tar.Z

HDR =	src/c.h src/cglbdec.h src/config.h src/expr.h src/gen.h \
	src/proto.h src/version.h
SRC =	Makefile src/copy-if-change \
	src/analyze.c src/cglbdef.c src/cmain.c src/decl.c src/expr.c \
	src/func.c src/genicode.c src/genstmt.c src/getsym.c src/init.c \
	src/intexpr.c src/list.c src/memmgt.c src/msgout.c src/optimize.c \
	src/outgen.c src/searchkw.c src/stmt.c src/symbol.c
SRC68K=	src/config.c68 src/gen68k.c src/genffp.c src/genieee.c \
	src/out68k_ack.c src/out68k_cpm.c src/out68k_gas.c \
	src/peep68k.c src/reg68k.c
SRC386=	src/config.c386 src/gen386.c src/out386_bas.c src/out386_gas.c \
	src/peep386.c src/reg386.c
src.uue : src.uaa
src.uaa :	${HDR} ${SRC} ${SRC68K} ${SRC386}
	@echo "----- Building archive 'src' -----"
	@tar c src.tar ${HDR} ${SRC} ${SRC68K} ${SRC386}
	@compress -b13 src.tar
	@rm src.tar
	@uue -800 src.tar.Z
	@rm src.tar.Z

LIB386=	lib386/Makefile lib386/alloca.s lib386/support.s
lib386.uue : ${LIB386}
	@echo "----- Building archive 'lib386' -----"
	@tar c lib386.tar ${LIB386}
	@compress -b13 lib386.tar
	@rm lib386.tar
	@uue lib386.tar.Z
	@rm lib386.tar.Z

LIB68K=	lib68k/Makefile lib68k/alloca_16.s lib68k/alloca_32.s \
	lib68k/divs.s lib68k/divu.s lib68k/muls.s lib68k/mulu.s
lib68k.uue : ${LIB68K}
	@echo "----- Building archive 'lib68k' -----"
	@tar c lib68k.tar ${LIB68K}
	@compress -b13 lib68k.tar
	@rm lib68k.tar
	@uue lib68k.tar.Z
	@rm lib68k.tar.Z

LIBMFFP=libmffp/Makefile libmffp/fpadd.s libmffp/fpcmp.s libmffp/fpconv.s \
	libmffp/fpdiv.s libmffp/fpmult.s libmffp/frexp.c libmffp/ldexp.c  \
	libmffp/modf.c
libmffp.uue : ${LIBMFF{}
	@echo "----- Building archive 'libmffp' -----"
	@tar c libmffp.tar ${LIBMFFP}
	@compress -b13 libmffp.tar
	@rm libmffp.tar
	@uue libmffp.tar.Z
	@rm libmffp.tar.Z

LIBIEEE=libieee/Makefile libieee/README libieee/_asf4.s libieee/_asf8.s \
	libieee/_cff4.s libieee/_cff8.s libieee/_cfi.s libieee/_cfu.s \
	libieee/_cif4.s libieee/_cif8.s libieee/_cmf4.s libieee/_cmf8.s \
	libieee/_cuf4.s libieee/_cuf8.s libieee/_dvf4.s libieee/_dvf8.s \
	libieee/_ffp.s libieee/_mlf4.s libieee/_mlf8.s libieee/_ngf8.s \
	libieee/_norm4.s libieee/_norm8.s libieee/frexp.s libieee/ldexp.s \
	libieee/modf.s libieee/testprog.c
libieee.uue : ${LIBIEEE}
	@echo "----- Building archive 'libieee' -----"
	@tar c libieee.tar ${LIBIEEE}
	@compress -b13 libieee.tar
	@rm libieee.tar
	@uue libieee.tar.Z
	@rm libieee.tar.Z

c68.uue : c68.uaa
c68.uaa :  c68
	@echo "----- Building archive 'c68' -----"
	@compress -b13 c68
	@uue -800 c68.Z
	@rm c68.Z

uue:	misc.uue docs.uue c68.uue lib386.uue lib68k.uue \
	libmffp.uue libieee.uue src.uue

clean :
	rm -f *.u??

