#
# lmkfile for layers.library
#

#
# Server directory for the data...
#
REMOTE = V:src/kickstart/layers
VERSION= 40

#
# Name of the module
#
MODNAME	= layers

#
# 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 -mes -cfistqm -d1 -O -q -j*e -.

#
# Assembler flags...  NOTE how they are used below...
#
AFLAGS	= -csq -i include: -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	=	layersbase.h macros.h layersbase.i

#
# My C source...
#
MY_C	=	addobs.c \
behind.c \
cleanup.c \
copylayer.c \
copyrect.c \
deletelayer.c \
hook.c \
layers.c \
localclipblit.c \
lock.c \
moreregions.c \
movesizelayer.c \
newlayer.c \
screenswap.c \
scrolllayer.c \
tomiddle.c \
update.c \
upfront.c \
usercliprects.c

#
# My Assebly source...
#
MY_A	=	layerface.asm \
abort.asm \
backfill.asm \
layerop.asm \
layersallocmem.asm \
locklayer.asm \
rsplit.asm \
dedicer.asm \
crtools.asm \
whichlayer.asm

#
# My object files...
#
MY_OBJS	=	layerface.o \
abort.o \
backfill.o \
layerop.o \
locklayer.o \
crtools.o \
dedicer.o \
whichlayer.o \
addobs.o \
behind.o \
cleanup.o \
copylayer.o \
copyrect.o \
deletelayer.o \
hook.o \
layers.o \
layersallocmem.o \
localclipblit.o \
lock.o \
moreregions.o \
movesizelayer.o \
newlayer.o \
rsplit.o \
screenswap.o \
scrolllayer.o \
tomiddle.o \
update.o \
upfront.o \
usercliprects.o

#
# My library objects...
#
MY_LIB_OBJS = endcode.o

#
# My library files...
#
MY_LIBS	= endcode.lib

#
# 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)
	$(LN) <with <
FROM $(MY_OBJS)
TO $(LD_FILE)
LIB $(MY_LIBS) $(LIBS)
$(LFLAGS)
<

#
# build my libraries
#
$(MY_LIBS):	$(MY_LIB_OBJS)
	oml $(MY_LIBS) r $(MY_LIB_OBJS)


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

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

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

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

#
# Release the current build to the server
#
internal:
	@delete $(REMOTE)/((\#?.(c|h|asm|i|ld|ld.strip|rev|doc|sfd))|makefile|lmkfile)
	@protect ((\#?.(c|h|asm|i|ld|ld.strip|rev|doc|sfd))|makefile|lmkfile) +r quiet
	@copy ((\#?.(c|h|asm|i|ld|ld.strip|rev|doc|sfd))|makefile|lmkfile) $(REMOTE)
	@delete V:include/graphics/(layers|clip).(h|i)
	@copy (layers|clip).(h|i) V:include/graphics
	@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|ld.strip|map)

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

$(MODNAME).doc:	$(MY_C) $(MY_A)
	@Echo "Making $(MODNAME).doc"
	@Join $(MY_C) $(MY_A) as T:$(MODNAME).tmp.doc
	@AutoDoc >$(MODNAME).doc T:$(MODNAME).tmp.doc
	@Delete T:$(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..."
