
GDAL_ROOT	=	../
!INCLUDE $(GDAL_ROOT)\nmake.opt

SCRIPT_CONFIG = .\setup.ini

gdalvars:
	-del $(SCRIPT_CONFIG)
	echo $(GDAL_HOME) > $(SCRIPT_CONFIG)
        findstr /c:"define GDAL_RELEASE_NAME " ..\gcore\gdal_version.h  >> $(SCRIPT_CONFIG)
#echo $(EXTERNAL_LIBS) >> $(SCRIPT_CONFIG)

python: gdalvars 
        cd python
        $(SWIG) -python -modern -new_repr -o extensions/gdalconst_wrap.c -outdir osgeo ..\include\gdalconst.i
        $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/gdal_wrap.cpp -outdir osgeo ..\include\gdal.i
        $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/osr_wrap.cpp -outdir osgeo ..\include\osr.i
        $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/ogr_wrap.cpp -outdir osgeo ..\include\ogr.i
        $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/gdal_array_wrap.cpp -outdir osgeo ..\include\gdal_array.i
        $(PYDIR)\python.exe setup.py build
        
#d:\Python\debug\Python-2.4\PCbuild\python_d.exe setup.py build   --debug

csharp: gdalvars
        cd csharp
        $(MAKE) /f makefile.vc interface
        $(MAKE) /f makefile.vc

java: gdalvars
        cd java
        if not exist org\gdal\gdal mkdir org\gdal\gdal
        cd gdal
        $(SWIG) -java -c++ -package org.gdal.gdal -outdir ../org/gdal/gdal -I../../include/java -o gdal_wrap.cpp ../../../include/gdal.i
        cd ..
        cd org\gdal
        if not exist ogr mkdir ogr
        cd ../../
        cd ogr
        $(SWIG) -java -c++ -package org.gdal.ogr -outdir ../org/gdal/ogr -I../../include/java -o ogr_wrap.cpp ../../../include/ogr.i
        cd ..
        cd org\gdal
        if not exist osr mkdir osr
        cd ../../
        cd osr
        $(SWIG) -java -c++ -package org.gdal.osr -outdir ../org/gdal/osr -I../../include/java -o osr_wrap.cpp ../../../include/osr.i
        cd ..
        cd org\gdal
        if not exist gdalconst mkdir gdalconst
        cd ../../
        cd const
        $(SWIG) -java -c++ -package org.gdal.gdalconst -outdir ../org/gdal/gdalconst -I../../include/java -o gdalconst_wrap.cpp ../../../include/gdalconst.i
        cd ..
        $(MAKE) /f makefile.vc

ruby: gdalvars
        cd ruby
        $(SWIG) -ruby -I../include/ruby -o gdalconst_wrap.c -autorename -prefix "gdal::" ../include/gdalconst.i
        $(SWIG) -c++ -ruby -I../include/ruby -o gdal_wrap.cpp -autorename -prefix "gdal::" ../include/gdal.i
        $(SWIG) -c++ -ruby -I../include/ruby -o osr_wrap.cpp -autorename -prefix "gdal::" ../include/osr.i
        $(SWIG) -c++ -ruby -I../include/ruby -o ogr_wrap.cpp -autorename -prefix "gdal::" ../include/ogr.i
        $(MAKE) /f makefile.vc build
        $(MAKE) /f makefile.vc install 
        
test: gdalvars
				cd $(GDAL_HOME)\..\gdalautotest
				$(PYDIR)/python.exe run_all.py
clean:
        -del setup.ini
        cd csharp
        $(MAKE) /f makefile.vc clean
        cd ..
        cd python
        if exist build\nul rmdir /S /Q build
        cd ..
        cd java
        $(MAKE) /f makefile.vc clean
        cd ..
        cd ruby
        $(MAKE) /f makefile.vc clean
        cd ..

