#
# :ts=8
#
# A trackdisk.device which uses ADF disk image files and its
# sidekick, the trusty DAControl shell command.
#
# Copyright (C) 2020 by Olaf Barthel <obarthel at gmx dot net>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#

.asm.o:
	asm $(AFLAGS) $<

.c.o:
	sc $(CFLAGS) $<

###############################################################################

OPTIMIZE =	optimize opttime
CPU =		any
DEBUG =		line
#DEBUG =	symbolflush noopt

###############################################################################

CFLAGS =	resopt idlen=64 comnest streq strmerge nostkchk \
		$(OPTIMIZE) cpu=$(CPU) debug=$(DEBUG) \
		params=register strsect=code mccons smallcode data=faronly
AFLAGS =	-d
LFLAGS =	addsym smallcode noicons batch

###############################################################################

OBJS = start.o cmd_main.o global_data.o insert_media_by_name.o \
	mount_floppy_file.o process_icons.o start_unit.o tools.o swap_stack.o
LIBS = lib:scnb.lib lib:amiga.lib lib:debug.lib

###############################################################################

DAControl: assert.lib $(OBJS)
	slink $(OBJS) to $@.debug lib $(LIBS) assert.lib $(LFLAGS) \
		map $@.map,fhx fwidth 32 pwidth 32 swidth 32
	slink $@.debug to $@ noicons nodebug

###############################################################################

assert.lib : assert.o
	oml assert.lib r assert.o

###############################################################################

assert.o : assert.c compiler.h
cmd_main.o : cmd_main.c compiler.h macros.h global_data.h \
	insert_media_by_name.h mount_floppy_file.h start_unit.h tools.h \
	cache.h cmd_main.h assert.h DAControl_rev.h
DAChecksum.o : DAChecksum.c
global_data.o : global_data.c macros.h global_data.h
insert_media_by_name.o : insert_media_by_name.c macros.h global_data.h \
	mount_floppy_file.h insert_media_by_name.h start_unit.h cache.h \
	tools.h assert.h
mount_floppy_file.o : mount_floppy_file.c macros.h global_data.h \
	mount_floppy_file.h assert.h
process_icons.o : process_icons.c macros.h global_data.h start_unit.h \
	insert_media_by_name.h compiler.h process_icons.h cache.h tools.h \
	assert.h
start.o : start.c compiler.h macros.h global_data.h process_icons.h \
	cmd_main.h swap_stack.h assert.h
start_unit.o : start_unit.c macros.h global_data.h mount_floppy_file.h \
	start_unit.h cache.h tools.h assert.h
tools.o : tools.c compiler.h macros.h global_data.h tools.h assert.h
swap_stack.o : swap_stack.asm

###############################################################################

clean:
	-delete \#?.(o|lib) \#?/\#?.(o|lib) DAControl(%|.debug)

realclean: clean
	-delete tags tagfiles \#?.map all
