#  ------------------ 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 prog_name
#     - compiles prog_name.cc -> prog_name.o 
#     - links prog_name.o -> prog_name 

#   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) 

%:%.cc
%:%.o
%.o:%.cc
%.o:%.c
%:%.c

.PRECIOUS: % %.o


#  --- Compilation and linking rules
%:%.o
	$(LINK.cc)  -o $@ $< $(LIBS)

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

%:%.c
	$(LINK.c)  $(USERFLAGS) -o $@ $< $(LIBS) 


