#
# makefile.vc - MSVC++ makefile for the PHP/MapScript extension
#
# This VC++ makefile will build the PHP module PHP_MAPSCRIPT.DLL
#
# To use the makefile:
#  - Open a DOS prompt window
#  - Run the VCVARS32.BAT script to initialize the VC++ environment variables
#  - Start the build with:  nmake /f makefile.vc
#
# $Id$
#

# Flag indicating to the option files that this is the build of PHP/MapScript
PHP_BUILD_CALL=TRUE
!INCLUDE ../../nmake.opt
!INCLUDE nmake.opt


PDB_FILE=/Fdphpms.pdb
#DZEND_DEBUG=0 was added for #2717
PHP4_FLAGS=/DZEND_WIN32 /DPHP_WIN32 /DPHP4 /DZTS /PHP_COMPILER_ID=VC9 /DZEND_DEBUG=0


#OPTFLAGS =	/nologo /Zi $(WARNING_LEVEL) $(DEBUG) $(PDB_FILE)
#BASE_CFLAGS = 	$(OPTFLAGS) -DWIN32 -D_WIN32 $(PHP4_FLAGS)
#LDFLAGS =	/NODEFAULTLIB:msvcrt /dll $(LDEBUG)
#LDFLAGS =	/NODEFAULTLIB:libcd /dll $(LDEBUG)

# Set flag for Visual Studio > 2003 & PHP < 5.3
# see http://bugs.php.net/bug.php?id=39130
!IF $(MSVC_VER) >= 1400
!IFDEF WIN64
VCFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
!ELSE
VCFLAGS = -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
!ENDIF
!ENDIF

BASE_CFLAGS = 	$(OPTFLAGS) -DWIN32 -D_WIN32 $(PHP4_FLAGS) $(VCFLAGS)
OPTFLAGS = /nologo /Zi /MD $(WARNING_LEVEL) $(DEBUG) /EHsc
LDFLAGS =       /NODEFAULTLIB:libc /dll /FORCE:MULTIPLE $(LDEBUG)

#
# Set PHP_HOME to point to the root of the PHP source tree
#
PHP_INC = -I$(PHP_HOME) -I$(PHP_HOME)/main -I$(PHP_HOME)/zend -I$(PHP_HOME)/include -I$(PHP_HOME)/tsrm

!IFDEF DLLBUILD
MS_LIBS = ../../mapserver_i.lib $(EXTERNAL_LIBS)
!ELSE
MS_LIBS = $(EXTERNAL_LIBS) ../../mapserver.lib
!ENDIF

#
# The rest of the file should not have to be edited...
#

PHPMS_CLASS_OBJS =  mapscript_error.obj color.obj rect.obj hashtable.obj web.obj grid.obj error.obj referencemap.obj querymap.obj outputformat.obj scalebar.obj label.obj legend.obj symbol.obj style.obj image.obj class.obj projection.obj line.obj shape.obj shapefile.obj point.obj labelcache.obj labelleader.obj labelcachemember.obj result.obj owsrequest.obj cluster.obj layer.obj map.obj

PHPMS_OBJS =  php_mapscript_util.obj $(PHPMS_CLASS_OBJS) php_mapscript.obj mapscript_i.obj

PHPPROJ_OBJS = php_mapscript_util.obj php_proj.obj

PHPMS_DLL =	php_mapscript.dll

PHPPROJ_DLL =	php_proj.dll

CFLAGS = 	$(BASE_CFLAGS) $(MS_CFLAGS) -I../.. $(PHP_INC)

default: 	all

all:		$(PHPMS_DLL)

mapscript:      $(PHPMS_DLL)

proj:	        $(PHPPROJ_DLL)

install:	all
	copy $(PHPMS_DLL) $(PHP_INSTALL_DIR)\$(PHP_INSTALL_DLL_NAME)

$(PHPMS_DLL):	$(PHPMS_OBJS)
	link $(LDFLAGS) /out:$(PHPMS_DLL) $(PHPMS_OBJS) $(MS_LIBS) \
		$(PHP_HOME)\lib\$(PHP_TS_LIB_NAME)
	if exist $(PHPMS_DLL).manifest mt -manifest $(PHPMS_DLL).manifest -outputresource:$(PHPMS_DLL);2

$(PHPPROJ_DLL):	$(PHPPROJ_OBJS)
	link $(LDFLAGS) /out:$(PHPPROJ_DLL) $(PHPPROJ_OBJS) $(MS_LIBS) \
		$(PHP_HOME)\lib\$(PHP_TS_LIB_NAME)

$(PHPMS_OBJS):	php_mapscript_util.h php_mapscript.h

.c.obj:
	$(CC) $(CFLAGS) /DCOMPILE_DL=1 /c $*.c /Fo$*.obj


clean:
	del *.obj
	del $(PHPMS_OBJS)
	del $(PHPPROJ_OBJS)
	del $(PHPMS_DLL)
	del $(PHPPROJ_DLL)
	del *.lib
	del *.pdb
	del *.exp
	del *.ilk
	del *.manifest

