#
# makefile.vc - Main mapcache makefile for MSVC++
#
#
# 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: $
#

!INCLUDE nmake.opt

BASE_CFLAGS = 	$(OPTFLAGS)

CFLAGS=$(BASE_CFLAGS) $(MAPCACHE_CFLAGS)
CC=     cl
LINK=   link

#
# Main mapcache library.
#

MAPCACHE_OBJS = lib\axisorder.obj  lib\dimension.obj  lib\imageio_mixed.obj  lib\service_wms.obj \
	        lib\buffer.obj lib\ezxml.obj  lib\imageio_png.obj  lib\service_wmts.obj \
                lib\cache_disk.obj  lib\lock.obj lib\services.obj lib\cache_bdb.obj \
                lib\cache_memcache.obj lib\grid.obj  lib\source.obj \
		lib\cache_sqlite.obj lib\http.obj lib\source_gdal.obj lib\source_dummy.obj \
		lib\cache_tiff.obj lib\image.obj lib\service_demo.obj lib\source_mapserver.obj \
		lib\configuration.obj lib\image_error.obj lib\service_kml.obj lib\source_wms.obj \
		lib\configuration_xml.obj lib\imageio.obj lib\service_tms.obj lib\tileset.obj \
		lib\core.obj lib\imageio_jpeg.obj lib\service_ve.obj lib\util.obj lib\strptime.obj \
		$(REGEX_OBJ)


MAPCACHE_FCGI = 	mapcache.exe
MAPCACHE_APACHE =       mod_mapcache.dll
MAPCACHE_SEED = 	mapcache_seed.exe

#
#
#
default: 	all

all:		$(MAPCACHE_LIB) $(MAPCACHE_FCGI) $(MAPCACHE_APACHE) $(MAPCACHE_SEED)


$(MAPCACHE_LIB): $(MAPCACHE_OBJS)
	lib /debug /out:$(MAPCACHE_LIB) $(MAPCACHE_OBJS)


$(MAPCACHE_FCGI): $(MAPCACHE_LIB)
          $(CC) $(CFLAGS) cgi\mapcache.c /Fecgi\mapcache.exe $(LIBS)
	         if exist cgi\$(MAPCACHE_FCGI).manifest mt -manifest cgi\$(MAPCACHE_FCGI).manifest -outputresource:cgi\$(MAPCACHE_FCGI);1

$(MAPCACHE_APACHE): $(MAPCACHE_LIB)
          $(CC) $(CFLAGS) apache\mod_mapcache.c /link /DLL /out:apache\mod_mapcache.dll $(LIBS)
	         if exist apache\$(MAPCACHE_APACHE).manifest mt -manifest apache\$(MAPCACHE_APACHE).manifest -outputresource:apache\$(MAPCACHE_APACHE);2

$(MAPCACHE_SEED): $(MAPCACHE_LIB)
          $(CC) $(CFLAGS) util\mapcache_seed.c /Feutil\mapcache_seed.exe $(LIBS)
	         if exist util\$(MAPCACHE_SEED).manifest mt -manifest util\$(MAPCACHE_SEED).manifest -outputresource:util\$(MAPCACHE_SEED);1

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

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


clean:
    del lib\*.obj
    del *.obj
    del *.exp
    del apache\$(MAPCACHE_APACHE)
    del apache\*.manifest
    del apache\*.exp
    del apache\*.lib
    del apache\*.pdb
    del apache\*.ilk
    del cgi\$(MAPCACHE_FCGI)
    del cgi\*.manifest
    del cgi\*.exp
    del cgi\*.lib
    del cgi\*.pdb
    del cgi\*.ilk
    del util\$(MAPCACHE_SEED)
    del util\*.manifest
    del util\*.exp
    del util\*.lib
    del util\*.pdb
    del util\*.ilk
    del *.lib
    del *.manifest


install: $(MAPCACHE_EXE)
	-mkdir $(BINDIR)
	copy *.exe $(BINDIR)



