
#
# SWIG Stuff
#
#SWIG_HOME="D:\swig\SWIG-1.3.23\"  <- should get this from ..\..\nmake.opt
#SWIG=$(SWIG_HOME)\swig

!INCLUDE ..\..\nmake.opt

MS_LIB = 	mapscript.lib
MS_LIB_DLL  =	mapscript_i.lib

#
# Java Stuff
#JAVA_HOME = "C:\Progra~1\Java\jdk1.5.0" <- should get this from ..\..\nmake.opt
JAVADOC=$(JAVA_HOME)\bin\javadoc
JAVAC=$(JAVA_HOME)\bin\javac
JAVA=$(JAVA_HOME)\bin\java
JAR=$(JAVA_HOME)\bin\jar
JAVA_INCLUDE=-I$(JAVA_HOME)\include -I$(JAVA_HOME)\include\win32

CC=     cl /MD
LINK=   link

MS_DLL = javamapscript.dll

BASE_CFLAGS = 	$(OPTFLAGS) -DWIN32 -D_WIN32
LDFLAGS =	/NODEFAULTLIB:"MSVCRTD" /NODEFAULTLIB:libcd /NODEFAULTLIB:libcmtd /NODEFAULTLIB:msvcrtd /NODEFAULTLIB:LIBC /DEBUG


all: interface_release mapscript_java mapscript_lib mapscript_jar

interface_release: 
        -md edu\umn\gis\mapscript
        $(SWIG) -java -package edu.umn.gis.mapscript -outdir edu/umn/gis/mapscript -o mapscript_wrap.c ../mapscript.i


mapscript_java:
	$(JAVAC) edu\umn\gis\mapscript\*.java

mapscript_wrap:
        $(CC) $(BASE_CFLAGS) $(MS_CFLAGS) $(JAVA_INCLUDE) /c mapscript_wrap.c  /Fomapscript_wrap.obj

.c.obj:	
	$(CC) $(BASE_CFLAGS) $(MS_CFLAGS) $(JAVA_INCLUDE) /c $*.c /Fo$*.obj

mapscript_lib: mapscript_wrap.obj
        link /dll /debug \
		mapscript_wrap.obj $(EXTERNAL_LIBS) ..\..\mapserver_i.lib $(LDFLAGS) /def:..\..\mapserver.def \
                /out:$(MS_DLL) /implib:$(MS_LIB_DLL)
	if exist $(MS_DLL).manifest mt -manifest $(MS_DLL).manifest -outputresource:$(MS_DLL);2

mapscript_javadoc:
	$(JAVADOC) -d doc -sourcepath edu/umn/gis/mapscript/*.java
		
mapscript_jar:
	$(JAR) cf mapscript.jar edu
test:
	$(JAVAC) -classpath ./mapscript.jar -d examples\ examples\*.java
	$(JAVA)  -cp ./;examples/;./mapscript.jar -Djava.library.path=. DumpShp ../../tests/point.shp
	$(JAVA)  -cp ./;examples/;./mapscript.jar -Djava.library.path=. ShapeInfo ..\..\tests\point.shp ..\..\tests\point.dbf
	$(JAVA)  -cp ./;examples/;./mapscript.jar -Djava.library.path=. DrawMap ..\..\tests\test.map .\map.png
	$(JAVA)  -cp ./;examples/;./mapscript.jar -Djava.library.path=. RFC24 ..\..\tests\test.map

threadtests:
	$(JAVAC) -cp ./mapscript.jar -d tests/threadtest/ tests/threadtest/*.java
	@echo "-------------------------------------------------------------------------"
	@echo "   You can use your own map! Copy the following command in your shell"
	@echo "        and change the file to the map file (the last argument)"
	@echo "-------------------------------------------------------------------------"
	$(JAVA) -cp tests/threadtest/;./mapscript.jar -Djava.library.path=. MapTest -t 10 -i 5 ../../tests/test.map

clean:
	-del *.obj
	-del *.lib
	-rmdir /s /q edu
	del $(MS_DLL)
	del $(MS_DLL).manifest
	del mapscript_wrap.c
	del mapscript.jar
	del *.ilk
	del *.pdb
	del *.exp
