CXSCLIB = /usr/local/cxsc/lib#                path to cxsc library 
CXSCINC = /usr/local/cxsc/include #           path to cxsc include directory

LIBPATHS = -L$(CXSCLIB)#                      library directories
INCPATHS = -I$(CXSCINC)#                      include directories
MLPROGRAMS = .#                               the MathLink progms

CXX = g++#                                    name of the C++ compiler

CXXFLAGS = -Wall -Winline#                    optional flags

LIBRARIES = $(LIBPATHS) -lML -lcxsc -lm -lpthread -lrt

ALL_PROGRAMS = $(patsubst $(MLPROGRAMS)/%.cpp,%, $(shell  ls $(MLPROGRAMS)/ddfAri.cpp))

$(ALL_PROGRAMS) :
	$(MLPROGRAMS)/mprep -prototypes -o $(MLPROGRAMS)/$@.tm.c  $(MLPROGRAMS)/$@.tm
	$(CXX) -g -o $(MLPROGRAMS)/$@  $(MLPROGRAMS)/$@.tm.c  $(MLPROGRAMS)/$@.cpp  $(INCPATHS)  $(CXXFLAGS)  $(LIBRARIES)

all : $(ALL_PROGRAMS)

.PHONY : clean

FILES = $(foreach file, $(ALL_PROGRAMS), $(MLPROGRAMS)/$(file))

clean : $(MLPROGRAMS)/*.tm.c  $(FILES)
	rm  $^
