# $Id: makefile.vc,v 1.5 2006/12/06 15:38:16 mloskot Exp $
#
# Makefile to build GDAL C++ Unit Tests (subset of Python tests)
#
# These tests are dedicated to Windows CE platform and cover features
# supported by Windows CE port of GDAL.
# Also, compatible and runnable on Windows 2000/XP.
#
#############################################################################
# CONFIGURATION

# GDAL library

!IFNDEF GDAL_ROOT
!IF EXIST("..\..\gdal\nmake.opt")
GDAL_ROOT = ..\..\gdal
!ENDIF
!ENDIF

!INCLUDE $(GDAL_ROOT)\nmake.opt

# Specification of enabled GDAL drivers
#GDAL_SUPPORT = \
#    -DHAVE_GEOS \
#    -DOGR_ENABLED \
#    -DSHAPE_ENABLED \
#    -DFRMT_aaigrid \
#    -DFRMT_dted \
#    -DFRMT_gtiff
GDAL_SUPPORT = \
    -DOGR_ENABLED \
    -DSHAPE_ENABLED \
    -DFRMT_aaigrid \
    -DFRMT_dted \
    -DFRMT_gtiff

# END OF CONFIGURATION
#############################################################################

GDAL_LIB = $(GDAL_ROOT)\gdal_i.lib

INCLUDE_DIR = \
    -I. \
    -Itut \
    -I$(PROJ4_ROOT)\src

OBJ = \
    test_cpl.obj \
    test_alg.obj \
    test_gdal.obj \
    test_gdal_aaigrid.obj \
    test_gdal_dted.obj \
    test_gdal_gtiff.obj \
    test_triangulation.obj \
    test_ogr.obj \
    test_ogr_geos.obj \
    test_ogr_shape.obj \
    test_osr.obj \
    test_osr_ct.obj \
    test_osr_pci.obj \
    test_osr_proj4.obj \
    tut/tut_gdal.obj

# Commands
RM = -del

# Complete set of compilation flags
CFLAGS	= $(CFLAGS) $(INCLUDE_DIR)
CPPFLAGS = $(CFLAGS)

GDAL_TEST_EXE = gdal_unit_test.exe

default: $(GDAL_TEST_EXE) testcopywords.exe testperfcopywords.exe testclosedondestroydm.exe testthreadcond.exe testblockcache.exe testblockcachewrite.exe testblockcachelimits.exe testdestroy.exe

check:	 $(GDAL_TEST_EXE) testblockcache.exe testblockcachewrite.exe testblockcachelimits.exe
	 $(GDAL_TEST_EXE)
	testblockcache.exe -check -co TILED=YES --debug TEST,LOCK -loops 3 --config GDAL_RB_LOCK_DEBUG_CONTENTION YES
	testblockcache.exe -check -co TILED=YES --debug TEST,LOCK -loops 3 --config GDAL_RB_LOCK_DEBUG_CONTENTION YES --config GDAL_RB_LOCK_TYPE SPIN
	testblockcache.exe -check -co TILED=YES -migrate
	testblockcache.exe -check -memdriver
	testblockcachewrite.exe --debug ON
	testblockcachelimits.exe --debug ON
	testdestroy.exe

check-all:	 check testcopywords.exe testperfcopywords.exe testclosedondestroydm.exe testthreadcond.exe
	testcopywords.exe
	testperfcopywords.exe
	testclosedondestroydm.exe
	testthreadcond.exe

$(GDAL_TEST_EXE): gdal_unit_test.cpp $(GDAL_DLL) $(OBJ)
	$(CC) gdal_unit_test.cpp $(CFLAGS) $(OBJ) $(GDAL_LIB) $(GEOS_LIB) $(PROJ4_LIB)
    if exist $(GDAL_TEST_EXE).manifest mt -manifest $(GDAL_TEST_EXE).manifest -outputresource:$(GDAL_TEST_EXE);1

testcopywords.exe: testcopywords.cpp
	$(CC) testcopywords.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testcopywords.exe.manifest mt -manifest testcopywords.exe.manifest -outputresource:testcopywords.exe;1

testperfcopywords.exe: testperfcopywords.cpp
	$(CC) testperfcopywords.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testperfcopywords.exe.manifest mt -manifest testperfcopywords.exe.manifest -outputresource:testperfcopywords.exe;1

testclosedondestroydm.exe: testclosedondestroydm.cpp
	$(CC) testclosedondestroydm.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testclosedondestroydm.exe.manifest mt -manifest testclosedondestroydm.exe.manifest -outputresource:testclosedondestroydm.exe;1

testthreadcond.exe: testthreadcond.cpp
	$(CC) testthreadcond.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testthreadcond.exe.manifest mt -manifest testthreadcond.exe.manifest -outputresource:testthreadcond.exe;1

testblockcache.exe: testblockcache.cpp
	$(CC) testblockcache.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testblockcache.exe.manifest mt -manifest testblockcache.exe.manifest -outputresource:testblockcache.exe;1

testblockcachewrite.exe: testblockcachewrite.cpp
	$(CC) testblockcachewrite.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testblockcachewrite.exe.manifest mt -manifest testblockcachewrite.exe.manifest -outputresource:testblockcachewrite.exe;1

testblockcachelimits.exe: testblockcachelimits.cpp
	$(CC) testblockcachelimits.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testblockcachelimits.exe.manifest mt -manifest testblockcachelimits.exe.manifest -outputresource:testblockcachelimits.exe;1

testdestroy.exe: testdestroy.cpp
	$(CC) testdestroy.cpp $(CFLAGS) $(GDAL_LIB)
    if exist testdestroy.exe.manifest mt -manifest testdestroy.exe.manifest -outputresource:testdestroy.exe;1

copy-gdal-dll:	$(GDAL_DLL) 

$(GDAL_DLL):	$(GDAL_ROOT)\$(GDAL_DLL)
    copy /y $(GDAL_ROOT)\$(GDAL_DLL) .

.cpp.obj:
	$(CC) $(CFLAGS) /c $*.cpp /Fo$@

.c.obj:
	$(CC) $(CFLAGS) /c $*.c /Fo$@

clean:
	$(RM) *~
	$(RM) *.dll
	$(RM) *.exe
	$(RM) *.exp
	$(RM) *.ilk
	$(RM) *.lib
	$(RM) *.manifest
	$(RM) *.obj
	$(RM) *.pdb
	$(RM) tmp\*.dbf
	$(RM) tmp\*.dt0
	$(RM) tmp\*.grd
	$(RM) tmp\*.shp
	$(RM) tmp\*.shx
	$(RM) tut\*.obj

