##### Module Macro #####
DEMOPROC	= demoproc

APPNAME    = vlibdemo
APPSRCS    = $(APPNAME).c dialogs.c
APPOBJS    = 

VISUALIB	= visualib

##### C7 Macro #####
C7	   = 1

##### Library Macro #####
APPLIBS    = libw mlibcew commdlg win87em $(VISUALIB) $(DEMOPROC)
APPMOD	   = -AM

DLLLIBS    = libw mdllcew commdlg oldnames win87em
DLLMOD	   = -Alnw

##### Include Macro #####
APPINCLS   = $(APPNAME).h $(VISUALIB).h

##### Resource Macro #####
APPRCFILES = $(APPNAME).rc
DLLRCFILES=

##### DEBUG Defined #####
DEBUG	= 0

##### Build Option Macros #####
MATH	= -FPi
!if $(DEBUG)
DDEF	= -DDEBUG
CLOPT	= -Zid -Od
MOPT	= -Zi
LOPT	= /CO /LI /MAP
!else
DDEF	=
CLOPT	= -Oxatp
LOPT	=
!endif

##### General Macros #####
DEF	= -nologo -c -G2sw -Zp -W3

##### Tool Macros #####
ASM	= masm -Mx $(MOPT) $(DDEF)
CC	= cl $(APPMOD) $(CLOPT) $(DDEF) $(DEF) $(MATH)
CC2	= cl $(DLLMOD) $(CLOPT) $(DDEF) $(DEF) $(MATH)
LINK	= link /NOD /NOE $(LOPT)
IMPLIB  = implib -nologo -noignorecase
RC	= rc $(DDEF)
HC	= hc

##### Main (default) Target #####
goal:	$(DEMOPROC).dll $(DEMOPROC).lib $(APPNAME).exe

##### Application #####
$(APPNAME).obj: $*.c
    $(CC) -NT $* $*.c

dialogs.obj: $*.c
    $(CC) -NT $* $*.c

$(DEMOPROC).obj: $*.c
    $(CC2) -NT $* $*.c

##### Inference Rules #####
.c.obj:
    $(CC2) -NT $* $*.c

.asm.obj:
    $(ASM) $*.asm;

#.rc.res:
#    $(RC) -r $*.rc

##### Dependents For Goal and Command Line #####
$(APPNAME).exe: $(APPSRCS:.c=.obj) $(APPNAME).def $(APPNAME).res $(VISUALIB).lib $(DEMOPROC).lib
    $(LINK) @<<
    $(APPSRCS:.c=),
    $(APPNAME).exe,
    $(APPNAME).map,
    $(APPLIBS),
    $(APPNAME).def
<<
    $(RC) -T -K $(APPNAME).res
!if $(DEBUG)
!if !$(C7)
    cvpack -p $(APPNAME).exe
!endif
    mapsym $(APPNAME).map
!endif

$(DEMOPROC).dll: $(DEMOPROC).obj $(DEMOPROC).def
    $(LINK) @<<
    $(DEMOPROC).obj $(DLLOBJS:.obj=),
    $(DEMOPROC).dll,
    $(DEMOPROC).map,
    $(DLLLIBS) $(VISUALIB),
    $(DEMOPROC).def
<<
    $(RC) -K -T $(DEMOPROC).dll
!if $(DEBUG)
!if !$(C7)
    cvpack -p $(DEMOPROC).dll
!endif
    mapsym $(DEMOPROC).map
!endif

$(DEMOPROC).lib:	$(DEMOPROC).def
    $(IMPLIB) $(DEMOPROC).lib $(DEMOPROC).def

##### Dependents #####
$(APPSRCS:.c=.obj): $(APPINCLS)
$(APPNAME).res: $(APPINCLS) $(APPRCFILES)

##### Clean Directory #####
clean:
	del *.obj
	del demoproc.lib
	del demoproc.dll
	del *.map
	del *.sym
	del *.res
	del err
