###########################################################################
#
# Default Makefile for using MACT.LIB
#
#############################################################################

version = production
#version = debug
compiler_type = 386
#compiler_type =

!ifeq compiler_type 386
stacksize = 30k
!else
stacksize = 20k
!endif

model = l

.OPTIMIZE
#.SILENT

makefile          = makefile
prg_dir           = .
obj_dir           = .\obj

mact_dir          = ..\mact
final_dir         = ..\
lib_dir           = $(mact_dir)

header_dir        = $(prg_dir);$(mact_dir);$(final_dir)
tasm_include_dir  = /i$(prg_dir) /i$(mact_dir)

input_file        = $[*
output_dir        = $(obj_dir)\$^&

.h   :              $(header_dir)
.c   :              $(header_dir)
.asm :              $(header_dir)
.obj :              $(obj_dir)
.lib :              $(lib_dir)


#############################################################################
#
# Production options
#
#############################################################################

tasm_production     = /t /mx /zi /p /w2
wcc386_production   = /zq /wx /d1 /oneatx /zp4 /5r /fpi87 /fp3
wcc_production      = /m$(model) /5 /zq /wx /d1 /oneatx /zp4 /fpi87 /fp3
wlink_production    =


#############################################################################
#
# Debugging options
#
#############################################################################

tasm_debug          = /t /mx /zi /p /w2
wcc386_debug        = /zq /wx /d2
wcc_debug           = /m$(model) /zq /wx /d2
wlink_debug         =


#############################################################################
#
# Compiler setup
#
#############################################################################

asm_pre_options     = $(tasm_$(version)) /i$(tasm_include_dir)
asm_post_options    = $(output_dir)

cc_pre_options      = $(wcc$(compiler_type)_$(version)) /i=$(header_dir)
cc_post_options     = /fo=$(output_dir)

link_options        = $(wlink_$(version))

asm                 = tasm
cc                  = wcc$(compiler_type)
link                = wlink
lib                 = wlib

.asm.obj :
   $(asm) $(asm_pre_options) $(input_file) $(asm_post_options)

.c.obj : .AUTODEPEND
   $(cc) $(cc_pre_options) $(input_file) $(cc_post_options)



#############################################################################
#
# Library files
#
#############################################################################

!ifeq compiler_type 386
lib_files = $(lib_dir)\mact$(compiler_type).lib audio_wf.lib
!else
lib_files = $(lib_dir)\mact$(compiler_type).lib
!endif


#############################################################################
#
# Make setup
#
#############################################################################

test_object_files = test.obj config.obj sounds.obj

$(final_dir)test.exe : test.exe
   move test.exe $(final_dir)test.exe

test.exe : $(test_object_files) $(lib_files) $(makefile)
   @set exe_name=$^&
   @%make exelink

#############################################################################
#
# Object file dependencies
#
#############################################################################


#############################################################################
#
# Link the EXE
#
#############################################################################

exelink : .SYMBOLIC
   @%create temp.lnk
   @%append temp.lnk option verbose
   @%append temp.lnk option quiet
   @%append temp.lnk option map
   @%append temp.lnk option stack=$(stacksize)
   @%append temp.lnk option CASEEXACT
   @%append temp.lnk name $(%exe_name)
   @%append temp.lnk debug all
   @for %i in ($(lib_files)) do @%append temp.lnk library %i
   @for %i in ($($(%exe_name)_object_files)) do @%append temp.lnk file $(obj_dir)\%i
   $(link) $(link_options) @temp.lnk
   @del temp.lnk


