##################################################################
#
#   makefile
# 
#   for the MARS software
#
##################################################################
# @maintitle

# @code

#
#  please change all system depend values in the 
#  config.mk.${OSTYPE} file 
#
#
include Makefile.conf.$(OSTYPE)
include Makefile.conf.general

# @endcode 

# @code 

PROGRAM = mars
SOLIB   = mars.so

#
#  connect the include files defined in the config.mk file
#
INCLUDES = -I./ -I$(INCLUDE_MBASE) -I./mrootformat/ -I./mocttest/

#
#  ----->>>   mars libraries
#

MARS_LIB = -L./ -lmocttest -lmrootformat -lmbase 
MARS_LIBB = libmbase.a libmocttest.a libmrootformat.a

#------------------------------------------------------------------------------

#.SILENT:

.SUFFIXES: .c .cc .cxx .h .hxx .o 


SRCFILES = 

SRCS    = $(SRCFILES)
HEADERS = $(SRCFILES:.cc=.h)
OBJS    = $(SRCFILES:.cc=.o) mars.o

############################################################

all: rmlib $(PROGRAM) $(SOLIB)

$(PROGRAM): $(MARS_LIBB) $(OBJS) MCint.o 
	@echo "Linking $(PROGRAM) ..." 
	$(CXX) $(CXXFLAGS) $(OBJS) $(MARS_LIB) MCint.o $(ROOTLIBS) $(ROOTGLIBS) -o $@
        
$(SOLIB): $(MARS_LIBB) $(OBJS) MCint.o
	@echo "Linking $(SOLIB) ..."
	$(CXX) $(CXXFLAGS) -shared $(OBJS) $(MARS_LIB) MCint.o $(ROOTLIBS) $(ROOTGLIBS) -o $@

libmbase.a:
	@echo "Creating libmbase.a ..."
	(cd mbase; make; cp libmbase.a ../libmbase.a; cd ..) 

libmocttest.a:
	@echo "Creating libmocttest.a ..."
	(cd mocttest; make; cp libmocttest.a ../libmocttest.a; cd ..) 


libmrootformat.a:
	@echo "Creating libmrootformat.a ..."
	(cd mrootformat; make; cp libmrootformat.a ../libmrootformat.a; cd ..) 

MCint.cc:	$(HEADERS)
	       	@echo "Generating dictionary MCint.cc..."
		@$(ROOTSYS)/bin/rootcint -f MCint.cc \
                -c $(INCLUDES) $(HEADERS) LinkDef.h 

include Makefile.rules

clean:	rmlib rmcint rmobjs rmcore rmbin

# @endcode

