#------------------------------------------------------------------------
# Makefile : Builds XLQC.XLL
#------------------------------------------------------------------------
#
# 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\xlqc. The modules xlauto and xlutil contain general 
#			useful in building other XLL's and are thus kept separate from
#			the xlqc specific functions.
#
NAME	= XLMATH
CFLAGS	= -ALw -GD -G2s -Zp -W3 /D_$(NAME)
LINKFLAGS	= /NOD
#
#	Object modules to .\OBJ
#	secondary source in \SRC\XLL
#
DIR		= OBJ
XDIR	= \SRC\XLL
INCLUDE	= .\;D:\MSVC\INCLUDE;D:\WINDEV\INCLUDE;D:\CPALETTE\INCLUDE;$(XDIR);

##### Library Macros #####
LIBS		= 
!if "$(DEBUG)"=="1"
CFLAGS		= /DDEBUG $(CFLAGS) -Zid -Od /Fo$*.OBJ
LINKFLAGS	=$(LINKFLAGS)  /CO /LI /MAP
LIBS		= libw ldllcew xlcall lxlfrmd $(LIBS)
!else
CFLAGS		= $(CFLAGS) /Os /Fo$*.OBJ
LINKFLAGS	= $(LINKFLAGS)
LIBS		= libw ldllcew xlcall lxlfrm $(LIBS)
!endif
##### SMARTHEAP flag defined ####
!if "$(SMART)"=="1"
$(CFLAGS)	= $(CFLAGS) /D_USE_SMARTHEAP
LIBS		= $(LIBS) smrtheap
!endif

##### Inference Rules #####
{.}.c{$(DIR)}.obj:							# c files here
    $(CC) /c $(CFLAGS) $<

{$(XDIR)}.c{$(DIR)}.obj:
	$(CC) /c $(CFLAGS) $<

{.}.rc{$(DIR)}.res:
    $(RC) $(RFLAGS) -r /fo $@ $<

$(NAME).xll:	$(DIR)\$(NAME).xll
	copy $** $@

##### Dependents For Goal and Command Line #####
$(DIR)\$(NAME).xll: $(DIR)\$(NAME).obj				\
	$(DIR)\xlminit.obj $(DIR)\xlmdlg.obj $(DIR)\xlmcfit.obj	\
	$(DIR)\xlcurve.obj $(DIR)\xldiag.obj			\
	$(DIR)\xlauto.obj $(DIR)\xlutil.obj 			\
	$(NAME).def $(DIR)\$(NAME).res 
    link $(LINKFLAGS) @<<
$(DIR)\$(NAME) $(DIR)\xlminit $(DIR)\xlmdlg $(DIR)\xlmcfit +
$(DIR)\xlauto $(DIR)\xlutil $(DIR)\xlcurve $(DIR)\xldiag,
    $(DIR)\$(NAME).xll,
    $(NAME).map,
    $(LIBS),
    $(NAME).def
<<
    rc -p -t $(DIR)\$(NAME).res $(DIR)\$(NAME).xll
!if "$(DEBUG)"=="1"
    cvpack -p $(NAME).xll
!endif

$(DIR):
	@IF NOT EXIST $(DIR)\*.* MD $(DIR)

##### Dependents #####
$(DIR)\$(NAME).res:		$(NAME).rc $(NAME).h 
$(DIR)\xlminit.obj:		$(NAME).h $(XDIR)\xlutil.h
$(DIR)\xlmdlg.obj:		$(NAME).h $(XDIR)\xlutil.h
$(DIR)\xlmcfit.obj:		$(NAME).h $(XDIR)\xlutil.h xlmcfit.h
$(DIR)\xlauto.obj:		$(NAME).h $(XDIR)\xlutil.h
$(DIR)\xlutil.obj:		$(NAME).h $(XDIR)\xlutil.h
$(DIR)\xlcurve.obj:		$(NAME).h $(XDIR)\xlutil.h $(XDIR)\xlcurve.h
$(DIR)\xldiag.obj:		$(NAME).h

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