# DIALOGIC CONFIDENTIAL 
# Copyright  2007 Dialogic Corporation. All Rights Reserved.
# 
# The source code contained or described herein and all documents related to 
# the source code ("Material") are owned by Dialogic Corporation or its suppliers
# or licensors. Title to the Material remains with Dialogic Corporation or its 
# suppliers and licensors. The Material contains trade secrets and proprietary
# and confidential information of Dialogic or its suppliers and licensors. The
# Material is protected by worldwide copyright and trade secret laws and treaty
# provisions. No part of the Material may be used, copied, reproduced, 
# modified, published, uploaded, posted, transmitted, distributed, or disclosed
# in any way without Dialogic's prior express written permission.
# 
# No license under any patent, copyright, trade secret or other intellectual 
# property right is granted to or conferred upon you by disclosure or delivery
# of the Materials, either expressly, by implication, inducement, estoppel or
# otherwise. Any license under such intellectual property rights must be
# express and approved by Dialogic in writing.
#
#######################################################################################
#USE_RTSP = 1

ifdef USE_RTSP
LIVE555 = /export/RTSP/live
#LIVE555 = /export/live555/live/
LIVE_INCS = -I$(LIVE555)/UsageEnvironment/include -I$(LIVE555)/groupsock/include -I$(LIVE555)/liveMedia/include -I$(LIVE555)/BasicUsageEnvironment/include
LIVE_COMPILE_OPTS =          $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LIVE_LIB_SUFFIX =                    a
USAGE_ENVIRONMENT_DIR = $(LIVE555)/UsageEnvironment
USAGE_ENVIRONMENT_LIB = $(USAGE_ENVIRONMENT_DIR)/libUsageEnvironment.$(LIVE_LIB_SUFFIX)
BASIC_USAGE_ENVIRONMENT_DIR = $(LIVE555)/BasicUsageEnvironment
BASIC_USAGE_ENVIRONMENT_LIB = $(BASIC_USAGE_ENVIRONMENT_DIR)/libBasicUsageEnvironment.$(LIVE_LIB_SUFFIX)
LIVEMEDIA_DIR = $(LIVE555)/liveMedia
LIVEMEDIA_LIB = $(LIVEMEDIA_DIR)/libliveMedia.$(LIVE_LIB_SUFFIX)
GROUPSOCK_DIR = $(LIVE555)/groupsock
GROUPSOCK_LIB = $(GROUPSOCK_DIR)/libgroupsock.$(LIVE_LIB_SUFFIX)
LIVE_LIBS =    $(LIVEMEDIA_LIB) $(GROUPSOCK_LIB) \
                $(BASIC_USAGE_ENVIRONMENT_LIB) $(USAGE_ENVIRONMENT_LIB) -lboost_thread
RTSP_FLAGS = -DUSE_RTSP
else
 LIVE_INCS = 
 LIVE_LIBS = 
 RTSP_FLAGS =
endif

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

# Defines for Oceanville (3G-324M) demo
# Enable these lines and recompile code to enable features

# This enables a GC/DTI connection using dtiB2 
# DTMF "4" will enable the connection, and "5" will disable it in any of the
# demo menus
#TDMAUDIO = -DTDM_AUDIO

# This disables the use of dev_ReserveResourceEx 
# for platforms that don't support it.
NO_RESERVATIONEX = -DNO_RESERVATIONEX

USE_MTK_API = -DUSE_MTK_API
USE_DEV_PORT_CONNECT = -DUSE_DEV_PORT_CONNECT

ifeq "$(DIALOGIC_PLATFORM)" "HMP"
  ifeq "$(DIALOGIC_RELNUM)" "3.1"
    #DIALOGIC_REL = -DHMP_3_1
    PLATFORM_DEFS = $(USE_DEV_PORT_CONNECT) 
  endif
  ifeq "$(DIALOGIC_RELNUM)" "4.1"
    #DIALOGIC_REL = -DHMP_4_1
    PLATFORM_DEFS = $(USE_DEV_PORT_CONNECT) $(USE_MTK_API)
    PLATFORM_LIBS = -lmtkl    
  endif
endif
ifeq "$(DIALOGIC_PLATFORM)" "OVL"
  ifeq "$(DIALOGIC_RELNUM)" "2.0"
    #DIALOGIC_REL = -DMMS_2_0
    PLATFORM_DEFS = $(USE_DEV_PORT_CONNECT) $(USE_MTK_API)
    PLATFORM_LIBS = -lmtkl 
  endif
endif

ifeq "$(DIALOGIC_PLATFORM)" "ZVL"
  ifeq "$(DIALOGIC_RELNUM)" "1.0"
    #DIALOGIC_REL = -DMMK_1_0
    PLATFORM_DEFS = $(USE_DEV_PORT_CONNECT) $(USE_MTK_API)
    PLATFORM_LIBS =  -lmtkl
  endif
endif


# Set to use Gnu debugger
GDB_FLAG = -g

ifdef INTEL_DIALOGIC_BIN
CFG 	=	External
else
CFG 	=	Internal
endif

ifeq "$(OS)" "windows"
all:
	msdev ..\MultiMediaDemo.dsw "MultiMediaDemo.dsw - Win32 Release" /MAKE
clean:
	rm ..\Release\MultiMediaDemo.exe
                                                                                                                             
else


#####################################################################################
# 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) $(LIVE_INCS)
                     
else
        CFG_INC =       -I/usr/dialogic/inc $(LIVE_INCS)            
endif

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

