#------------------------------------------------------------------------------
# General Settings
#------------------------------------------------------------------------------

TOPDIR = ..

include $(TOPDIR)/Makefile.defs
include $(TOPDIR)/mf/common.defs

.SUFFIXES: .cpp .o
.PHONY: all install clean


# Directories
EPKDIR   = $(TOPDIR)/epik/utils
EPKINC   = -I$(EPKDIR) 
EPKLIB   = -L$(EPKDIR) -lepk.util 

ELGDIR   = $(TOPDIR)/epik/epilog/base
ELGINC   = -I$(ELGDIR)
ELGLIB   = -L$(ELGDIR) -lelg.base 

PEARLDIR = $(TOPDIR)/pearl
PEARLINC = -I$(PEARLDIR)/base -I$(PEARLDIR)/MPI -I$(PEARLDIR)/replay
PEARLLIB = -L$(PEARLDIR)/base -L$(PEARLDIR)/MPI -L$(PEARLDIR)/replay \
           -lpearl.replay -lpearl.mpi -lpearl.base

BASEDIR  = $(PEARLDIR)/base
BASEINC  = -I$(BASEDIR)
BASELIB  = -L$(BASEDIR) -lpearl.base

# Compile flags
CXXFLAGS += -DPEARL_USE_LIST $(PEARLINC) $(SIONLIB_CFLAGS_SER) $(EPKINC)

# Programs
PROGS = \
	 salsa 




#------------------------------------------------------------------------------
# Rules
#------------------------------------------------------------------------------

all: $(PROGS)

install:
	$(MKDIR) -m 755 $(BINDIR)
	@list='$(PROGS)'; for p in $$list; do \
		echo "$(INSTALL) -c -m 755 $$p $(BINDIR)" ; \
		eval "$(INSTALL) -c -m 755 $$p $(BINDIR)" ; \
	done

clean:
	rm -f $(PROGS)
	rm -f *.o	
	rm -f block*.out
	rm -f *~	


salsa: salsa.o SalsaCallback.o MessageChecker.o SalsaParser.o
	$(MPICXX) $(CXXFLAGS) $(SIONLIB_CFLAGS_MPI) -DPEARL_USE_LIST $(MPIEXTRA) \
		-o $@ $< SalsaCallback.o MessageChecker.o SalsaParser.o \
		$(LDFLAGS) $(PEARLLIB) $(ELGLIB) $(EPKLIB) $(SIONLIB_LIB) \
		$(SZLIB_LIBPATH) $(SZLIB_LIB) $(MPILIB)  \
		$(UTILLIB) $(SFLAG)

.cpp.o: 
	$(MPICXX) $(CXXFLAGS) $(MPIEXTRA) -c $<

MessageChecker.o: MessageChecker.cpp

SalsaParser.o: SalsaParser.cpp

SalsaCallback.o: SalsaCallback.cpp

#------------------------------------------------------------------------------
# Dependencies
#
# Generated by:
#   g++ -MM -I../base -I../../epik/utils pearl_printmap.cpp \
#   | sed -e 's,../base,$(BASEDIR),g' \
#         -e 's,../../epik/utils,$(EPKDIR),g'
#
#   mpicxx -MM -DPEARL_USE_LIST -I../pearl/base -I../pearl/MPI \
#          -I../pearl/replay *.cpp \
#   | sed -e 's,\.\./pearl,$(PEARLDIR),g' \
#         -e 's,LIST/,$(PEARL_DS)/,g'
#------------------------------------------------------------------------------

#pearl_printmap.o: pearl_printmap.cpp $(BASEDIR)/Error.h \
#  $(BASEDIR)/MappingTable.h $(EPKDIR)/elg_types.h \
#  $(BASEDIR)/pearl_types.h

