# VERSION = 2.2.3
# COMPILED_BY ?= gcc-4.6.3
# RWINLIB = ../windows/gdal2-$(VERSION)
# TARGET = lib$(subst gcc,,$(COMPILED_BY))$(R_ARCH)

# PKG_CPPFLAGS =\
# 	-I$(RWINLIB)/include/gdal \
# 	-I$(RWINLIB)/include/geos \
# 	-I$(RWINLIB)/include/proj

# PKG_LIBS = \
# 	-L$(RWINLIB)/$(TARGET) \
#       -L$(RWINLIB)/lib$(R_ARCH) \
#       -lgdal -lsqlite3 -lspatialite -lproj -lgeos_c -lgeos  \
# 	-ljson-c -lnetcdf -lmariadbclient -lpq -lintl -lwebp -lcurl -lssh2 -lssl -lcrypto \
# 	-lkea -lhdf5_cpp -lhdf5_hl -lhdf5 -lexpat -lfreexl -lcfitsio \
# 	-lmfhdf -ldf -lxdr \
# 	-lopenjp2 -ljasper -lpng16 -ljpeg -ltiff -lgeotiff -lgif -lxml2 -llzma -lszip -lz \
# 	-lodbc32 -lodbccp32 -liconv -lpsapi -lws2_32 -lcrypt32 -lwldap32 -lsecur32 -lgdi32

# all: clean winlibs

# CXX_STD = CXX11

# winlibs:
# 	mkdir -p ../inst
# 	"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" --vanilla "../tools/winlibs.R" $(VERSION)
# 	cp -r $(RWINLIB)/share/gdal ../inst/
# 	cp -r $(RWINLIB)/share/proj ../inst/

# clean:
# 	rm -f $(SHLIB) $(OBJECTS)

# .PHONY: all winlibs clean

# VERSION = 3.0.4
VERSION = 3.2.1
RWINLIB = ../windows/gdal3-$(VERSION)
TARGET = lib$(subst gcc,,$(COMPILED_BY))$(R_ARCH)

PKG_CPPFLAGS =\
	-I$(RWINLIB)/include/gdal-3.2.1 \
	-I$(RWINLIB)/include/geos-3.8.0 \
	-I$(RWINLIB)/include/proj-7.2.1 \
	-DPROJ_H_API

PKG_LIBS = \
	-L$(RWINLIB)/$(TARGET) \
	-L$(RWINLIB)/lib$(R_ARCH)$(CRT) \
	-lgdal -lsqlite3 -lspatialite -lproj -lgeos_c -lgeos  \
	-ljson-c -lnetcdf -lmariadbclient -lpq -lpgport -lpgcommon \
	-lwebp -lcurl -lssh2 -lssl \
	-lhdf5_hl -lhdf5 -lexpat -lfreexl -lcfitsio \
	-lmfhdf -lhdf -lxdr -lpcre \
	-lopenjp2 -ljasper -lpng -ljpeg -ltiff -lgeotiff -lgif -lxml2 -llzma -lz \
	-lodbc32 -lodbccp32 -liconv -lpsapi -lwldap32 -lsecur32 -lgdi32 -lnormaliz \
	-lcrypto -lcrypt32 -lws2_32 -lshlwapi
# https://github.com/r-spatial/sf/pull/1587

all: clean winlibs

CXX_STD = CXX11

winlibs:
	mkdir -p ../inst
	"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" --vanilla "../tools/winlibs.R" $(VERSION)
	cp -r $(RWINLIB)/share/gdal ../inst/
	cp -r $(RWINLIB)/share/proj ../inst/

clean:
	rm -f $(SHLIB) $(OBJECTS)

.PHONY: all winlibs clean

