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

version = production
#version = debug2
#version = debug1
compiler_type = 386
#compiler_type =

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

model = l

.OPTIMIZE
#.SILENT

makefile          = makefile
prg_dir           = .
obj_dir           = .\obj

final_dir         = .\
sw_dir            = .
lib_dir           = $(sw_dir)
prep_dir          = .\prep

header_dir        = $(prg_dir);$(sw_dir);$(sw_dir)\setup\mact;$(sw_dir)\setup;$(sw_dir)\setup\setup;$(sw_dir)\ten\incl;
tasm_include_dir  = /i$(prg_dir) /i$(sw_dir)

#was input_file	= $[*
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    =

tasm_production     = /t /mx /zi /p /w2
wcc386_production   = /w4 /5r /orneatxu /s /ei
wlink_production    =

#############################################################################
#
# Debugging 1 options
#
#############################################################################

tasm_debug1          = /t /mx /zi /p /w2
#wcc386_debug1       = /zq /wx /d1
#wcc386_debug1        = /w4 /5r /d1 /of+
#wcc386_debug1        = /w4 /5r /d1 /s /or /ei
wcc386_debug1        = /w4 /5r /d1 /or /ei /of+
wlink_debug1         =

#############################################################################
#
# Debugging 2 options
#
#############################################################################

tasm_debug2          = /t /mx /zi /p /w2
#wcc386_debug2       = /zq /wx /d2
#wcc386_debug2        = /w4 /5r /d2 /of+
wcc386_debug2        = /w4 /5r /d2 /ei /of+
wlink_debug2         =


#############################################################################
#
# 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)
cpp                 = wpp$(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)

.cpp.obj : .AUTODEPEND
   $(cpp) $(cc_pre_options) $(input_file) $(cc_post_options)


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

!ifeq compiler_type 386
#lib_files = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib .\mc35a3r.lib .\mc35a3s.lib .\rxa3r.lib .\rxa3s.lib

lib_files_production = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib .\mc35a3r.lib .\mc35a3s.lib .\rxa3r.lib .\rxa3s.lib .\ten\lib\sdkboxr.lib
lib_files_debug2 = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib .\mc35a3r.lib .\mc35a3s.lib .\rxa3r.lib .\rxa3s.lib .\ten\lib\sdkboxr.lib
lib_files_debug1 = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib .\mc35a3r.lib .\mc35a3s.lib .\rxa3r.lib .\rxa3s.lib .\ten\lib\sdkboxr.lib

lib_files = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib .\mc35a3r.lib .\mc35a3s.lib .\rxa3r.lib .\rxa3s.lib .\ten\lib\sdkboxr.lib
#lib_files = $(lib_dir)\setup\mact\mact$(compiler_type).lib $(lib_dir)\audio_wf.lib  
!else
lib_files = $(lib_dir)\mact$(compiler_type).lib
!endif

#        MENUS.obj &
#        WNDO_LIB.obj &
#        TEXT_LIB.obj &
#        MNU_INPT.obj &
#        MENU_LIB.obj &

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

sw_object_files = hooks.obj &
       mdastr.obj &
       cache.obj &
       vis.obj &
       game.obj &
	   ai.obj &
       sounds.obj &
       menus.obj &
       anim.obj &
       readini.obj &
       ten.obj &
       mclip.obj &
       demo.obj &
       sync.obj &
       rotator.obj &
       slidor.obj &
       symutil.obj &
       scrip2.obj &
       JPLAYER.obj &
       CONSOLE.OBJ &
       CD.OBJ &
       SWCONFIG.obj &
       RTS.obj &
       quake.obj &
       pcx.obj &
       midi.obj &
       predict.obj &
       net.obj &
       border.obj &
       inv.obj &
       panel.obj &
       wallmove.obj &
       copysect.obj &
       light.obj &
       text.obj &
       vator.obj &
       spike.obj &
       morph.obj &
       sector.obj &
       interp.obj &
       jsector.obj &
       warp.obj &
       sprite.obj &
       save.obj &
       break.obj &
       weapon.obj &
       rooms.obj &
       player.obj &
       cheats.obj &
       config.obj &
       setup.obj &
	   skull.obj &
	   kbd.obj &
	   draw.obj &
	   skel.obj &
	   serp.obj &
	   goro.obj &
	   ripper.obj &
	   ripper2.obj &
       interpsh.obj &
	   ninja.obj &
	   coolie.obj &
	   coolg.obj &
	   hornet.obj &
	   lava.obj &
       track.obj &
	   timer.obj &
	   colormap.obj &
	   cache1d.obj &
	   mmulti.obj &
	   a.obj &
	   engine.obj &
	   actor.obj &
	   eel.obj &
	   jweapon.obj &
	   sumo.obj &
       miscactr.obj &
       bunny.obj &
	   tensw.obj &
       girlninj.obj &
       zombie.obj &
       zilla.obj
	
$(final_dir)sw.exe : sw.exe
#   move sw.exe $(final_dir)sw.exe

sw.exe : $(sw_object_files) $(lib_files_$(version)) $(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 sort global
   @%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_$(version))) 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


