#  ------------------ SOPHYA -------------------------
#    Makefile fot compiling and linking a simple C++ 
#         program with SOPHYA class library 
#  ---------------------------------------------------
#  GNU make program should be used with this makefile
#  ---------------------------------------------------
#  Usage: make 
#     - compiles ex1.cc -> Objs/ex1.o 
#     - links Objs/ex1.o -> Objs/ex1 
#         make depend
#         to create the Objs/ directory

#   SOPHYA compilation rules - OPTFLAG and DBGFLAG 
# can be used to define Debug and optimization flags
# Additional options can be specified using USERFLAGS
# USERFLAGS := -I/.../myincludes 

include $(SOPHYABASEREP)/Include/MakefileUser.h


# ----- List of SOPHYA libraries 
ifdef NOSHLIB
LIBF =  $(LIB)libLinAlg.a $(LIB)libIFFTW.a $(LIB)libFitsIOServer.a $(LIB)libSamba.a $(LIB)libSkyMap.a $(LIB)libSkyT.a $(LIB)libNTools.a $(LIB)libHiStats.a $(LIB)libTArray.a $(LIB)libSysTools.a
LIBS = -L$(LIB) -lLinAlg -lIFFTW -lFitsIOServer -lSamba -lSkyMap -lSkyT -lNTools -lHiStats -lTArray -lSysTools -lm
ifeq ($(CXX),cxx)
# librairie des instances de templates cxx
LIBS := $(LIBS) -lsotcxx
endif
else
LIBF =  $(SLB)libsophya.so $(SLB)libextsophya.so
LIBS = -L$(SLB) -lextsophya -lsophya  -lm
endif

LDLIBS := $(LIBS) $(LDLIBS) 

#  Object and executable files will be put in 
MYOBJS := Objs/

#  --- Compilation and linking rules
$(MYOBJS)%.o:%.cc
	$(COMPILE.cc)   $(USERFLAGS) -o $@ $<

$(MYOBJS)%:%.c
	$(COMPILE.c)  $(USERFLAGS) -o $@ $< 


#  list of default build target
all : depend $(MYOBJS)ex1

#  Clean procedure
clean : 
	rm -f $(MYOBJS)ex1 $(MYOBJS)ex1.o
#  Directory buid procedure
depend :
	if (test ! -d $(MYOBJS) ) then mkdir $(MYOBJS) ; fi

#  build rules for ex1
$(MYOBJS)ex1 : $(MYOBJS)ex1.o
	$(LINK.cc) $^ $(LIBS) -o $@
$(MYOBJS)ex1.o : ex1.cc



