# Project: table_calculus
# MinGW Makefile
# Created by O. Conrad

PRJ_NAME = table_calculus
BIN_SAGA = $(SAGA)\bin\saga_mingw
TMP_SAGA = $(SAGA)\bin\tmp\saga_mingw
MLB_TEMP = $(TMP_SAGA)\$(PRJ_NAME)
MLB_PATH = $(BIN_SAGA)\modules
MLB_NAME = $(MLB_PATH)\$(PRJ_NAME).dll
LIB_NAME = $(MLB_PATH)\lib$(PRJ_NAME).a

CPP      = g++.exe
LD       = dllwrap.exe

DEP_INCS = 
DEP_DEFS = 
DEP_LIBS = 
DEP_LFLG = 

OBJ      = $(MLB_TEMP)/Fit.o $(MLB_TEMP)/LMFit.o $(MLB_TEMP)/MLB_Interface.o $(MLB_TEMP)/Table_Calculator.o $(MLB_TEMP)/Table_CalculatorShapes.o $(MLB_TEMP)/Table_Trend.o

CXXFLAGS = -I"$(MINGW)/include" -I"$(SAGA)/src/saga_core" -D$(PRJ_NAME)_EXPORTS -DBUILDING_DLL=1 -D_SAGA_MSW -D_SAGA_MINGW -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -fexpensive-optimizations -Os -O2 -O3 $(DEP_INCS) $(DEP_DEFS)

LIBS     = -L"$(MINGW)/lib" -L"$(WXWIN)/lib/gcc_lib" $(DEP_LIBS) $(BIN_SAGA)/libsaga_api.a
LDFLAGS  = --no-export-all-symbols --add-stdcall-alias --driver-name c++ $(DEP_LFLG)

.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):
	if not exist $(TMP_SAGA) mkdir $(TMP_SAGA)

$(MLB_TEMP): $(TMP_SAGA)
	if not exist $(MLB_TEMP) mkdir $(MLB_TEMP)

$(MLB_PATH):
	if not exist $(MLB_PATH) mkdir $(MLB_PATH)

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


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

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

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

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

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

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