                                                                                                                                                                                                                                                               
CC	=	@CC@
CXX	=	@CXX@
LD	=	@CXX@

CPPFLAGS = -DUSE_CPL -DGRASS_GISBASE=\"@GRASS_GISBASE@\" \
	  @GDAL_INC@ @GRASS_INCLUDE@ @CPPFLAGS@ 
CXXFLAGS = @CXX_WFLAGS@ @CXX_PIC@ 

RANLIB		=	@RANLIB@
SO_EXT		=	@SO_EXT@
LD_SHARED	=	@LD_SHARED@

LIBS	=	@LIBS@

GRASSTABLES_DIR = @prefix@/share/gdal/grass

AUTOLOAD_DIR	=	@AUTOLOAD_DIR@

GLIBNAME =	gdal_GRASS.so
OLIBNAME =	ogr_GRASS.so

default:	$(GLIBNAME) $(OLIBNAME)

install:	default
	install -d $(AUTOLOAD_DIR)
	cp $(GLIBNAME) $(AUTOLOAD_DIR)
	cp $(OLIBNAME) $(AUTOLOAD_DIR)
	test -d ${GRASSTABLES_DIR} || mkdir ${GRASSTABLES_DIR}
	test -d ${GRASSTABLES_DIR}/etc || mkdir ${GRASSTABLES_DIR}/etc
	cp @GRASS_GISBASE@/etc/ellipse.table ${GRASSTABLES_DIR}/etc
	cp @GRASS_GISBASE@/etc/datum.table @GRASS_GISBASE@/etc/datumtransform.table ${GRASSTABLES_DIR}/etc
	test -d ${GRASSTABLES_DIR}/driver || mkdir ${GRASSTABLES_DIR}/driver
	test -d ${GRASSTABLES_DIR}/driver/db || mkdir ${GRASSTABLES_DIR}/driver/db
	cp -r @GRASS_GISBASE@/driver/db/* ${GRASSTABLES_DIR}/driver/db/

clean:
	rm -f $(OLIBNAME) $(GLIBNAME) *.o 

distclean: clean
	rm -fr Makefile config.status config.log autom*.cache


$(GLIBNAME):	grass57dataset.o
	$(LD_SHARED) grass57dataset.o $(LIBS) -o $(GLIBNAME)

$(OLIBNAME):	ogrgrassdriver.o ogrgrassdatasource.o ogrgrasslayer.o 
	$(LD_SHARED) ogrgrassdriver.o ogrgrassdatasource.o ogrgrasslayer.o $(LIBS) -o $(OLIBNAME)

%.o:	%.cpp
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<

