## This is just the *preliminary* part of the general 'cross-makefile'.
## Here we set macros *specific for ms platforms*
## and all the nmake-specific parts that are incompatible with a
##  standard makefile

## Expected:
##   OS : win
##   ARCH: x32 or x64

TARGET=$(OS)-$(ARCH)

PATH_SEP=;


!if ! defined(BUILDDIR)
# -- WARNING: in Unix notation
BUILDDIR=XBUILD
!endif

PKGDIR=$(BUILDDIR)/tclMuPDF

## set some macros for OS-Dependent commands.
## -- Macros for DOS commands -------------- 
X_COMMENT=:: 
X_RMDIR=U2D rmdir
X_MKDIR=U2D mkdir
X_COPY=U2D copy
X_RM=U2D rm
X_COPYTREE=U2D xcopy

### --- Implicit rules for 
###      any --> .h, .h --> .c, .c --> .obj  

.SUFFIXES : .c .h

#
# Inference Rule: from *.c to *.obj :
#    DIR_OBJ is defined in the generic cross-makefile
#    OH NOOO !!!  nmake's inference rules requires that DIR_OBJ
#      (i..e target and dependents) be defined before loading the rule ! 
#

DIR_CSRC=src
DIR_OBJ=$(BUILDDIR)/$(TARGET)


# Inference Rule: from *.h to *.c :
#   the (implicit) action is 'touch'
{$(DIR_CSRC)}.h{$(DIR_CSRC)}.c:

 
## MS-specific Options for CC :
##   /Ox - (optional) - maximum optimizations  (implies /Oy)
##   -MD   Compiles to create a multithreaded DLL, by using MSVCRT.lib

CFLAGS=-W4 -MD -Ox $(CFLAGS)

# NOTE: the following macros, common for all platforms,
#   CC_TCL_OPTIONS
#   CC_TK_OPTIONS
# will be defined later in cross-makefile

{$(DIR_CSRC)}.c{$(DIR_OBJ)}.obj:
	$(CC) -c $(CC_TCL_OPTIONS) $< -Fo$@ 

{$(DIR_CSRC)}.c{$(DIR_OBJ)}.tkobj:
	$(CC) -c $(CC_TK_OPTIONS) $< -Fo$@    


## Commands and options for linking
##   ?? LIBCMT derives from mupdf's libs ??
LINK=link /DLL /NODEFAULTLIB:LIBCMT
LINK_OUT_OPTION=-out:

MU_LIBS=\
	BuildSupport/mupdf/$(TARGET)/libmupdf.lib \
	BuildSupport/mupdf/$(TARGET)/libthirdparty.lib \
	BuildSupport/mupdf/$(TARGET)/libresources.lib
    
TCL_LIB_OPTIONS=\
	BuildSupport/tcltk/$(TARGET)/tclstub86.lib \
	$(MU_LIBS)

TK_LIB_OPTIONS=\
	BuildSupport/tcltk/$(TARGET)/tclstub86.lib \
	BuildSupport/tcltk/$(TARGET)/tkstub86.lib \
	$(MU_LIBS)


DLL_TCL=tclMuPDF.dll
DLL_TK=tkMuPDF.dll

!INCLUDE cross-makefile