ifdef DLGCROOT
	# Sdpapi library
	SDPAPI_LOC = $(DLGCROOT)/demos/sdpapi
	SDPAPI_LIB = $(SDPAPI_LOC)/Linux/sdpAPI.a
	SDPAPI_INC = -I$(SDPAPI_LOC)
else
	# Sdpapi library
	SDPAPI_LOC = /usr/dialogic/demos/sdpapi
	SDPAPI_LIB = $(SDPAPI_LOC)/Linux/sdpAPI.a
	SDPAPI_INC = -I$(SDPAPI_LOC)
endif
	

# Initialize other variables
OUTDIR          =       ./Release
OBJDIR		=	$(OUTDIR)
OUTFILE         =       $(OUTDIR)/MultiMediaDemo
DEBUG_FLAG	=	-DDEBUG_LOG

ifdef USE_RTSP
RTSPOBJS   = $(OBJDIR)/CRTSPClient.o \
             $(OBJDIR)/CRTSPEnv.o
else
RTSPOBJS =
endif


LIB		=	-lgc 				\
			-lipm 				\
			-lsrl 				\
			-lmml -ldevmgmt  	\
			$(PLATFORM_LIBS)    \
			$(LIVE_LIBS)				 

INC		= 	appevents.h			\
			config.h			\
			connection.h			\
			exitsync.h			\
			ipchannel.h			\
                        sprop.h                         \
			locker.h			\
			miscellaneous.h			\
			mmdemo.h			\
			mmstream.h			

OBJ 		= 	$(RTSPOBJS)                     \
                        $(OBJDIR)/mmdemo.o		\
			$(OBJDIR)/mmstream.o 		\
			$(OBJDIR)/config.o 		\
			$(OBJDIR)/exitsync.o 		\
			$(OBJDIR)/ipchannel.o		\
			$(OBJDIR)/sprop.o		\
			$(OBJDIR)/MultiMediaDemo_version.o 	

COMPILE		=	g++ -c $(GDB_FLAG) $(DEBUG_FLAG) -m32 -o "$(OUTDIR)/$(*F).o" $(CFG_INC) \
				$(RTSP_FLAGS) $(SDPAPI_INC) $(DIALOGIC_REL) $(PLATFORM_DEFS) "$<"
LINK		=	g++ $(GDB_FLAG) -m32 -o "$(OUTFILE)" $(OBJ) $(CFG_LIB) $(LIB) $(SDPAPI_LIB)

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

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

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

# Build rules
all:
	$(MAKE) $(OUTFILE)
 
# Rebuild this project
rebuild: cleanall all
 
# Clean this project
clean:
	rm -f $(OUTFILE)
	rm -f $(OBJ)
 
# Clean this project and all dependencies
cleanall: clean
 
endif


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


OUTDIR          =       $(MULTIMEDIADEMO_OBJECTS)
OBJDIR		=	$(MULTIMEDIADEMO_OBJECTS)
INCDIR		=	$(MULTIMEDIADEMO_OBJECTS)
OUTFILE         =       $(OUTDIR)/MultiMediaDemo
DEBUG_FLAG	=	-DDEBUG_LOG

CFG_INC		=	-I$(MULTIMEDIADEMO_INC_EXT) 	\
			-I$(IPDEMOS_IMPORT_INC)		
			
			
CFG_LIB		=	-L$(IPDEMOS_IMPORT_LIB)		
		
# Sdpapi library
SDPAPI_LOC 	= 	$(IPDEMOS_IMPORT_LIB)
SDPAPI_LIB 	= 	$(SDPAPI_LOC)/sdpAPI.a
SDPAPI_INC 	= 	-I$(SDPAPI_LOC)
	
LIB		=	-lgc 				\
			-lipm 				\
			-lsrl 				\
			-lmml		                \
			-ldevmgmt

INC		= 	$(MULTIMEDIADEMO_ROOT)/appevents.h		\
			$(MULTIMEDIADEMO_ROOT)/config.h			\
			$(MULTIMEDIADEMO_ROOT)/connection.h		\
			$(MULTIMEDIADEMO_ROOT)/exitsync.h		\
			$(MULTIMEDIADEMO_ROOT)/ipchannel.h		\
			$(MULTIMEDIADEMO_ROOT)/sprop.h		        \
			$(MULTIMEDIADEMO_ROOT)/locker.h			\
			$(MULTIMEDIADEMO_ROOT)/miscellaneous.h		\
			$(MULTIMEDIADEMO_ROOT)/mmdemo.h			\
			$(MULTIMEDIADEMO_ROOT)/mmstream.h		\
			$(MULTIMEDIADEMO_ROOT)/CRTSPClient.h

OBJ 		= 	$(OBJDIR)/mmdemo.o		\
			$(OBJDIR)/mmstream.o 		\
			$(OBJDIR)/config.o 		\
			$(OBJDIR)/exitsync.o 		\
			$(OBJDIR)/ipchannel.o		\
			$(OBJDIR)/sprop.o		\
			$(OBJDIR)/CRTSPClient.o		\
			$(OBJDIR)/MultiMediaDemo_version.o 


COMPILE		=	g++ -c -m32 -o "$(OBJDIR)/$(*F).o" $(CFG_INC) $(SDPAPI_INC) "$<"
LINK		=	g++ -m32 -o "$(OUTFILE)" $(OBJ) $(CFG_LIB) $(LIB) $(SDPAPI_LIB)

# Pattern rules
$(MULTIMEDIADEMO_OBJECTS)/%.o :$(MULTIMEDIADEMO_SRC)/%.cpp
	$(COMPILE)

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

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

# Build rules
all: 
	$(MAKE) $(OUTFILE)

# Rebuild this project
rebuild: cleanall all


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

endif

endif

