# Makefile : Builds Xlmath
#
# Usage:	NMAKE					(build application)
#	   :	NMAKE DEBUG[0|1]		(build debug version)
#	   :	NMAKE SMART[0|1] 		(build application using SMRTHEAP.DLL
#	   :	NMAKE clean				(erase compiled files)
#
# Note:		The files xlauto.c, xlutil.c xlutil.h are in the subdirectory
#			\xll. All other files are in the subdirectory
#			\xll\xlmath. The modules xlauto and xlutil contain general 
#			useful in building other XLL's and are thus kept separate from
#			the xlmath specific functions.
#

NAME	= xlmath
CFLAGS	= -c -ALw -GD -G2s -Zp -W3
INCLUDE=\C700\INCLUDE;\WINDEV\INCLUDE;\SRC\XLL;\SRC\XLL\XLMATH;
SRC1	= xlminit.c xlmdlg.c $(NAME).c xlmdiag.c xlmcurve.c xlmcfit.c
## directory with xlauto.c xlutil.c & xlutil.h
XLDIR	= ..
SRC2	= $(XLDIR)\xlauto.c $(XLDIR)\xlutil.c
OBJ2	= $(XLDIR)\xlauto.obj $(XLDIR)\xlutil.obj

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

##### Include Macro #####
INCL1	= $(XLDIR)\xlutil.h
INCL2	= $(NAME).h $(INCLU) xlmcurve.h xlmcfit.h

##### Resource Macro #####
RCFILES = $(NAME).rc

##### Library Macros #####
#	the libraries lxlfrmd & lxlfrm are the large model 
#	debug and non-debugging versions of framework (Excel-SDK)
#	
!if "$(DEBUG)"=="1"
LIB1	= libw ldllcew xlcall lxlfrmd
DDEF	= -DDEBUG
CLOPT	= -Zid -Od
MOPT	= -Zi
LOPT	= /CO /LI /MAP
!else
LIB1	= libw ldllcew xlcall lxlfrm
DDEF	=
CLOPT	= -Os
LOPT	=
!endif

##### SMARTHEAP flag defined ####
!if "$(SMART)"=="1"
CSMART 	= /D_USE_SMARTHEAP
LIB2	= smrtheap
!else
CSMART	=	
LIB2	= 
!endif

##### General Macros #####
#
DEF	= -D_XLMATH		#defines xlmath specific in xlutil.c and xlauto.c

##### Tool Macros #####
CC	= cl $(CFLAGS) $(CLOPT) $(CSMART) $(DDEF) $(DEF)
LINK	= link /NOD /NOE $(LOPT)
RC	= rc $(DDEF) $(DEF)
HC	= hc

##### Inference Rules #####
.c.obj:
    $(CC) $*.c

{$(XLDIR)\}.c.obj:
	$(CC) $<

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

##### Main (default) Target #####
all: $(NAME).xll $(SRC2:.c=.obj)

$(XLDIR)\xlauto.obj : xlauto.obj
	copy xlauto.obj $(XLDIR)\*.*

$(XLDIR)\xlutil.obj : xlutil.obj
	copy xlutil.obj $(XLDIR)\*.*
	
##### Dependents For Goal and Command Line #####
$(NAME).xll: $(SRC1:.c=.obj) $(SRC2:.c=.obj) $(NAME).def $(NAME).res 
    $(LINK) @<<
    $(SRC1:.c=.obj) $(SRC2:.c=.obj),
    $(NAME).xll,
    $(NAME).map,
    $(LIB1) $(LIB2),
    $(NAME).def
<<
    $(RC) -p -T $(NAME).res $(NAME).xll

!if "$(DEBUG)"=="1"
!if !$(C7)
    cvpack -p $(NAME).xll
!endif
    mapsym $(NAME).map
!endif

##### Dependents #####
$(SRC1:.c=.obj):  $(INCL1) $(INCL2)
$(SRC2:.c=.obj):  $(INCL2)
$(NAME).res: $(RCFILES) $(INCL1)

##### Clean Directory #####
clean:
	-del errors
    -del *.obj
    -del *.res
    -del *.map
    -del *.sym
    -del *.@*
    -del *.bak
	-del $(XLDIR)\*.obj