SalsaParser.o: SalsaParser.cpp SalsaParser.h salsa.h
MessageChecker.o: MessageChecker.cpp MessageChecker.h salsa.h \
 $(PEARLDIR)/base/pearl.h $(PEARLDIR)/replay/pearl_replay.h \
 $(PEARLDIR)/base/LocalTrace.h $(PEARLDIR)/base/$(PEARL_DS)/LocalTrace.h \
 $(PEARLDIR)/base/$(PEARL_DS)/Event.h $(PEARLDIR)/base/Event_rep.h \
 $(PEARLDIR)/base/pearl_padding.h $(PEARLDIR)/base/pearl_types.h \
 $(PEARLDIR)/base/SmallObject.h $(PEARLDIR)/base/pearl_types.h \
 $(PEARLDIR)/base/Error.h $(PEARLDIR)/base/Event.h $(PEARLDIR)/base/$(PEARL_DS)/Event.h \
 $(PEARLDIR)/base/GlobalDefs.h $(PEARLDIR)/replay/CallbackManager.h \
 $(PEARLDIR)/replay/Callback.h $(PEARLDIR)/base/CountedPtr.h \
 $(PEARLDIR)/replay/CallbackData.h $(PEARLDIR)/base/Location.h \
 $(PEARLDIR)/base/IdObject.h $(PEARLDIR)/base/Process.h \
 $(PEARLDIR)/base/NamedObject.h $(PEARLDIR)/MPI/MpiMessage.h \
 $(PEARLDIR)/base/Buffer.h $(PEARLDIR)/MPI/MpiComm.h $(PEARLDIR)/MPI/MpiGroup.h \
 $(PEARLDIR)/base/Group.h $(PEARLDIR)/base/RemoteEvent.h \
 $(PEARLDIR)/base/CountedPtr.h $(PEARLDIR)/base/Event_rep.h
SalsaCallback.o: SalsaCallback.cpp SalsaCallback.h salsa.h $(PEARLDIR)/base/pearl.h \
 $(PEARLDIR)/replay/pearl_replay.h $(PEARLDIR)/base/LocalTrace.h \
 $(PEARLDIR)/base/$(PEARL_DS)/LocalTrace.h $(PEARLDIR)/base/$(PEARL_DS)/Event.h \
 $(PEARLDIR)/base/Event_rep.h $(PEARLDIR)/base/pearl_padding.h \
 $(PEARLDIR)/base/pearl_types.h $(PEARLDIR)/base/SmallObject.h \
 $(PEARLDIR)/base/pearl_types.h $(PEARLDIR)/base/Error.h $(PEARLDIR)/base/Event.h \
 $(PEARLDIR)/base/$(PEARL_DS)/Event.h $(PEARLDIR)/base/GlobalDefs.h \
 $(PEARLDIR)/replay/CallbackManager.h $(PEARLDIR)/replay/Callback.h \
 $(PEARLDIR)/base/CountedPtr.h $(PEARLDIR)/replay/CallbackData.h \
 $(PEARLDIR)/base/Location.h $(PEARLDIR)/base/IdObject.h \
 $(PEARLDIR)/base/Process.h $(PEARLDIR)/base/NamedObject.h \
 $(PEARLDIR)/MPI/MpiMessage.h $(PEARLDIR)/base/Buffer.h $(PEARLDIR)/MPI/MpiComm.h \
 $(PEARLDIR)/MPI/MpiGroup.h $(PEARLDIR)/base/Group.h \
 $(PEARLDIR)/base/RemoteEvent.h $(PEARLDIR)/base/CountedPtr.h \
 $(PEARLDIR)/base/Event_rep.h MessageChecker.h
salsa.o: salsa.cpp salsa.h $(PEARLDIR)/base/pearl.h \
 $(PEARLDIR)/replay/pearl_replay.h $(PEARLDIR)/base/LocalTrace.h \
 $(PEARLDIR)/base/$(PEARL_DS)/LocalTrace.h $(PEARLDIR)/base/$(PEARL_DS)/Event.h \
 $(PEARLDIR)/base/Event_rep.h $(PEARLDIR)/base/pearl_padding.h \
 $(PEARLDIR)/base/pearl_types.h $(PEARLDIR)/base/SmallObject.h \
 $(PEARLDIR)/base/pearl_types.h $(PEARLDIR)/base/Error.h $(PEARLDIR)/base/Event.h \
 $(PEARLDIR)/base/$(PEARL_DS)/Event.h $(PEARLDIR)/base/GlobalDefs.h \
 $(PEARLDIR)/replay/CallbackManager.h $(PEARLDIR)/replay/Callback.h \
 $(PEARLDIR)/base/CountedPtr.h $(PEARLDIR)/replay/CallbackData.h \
 $(PEARLDIR)/base/Location.h $(PEARLDIR)/base/IdObject.h \
 $(PEARLDIR)/base/Process.h $(PEARLDIR)/base/NamedObject.h \
 $(PEARLDIR)/MPI/MpiMessage.h $(PEARLDIR)/base/Buffer.h $(PEARLDIR)/MPI/MpiComm.h \
 $(PEARLDIR)/MPI/MpiGroup.h $(PEARLDIR)/base/Group.h \
 $(PEARLDIR)/base/RemoteEvent.h $(PEARLDIR)/base/CountedPtr.h \
 $(PEARLDIR)/base/Event_rep.h MessageChecker.h SalsaCallback.h \
 SalsaParser.h
