###############################################################################
#
# lmkfile for 68040.library
#
# 68040.library contains the code needed to setup and maintain 68881 software
# compatibility on a 68040 processor.  It will check for the 68040 processor
# flag and install itself if needed.
#
###############################################################################

#
# Server directory for the data...
#
REMOTE = V:src/workbench/libs/68040
VERSION= 37

#
# Name of the module
#
MODNAME	= 68040

#
# The ".LD" file we want to produce.
#
LD_FILE	= $(MODNAME).ld
LD_STRIP= $(MODNAME).ld.strip

#
# Compiler, assembler, and linker
#
CC = lc
AS = hx68 -a
LN = blink

#
# Compiler flags...
#
CFLAGS	= -b0 -v -rr -ms -cfistqm -d1 -O -.

#
# Assembler flags...  NOTE how they are used below...
#
AFLAGS	= -cqs -i include: -o

#
# Default rules...
#
.c.o:
	$(CC) $(CFLAGS) $*.c

.asm.o:
	$(AS) $*.asm $(AFLAGS) $*.o

#
# Linker flags
#
LFLAGS		= ADDSYM SMALLCODE SMALLDATA MAP $(MODNAME).map HLSXF PLAIN SWIDTH 16
LFLAGS_STRIP	= ND

#
# System libraries
#
LIBS= LIB:small.lib LIB:debug.lib

#
# My headers...
#
MY_HDR	=

#
# My C source...
#
MY_C	=	mmu.c

#
# My Assebly source...
#
MY_A	=	library.asm	\
		bindec.asm	\
		binstr.asm	\
		bugfix.asm	\
		decbin.asm	\
		do_func.asm	\
		gen_except.asm	\
		get_op.asm	\
		kernel_ex.asm	\
		res_func.asm	\
		round.asm	\
		sacos.asm	\
		sasin.asm	\
		satan.asm	\
		satanh.asm	\
		scale.asm	\
		scosh.asm	\
		setox.asm	\
		sgetem.asm	\
		sint.asm	\
		slog2.asm	\
		slogn.asm	\
		smovecr.asm	\
		srem_mod.asm	\
		ssin.asm	\
		ssinh.asm	\
		stan.asm	\
		stanh.asm	\
		sto_res.asm	\
		stwotox.asm	\
		tbldo.asm	\
		util.asm	\
		x_bsun.asm	\
		x_fline.asm	\
		x_operr.asm	\
		x_ovfl.asm	\
		x_snan.asm	\
		x_store.asm	\
		x_unfl.asm	\
		x_unimp.asm	\
		x_unsupp.asm	\
		endcode.asm

#
# My object files...
#
MY_OBJS	=	library.o	\
		bindec.o	\
		binstr.o	\
		bugfix.o	\
		decbin.o	\
		do_func.o	\
		gen_except.o	\
		get_op.o	\
		kernel_ex.o	\
		res_func.o	\
		round.o		\
		sacos.o		\
		sasin.o		\
		satan.o		\
		satanh.o	\
		scale.o		\
		x_bsun.o	\
		x_fline.o	\
		x_operr.o	\
		x_ovfl.o	\
		x_snan.o	\
		x_store.o	\
		x_unfl.o	\
		x_unimp.o	\
		x_unsupp.o	\
		scosh.o		\
		setox.o		\
		sgetem.o	\
		sint.o		\
		slog2.o		\
		slogn.o		\
		smovecr.o	\
		srem_mod.o	\
		ssin.o		\
		ssinh.o		\
		stan.o		\
		stanh.o		\
		sto_res.o	\
		stwotox.o	\
		tbldo.o		\
		util.o		\
		mmu.o

#
# My library objects...
#
MY_LIB_OBJS =

#
# My library files...
#
MY_LIBS	=

#
# Build the stripped LD file...
#
$(LD_STRIP):	$(LD_FILE)
	$(LN) FROM $(LD_FILE) TO $(LD_STRIP) $(LFLAGS_STRIP)

#
# Build the LD file...
#
$(LD_FILE):	$(MY_OBJS) $(MY_LIBS) endcode.o
	$(LN) <with <
FROM $(MY_OBJS) endcode.o
TO $(LD_FILE)
LIB $(MY_LIBS) $(LIBS)
$(LFLAGS)
<

#
# Bump the version...
#
version:
	@bumprev $(VERSION) $(MODNAME)_rev

$(MODNAME)_rev.i:	$(MY_A) $(MY_C)
	@bumprev $(VERSION) $(MODNAME)_rev

$(MODNAME)_rev.h:	$(MY_A) $(MY_C)
	@bumprev $(VERSION) $(MODNAME)_rev

#
# Specific dependancies...
#
library.o:	library.asm $(MODNAME)_rev.i

#
# Release the current build to the server
#
internal:
	@delete $(REMOTE)/((\#?.(c|h|asm|i|rev|doc|sfd|ld|ld.\#?))|makefile|lmkfile)
	@protect ((\#?.(c|h|asm|i|ld|rev|doc|sfd))|makefile|lmkfile) +r quiet
	@copy ((\#?.(c|h|asm|i|rev|doc|sfd|ld|ld.\#?))|makefile|lmkfile) $(REMOTE)
	@copy \#?.doc V:doc NOPRO
	@copy \#?.sfd V:lib/sfd NOPRO

#
# Blow away all files that would need to be rebuilt
#
clean:
	@delete \#?.(o|ld|doc)

#
# Make the AutoDocs
#
doc:	$(MODNAME).doc

$(MODNAME).doc:	$(MY_C) $(MY_A)
	@Echo "Making $(MODNAME).doc"
	@Join $(MY_C) $(MY_A) as RAM:$(MODNAME).tmp.doc
	@AutoDoc >$(MODNAME).doc -a RAM:$(MODNAME).tmp.doc
	@Delete RAM:$(MODNAME).tmp.doc QUIET
	@Protect $(MODNAME).doc rwd

#
# Make a complete new release (This still is in testing...)
#
release:
	lmk clean
	lmk version
	lmk doc
	lmk $(LD_FILE)
	lmk $(LD_STRIP)
	lmk internal

#
# The following rule is to bring the source down to the local directory
# To do the following you should copy this LMKfile to the local directory
# and make sure it is readable.  Then type MAKE ToLocal to have the
# code copied down...
#
tolocal:
	@protect \#? rwed QUIET
	@copy $(REMOTE)/\#? ""
	@protect \#? +r QUIET
	@protect \#?_rev\#? rwd QUIET
	@Echo "Local is updated..."

update:	68040.ld.strip
	Copy 68040.ld.strip 040_Test:68040.library
