# Project: io_grid
# Linux GCC Makefile
# Created by O. Conrad

PRJ_NAME = io_grid
SAGA     = ./../../..
BIN_SAGA = $(SAGA)/../bin/saga_gtk
TMP_SAGA = $(SAGA)/../bin/tmp/saga_gtk
INC_SAGA = $(SAGA)/saga_core
MLB_TEMP = $(TMP_SAGA)/$(PRJ_NAME)
MLB_PATH = $(BIN_SAGA)/modules
MLB_NAME = $(MLB_PATH)/$(PRJ_NAME).so

CPP      = g++
LD       = g++

DEP_INCS = 
DEP_DEFS = 
DEP_LIBS = 
DEP_LFLG = 

OBJ      = $(MLB_TEMP)/bmp_export.o $(MLB_TEMP)/erdas_lan.o $(MLB_TEMP)/esri_arcinfo.o $(MLB_TEMP)/grid_table.o $(MLB_TEMP)/MLB_Interface.o $(MLB_TEMP)/mola.o $(MLB_TEMP)/raw.o $(MLB_TEMP)/srtm30.o $(MLB_TEMP)/surfer.o $(MLB_TEMP)/usgs_srtm.o $(MLB_TEMP)/xyz.o

DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS =
CXX_DEFS =
CXX_FLGS = -O2
CXXFLAGS = $(CXX_INCS) $(CXX_DEFS) $(CXX_FLGS) $(DEP_INCS) $(DEP_DEFS) -I$(INC_SAGA) $(DEF_SAGA)

LDFLAGS  = -shared $(DEP_LFLG)
LIBS     = $(DEP_LIBS)

.PHONY: all all-before all-after clean clean-custom

all: all-before $(MLB_NAME) all-after

clean: clean-custom
	rm -f $(OBJ) $(MLB_NAME)

$(TMP_SAGA):
	-mkdir $(TMP_SAGA)

$(MLB_TEMP): $(TMP_SAGA)
	-mkdir $(MLB_TEMP)

$(MLB_PATH):
	-mkdir $(MLB_PATH)

$(MLB_NAME): $(MLB_TEMP) $(MLB_PATH) $(OBJ)
	$(LD) $(LDFLAGS) -o $(MLB_NAME) $(OBJ) $(LIBS)


$(MLB_TEMP)/bmp_export.o: ./bmp_export.cpp
	$(CPP) -c ./bmp_export.cpp -o $(MLB_TEMP)/bmp_export.o $(CXXFLAGS)

$(MLB_TEMP)/erdas_lan.o: ./erdas_lan.cpp
	$(CPP) -c ./erdas_lan.cpp -o $(MLB_TEMP)/erdas_lan.o $(CXXFLAGS)

$(MLB_TEMP)/esri_arcinfo.o: ./esri_arcinfo.cpp
	$(CPP) -c ./esri_arcinfo.cpp -o $(MLB_TEMP)/esri_arcinfo.o $(CXXFLAGS)

$(MLB_TEMP)/grid_table.o: ./grid_table.cpp
	$(CPP) -c ./grid_table.cpp -o $(MLB_TEMP)/grid_table.o $(CXXFLAGS)

$(MLB_TEMP)/MLB_Interface.o: ./MLB_Interface.cpp
	$(CPP) -c ./MLB_Interface.cpp -o $(MLB_TEMP)/MLB_Interface.o $(CXXFLAGS)

$(MLB_TEMP)/mola.o: ./mola.cpp
	$(CPP) -c ./mola.cpp -o $(MLB_TEMP)/mola.o $(CXXFLAGS)

$(MLB_TEMP)/raw.o: ./raw.cpp
	$(CPP) -c ./raw.cpp -o $(MLB_TEMP)/raw.o $(CXXFLAGS)

$(MLB_TEMP)/srtm30.o: ./srtm30.cpp
	$(CPP) -c ./srtm30.cpp -o $(MLB_TEMP)/srtm30.o $(CXXFLAGS)

$(MLB_TEMP)/surfer.o: ./surfer.cpp
	$(CPP) -c ./surfer.cpp -o $(MLB_TEMP)/surfer.o $(CXXFLAGS)

$(MLB_TEMP)/usgs_srtm.o: ./usgs_srtm.cpp
	$(CPP) -c ./usgs_srtm.cpp -o $(MLB_TEMP)/usgs_srtm.o $(CXXFLAGS)

$(MLB_TEMP)/xyz.o: ./xyz.cpp
	$(CPP) -c ./xyz.cpp -o $(MLB_TEMP)/xyz.o $(CXXFLAGS)
