# Makefile for CnfConferencing demo
# If no configuration is specified
# force CFG to be Release if build installed, or Internal otherwise

ifdef INTEL_DIALOGIC_BIN
CFG :=	External
else
CFG :=	Internal
endif

ifeq "$(OS)" "windows"
all:
	msdev ..\src\CnfConferencingDemo.dsw "CnfConferencingDemo - Win32 Release" /MAKE
clean:
	del ..\src\Release\CnfConferencingDemo.exe   
                                                                                                                        
else
#####################################################################################
# Configuration: Linux
#####################################################################################

LIB		=	-lsrl 			\
			-ldxxx 			\
			-ldti 			\
			-lgc				\
			-lcnf				\
			-ldevmgmt			\
			-lipm			


# Initialize other variables
ifndef BUILD
  BUILD = _HMP15
endif

#------------------------------
# Configuration: External
#------------------------------
ifeq "$(CFG)" "External"

  # If the Dialogic Environment variable has been set, use it
  ifdef INTEL_DIALOGIC_INC
	CFG_INC = 	-I$(INTEL_DIALOGIC_INC)
  else
	CFG_INC = 	-I/usr/dialogic/inc
  endif

  ifdef INTEL_DIALOGIC_LIB
        CFG_LIB = 	-L$(INTEL_DIALOGIC_LIB)
  else
        CFG_LIB = 	-L/usr/dialogic/lib
  endif

  ifdef DEBUG
    OUTDIR        = ./Debug
  else
    OUTDIR        = ./Release
  endif

  OBJDIR		=	$(OUTDIR)
  SYS_LIB		=	-L/usr/lib

  SRC		      = ./
 
endif
# end External
#------------------------------
# Configuration: Internal
#------------------------------
ifeq "$(CFG)" "Internal"
  top_reldir	=	../../../../
  -include ./make.rules.mak

  OUTDIR        =   $(IPDEMOS_BIN_EXT)
  OBJDIR		=	$(CONFERENCINGDEMO_OBJECTS)
  SYS_LIB		=	-L$(IPDEMOS_IMPORT_LIB)
  CFG_INC		=	-I$(CONFERENCINGDEMO_INC_EXT) -I$(IPDEMOS_IMPORT_INC)
  CFG_LIB		=	-L$(IPDEMOS_IMPORT_LIB) $(SYS_LIB)
  SRC		    = 	../src

endif


# Initialize other variables
ifdef DEBUG
  DBGO	    = -g
endif

#------------------------------
# Configuration: Both
#------------------------------

OUTFILE   = $(OUTDIR)/CnfConferencingDemo


HDR 	  = $(SRC)/CnfBoard.h			\
			$(SRC)/CnfConference.h		\
			$(SRC)/CnfDemoPrm.h		\
			$(SRC)/ConfigFile.h		\
			$(SRC)/ConsoleLog.h		\
			$(SRC)/DetectCfg.h		\
			$(SRC)/FileLog.h			\
			$(SRC)/GenLog.h			\
			$(SRC)/IptDevice.h		\
			$(SRC)/NtwkDevice.h		\
			$(SRC)/pdl.h			\
			$(SRC)/product_versions.h 	\
			$(SRC)/PstnDevoice.h		\
			$(SRC)/SdpParser.h		\
			$(SRC)/SrlDevice.h		\
			$(SRC)/SrlDeviceContainer.h	\
			$(SRC)/SrlThread.h		\
			$(SRC)/StateMachine.h		\
			$(SRC)/utils.h			\
			$(SRC)/win_unix.h


OBJ 		= 	$(OBJDIR)/FileLog.o 		\
	     		$(OBJDIR)/GenLog.o    		\
			$(OBJDIR)/utils.o			\
			$(OBJDIR)/main.o 			\
			$(OBJDIR)/CnfBoard.o 		\
			$(OBJDIR)/CnfConference.o  	\
			$(OBJDIR)/CnfDemoPrm.o 		\
			$(OBJDIR)/CnfDemo_version.o	\
			$(OBJDIR)/ConfigFile.o 		\
			$(OBJDIR)/ConsoleLog.o 		\
			$(OBJDIR)/DetectCfg.o 		\
			$(OBJDIR)/DevDump.o 		\
			$(OBJDIR)/gc_wrapper.o 		\
			$(OBJDIR)/IptDevice.o 		\
			$(OBJDIR)/NtwkDevice.o 		\
			$(OBJDIR)/PstnDevice.o 		\
			$(OBJDIR)/SrlDeviceContainer.o	\
			$(OBJDIR)/SrlDevice.o 		\
			$(OBJDIR)/SrlThread.o 		\
			$(OBJDIR)/CParser.o 		\
			$(OBJDIR)/SdpParser.o 		\
			$(OBJDIR)/StateMachine.o

CFLAGS		= -DLINUX -D$(BUILD) $(EXTRA_CXXFLAGS)
LDFLAGS		= $(EXTRA_LDFLAGS)

COMPILE	=	g++ $(DBGO) -c -Dlint -Wall $(CFLAGS)  -o "$(OBJDIR)/$(*F).o" $(CFG_INC) "$<"
LINK	=	g++ $(DBGO) $(LDFLAGS) -o "$(OUTFILE)" $(OBJ) $(SYS_LIB) $(CFG_LIB) $(LIB)

# Pattern rules
$(OBJDIR)/%.o : $(SRC)/%.cpp
	$(COMPILE)

# Build rules
all: $(OUTFILE)

$(OUTFILE): $(OUTDIR) $(OBJ)
	$(LINK)

# Create the release dir if doesn't exist
$(OUTDIR):
	mkdir -p "$(OUTDIR)"

# Rebuild this project
rebuild: clean all

# Clean this project
clean:
	rm -f $(OUTFILE)
	rm -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean

explain:
	@echo " "
	@echo "*********** Explaination ************"
	@echo obj filles $(OBJ)
	@echo src    : $(SRC)
	@echo Objdir : $(OBJDIR)
	@echo Output : $(OUTFILE)
	@echo Compile: $(COMPILE)
	@echo Link   : $(LINK)


endif
