# template makefile for 386 kernel
# dont forget to SET KERNEL=C:\KERNEL\ (for example)
# here we define our target replace it with name of your current project
target = play

# assembler switches
ASWITCH = /m2 /z /i$(KERNEL)SYS /i$(KERNEL)SND /dNoDebug
# m2 - 2 passes
# z - display line with error
# additional defines:
# /dNoDebug - debugger is not appended to kernel code
# /dxTiny   - kernel compiles in extra small mode but loses some functionality
AS = tasm32.exe $(ASWITCH)

#linker switches
LSWITCH = /3 /s /l /m /ye /yx
# 3 - enable 386 processing
# s - detailed segment map
# l - source line addresses
# m - include public names
# ye - enable expanded memory swapping
# yx - enable extended memory swapping
LD = tlink.exe $(LSWITCH)

# kernel interface dependencies
kideps = $(KERNEL)sys\krnl386.inc \
         $(KERNEL)sys\krnl386.def \
         $(KERNEL)sys\common.def

# kernel dependencies
kdeps = $(KERNEL)sys\krnl386.asm \
        $(KERNEL)sys\keyboard.inc \
        $(KERNEL)sys\mem.inc \
        $(KERNEL)sys\res.inc \
        $(KERNEL)sys\file.inc \
        $(KERNEL)sys\packer.inc \
        $(KERNEL)sys\exceptio.inc \
        $(KERNEL)sys\debug.asm \
        $(KERNEL)sys\unasm.inc \
        $(KERNEL)sys\exp.inc \
        $(KERNEL)sys\dllsys.inc

# here add your all targets
all: $(target).exe

# when to link target file ?
$(target).exe: krnl386.obj $(target).obj snd.obj
        $(LD) krnl386.obj $(target).obj snd.obj , $(target).exe

#when to recompile target file ?
$(target).obj: $(target).asm $(kideps)
        $(AS) $(target).asm

# when to recompile kernel ?
krnl386.obj: $(kdeps) $(kideps)
        $(AS) $(KERNEL)sys\krnl386.asm

# vesa linear frame buffer library
#vesa.obj: $(KERNEL)sys\vesa.asm $(KERNEL)sys\vesa.inc
#        $(AS) $(KERNEL)sys\vesa.asm

# /d_MIXCH=10
# /dSND_DOAMP=0
# /d_AMPL=1
# /dSND_FILTER=0
sset =

# sound library interface dependencies
sideps = $(KERNEL)snd\snd.inc

# sound library dependencies
sdeps = $(KERNEL)snd\snd.asm \
        $(KERNEL)snd\common.inc \
        $(KERNEL)snd\config.inc \
        $(KERNEL)snd\sbhw.inc \
        $(KERNEL)snd\sbphw.inc \
        $(KERNEL)snd\sb16hw.inc \
        $(KERNEL)snd\gushw.inc \
        $(KERNEL)snd\sbmod.inc \
        $(KERNEL)snd\sbpmod.inc \
        $(KERNEL)snd\sb16mod.inc \
        $(KERNEL)snd\gusmod.inc

# /d_MIXCH=10
# /dSND_DOAMP=0
# /d_AMPL=1
# /dSND_FILTER=0
sset =

#when to recompile sound library
snd.obj: $(sdeps) $(kideps) $(sideps)
        $(AS) $(sset) $(KERNEL)snd\snd.asm

clean:
        del *.bak
        del *.map

