#****************************************************************************
#
#  Project:     MP3TAG
#  Description:
#
#****************************************************************************

#****************************************************************************
#    Project
#****************************************************************************

PrjName         = mp3tag
OS              = nt
OSName          = 'Far plugin module'
#DEBUG_INFO      = Yes
#OPTIMIZATION    = Yes

#****************************************************************************
#    Modules names definition
#****************************************************************************

DllName         = $(PrjName)                    # Project .exe filename

#****************************************************************************
#    Compilers root directories
#****************************************************************************

WATCOM_Dir      = $(%WATCOM)

#****************************************************************************
#    Default directories structure. Tools location definition.
#****************************************************************************

WC_Cpp          = $(WATCOM_Dir)\BINNT\wpp386
WLink           = $(WATCOM_Dir)\BINNT\wlink
WLib            = $(WATCOM_Dir)\BINNT\wlib
!loaddll wpp386 wppd386

#****************************************************************************
#    Options files
#****************************************************************************

WC_Cfg          = $(DllName).ini               # Watcom compiler
WL_Cfg          = $(DllName).lnk               # Watcom linker

WC_Cpp_Opt      = -zq -bd -bt=$(OS) /er /s /zp1 /wx /zq /zkl /fp5
WC_Cpp_Opt      += /fo=$(OBJ)\ /i=$(WATCOM_Dir)\h;$(WATCOM_Dir)\h\nt;$(INC); /fhq=$(PCH)\$(DllName).pch
#WC_Cpp_Opt      += -dNT -dCONSOLE

!ifeq DEBUG_INFO Yes
WC_Cpp_Opt      += -d3 -hw
!else
!ifeq OPTIMIZATION Yes
WC_Cpp_Opt      += -oa -ob -oe -oh -oi+ -ok -ol+ -on -oo -or -ot -oz
!endif
!endif

#****************************************************************************
#    Watcom library utility options
#****************************************************************************

WLib_Opt        = -c -n -b

#****************************************************************************
#    Object files to include in project
#****************************************************************************

ObjLst          = mp3dlg.obj   &
                  mp3tag.obj   &
                  mp3tagz.obj  &
                  mp3edit.obj  &
                  mp3misc.obj  &
                  mp3desc.obj  &
                  mp3reg.obj   &
                  desc.obj     &
                  mp3tgfn.obj  &
                  cfg.obj      &
                  cvtfname.obj &
                  strtok.obj   &
                  templtok.obj

#****************************************************************************
#    Project target
#****************************************************************************

all : makedirs $(DLL)\$(DllName).dll

$(DLL)\$(DllName).dll : $(WL_Cfg) $(ObjLst)
     @echo **** Building "$^&" project ****
     @$(WLink) @$(WL_Cfg)

#****************************************************************************
#    Options files building
#****************************************************************************

$(WL_Cfg) : $(__MAKEFILES__)
     @echo **** Creating linker configuration file $^. ****
     @%create $^.
     @%append $^. SYSTEM $(OS) dll
     @%append $^. NAME $(DLL)\$(DllName)
!ifeq DEBUG_INFO Yes
     @%append $^. DEBUG Watcom
!endif
     @%append $^. OPTION MAP=$(LNK)\$(PrjName),CACHE,ARTIFICIAL
     @%append $^. OPTION OSNAME=$(OSName)
     @for %ObjName in ($(ObjLst)) do @%append $^. FILE $(OBJ)\%ObjName
     @for %LibName in ($(LibLst)) do @%append $^. OPTLIB $(LIB)\%LibName
     @%append $^. EXPORT OpenPlugin='_OpenPlugin@8'
     @%append $^. EXPORT SetStartupInfo='_SetStartupInfo@4'
     @%append $^. EXPORT GetPluginInfo='_GetPluginInfo@4'
     @%append $^. EXPORT Configure='_Configure@4'

$(WC_Cfg) : $(__MAKEFILES__)
     @echo **** Creating compiler configuration file $^. ****
     @%create $^.
     @%append $^. $(WC_Cpp_Opt)
     @for %MacroName in ($(MACRO_LIST)) do @%append $^. /d%MacroName

$(ObjLst) : $(WC_Cfg) .autodepend

#****************************************************************************
#    Implict rules
#****************************************************************************

.c.obj :
     @echo **** Compiling source $[. file ****
     @$(WC_Cpp) $[@ @$(WC_Cfg)

.cpp.obj :
     @echo **** Compiling source $[. file ****
     @$(WC_Cpp) $[@ @$(WC_Cfg)

#****************************************************************************
#    Path to files with different extentions
#****************************************************************************

makedirs: .symbolic

     @if not exist $EXE @md $EXE
     @if not exist $DLL @md $DLL
     @if not exist $OBJ @md $OBJ
     @if not exist $LIB @md $LIB
     @if not exist $INC @md $INC
     @if not exist $SRC @md $SRC
     @if not exist $DOC @md $DOC
     @if not exist $ASM @md $ASM
     @if not exist $ARC @md $ARC
     @if not exist $ERR @md $ERR
     @if not exist $LNK @md $LNK
     @if not exist $PCH @md $PCH

#=== End ====================================================================
