###############################################################################
#
#       @file  Makefile 
# -- Intel Copyright Notice --
# 
# Copyright (c) 2002-2008 Intel Corporation All Rights Reserved.
# 
# The source code contained or described herein and all documents
# related to the source code ("Material") are owned by Intel Corporation
# or its suppliers or licensors.  Title to the Material remains with
# Intel Corporation or its suppliers and licensors. The software is licensed under 
# IXA SDK license.
# 
# 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 except in accordance with the
# applicable license agreement .
# 
# 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, except in accordance with the
# applicable license agreement.
# 
# Unless otherwise agreed by Intel in writing, you may not remove or
# alter this notice or any other notice embedded in Materials by Intel
# or Intel's suppliers or licensors in any way.
# 
# For further details, please see the file README.TXT distributed with
# this software.
# 
# -- End Intel Copyright Notice --
# 
#
###############################################################################


############################################################################
# tools
############################################################################

ifeq ($(TOOLENV),linux)
 ifeq ($(IX_DEVICE),ia)
#   LINUX_INC = /usr/include
#   LINUX_KERNEL_INC :=   	
   LINUX_CROSS_COMPILE := /usr/bin/
   CC := $(LINUX_CROSS_COMPILE)gcc
   LD := $(LINUX_CROSS_COMPILE)ld
   AR := $(LINUX_CROSS_COMPILE)ar
   AS := $(LINUX_CROSS_COMPILE)as
 endif #IA
endif

############################################################################
# compiler/linker flags
############################################################################

# Override standard COPTS

CFLAGS += -DNDEBUG -g

ifeq ($(IX_DEVICE),ia)
CFLAGS += -I./ -I./include/ -I$(LINUX_INC) -I$(ADS_BASE_DIR)/include \
		-r -nostdlib -DUSER_SPACE_DSR -O3 -DIX_DSP_CODELET_SOCKET_SINGLE_THREAD \
		-I$(API_DIR) -I$(API_DIR)/hss -I$(API_DIR)/tcp_udp

endif #IA

ifeq ($(SRTP_ENABLED), true)
CFLAGS += -I$(SRTP_BASE)/include -I$(SRTP_BASE)/crypto/include -DSRTP -DSRTP_ACCEL_FLAG -I$(API_DIR)/accel_infra
endif

KERNEL_VER = 2_6_18

DEVICE = IA

 FOUNDATION_LIB_PATH = $(ADS_BASE_DIR)/lib/$(DEVICE)/$(KERNEL_VER)/Foundation
 PLUGINS_LIB_PATH = $(ADS_BASE_DIR)/lib/$(DEVICE)/$(KERNEL_VER)/Codec

 CODEC_PLUGINS = -lusc
 CODEC_CORE_LIB = -lippsc -lipps -lippcore

#DEFAULT_FOUNDATION_LIB = -ldsp -llec

ifeq ($(IX_DEVICE),ia)
LDFLAGS = -lpthread -ldl -lrt -L/usr/lib/ -lasound \
		-L$(FOUNDATION_LIB_PATH) -ldsp -L$(ADS_BASE_DIR)/lib -lplug -L$(FOUNDATION_LIB_PATH) -llec\
		-L$(FOUNDATION_LIB_PATH) -losal \
                -L$(PLUGINS_LIB_PATH) $(CODEC_PLUGINS) -L$(IPP_CODEC_ROOT_PATH) $(CODEC_CORE_LIB)

endif



############################################################################
# list of files
############################################################################
OUTPUT_NAME = dspApp

# list of C files
C_FILES = \
	IxDspCodeletMain.c \
    IxDspCodeletALSA.c \
	IxDspCodeletInit.c \
	IxDspCodeletMenu.c \
	IxDspCodeletCidBc.c \
	IxDspCodeletMsgPrint.c \
	IxDspCodelet3WCall.c \
	IxDspCodeletDiag.c \
	IxDspCodeletPlay.c \
	IxDspCodeletAddTone.c \
	IxDspCodeletAudioData1.c \
	IxDspCodeletAudioData2.c \
	IxDspCodeletUsrMsg.c \
	IxDspCodeletSocket.c \
	IxDspCodeletAppOsslLib.c \
	IxDspCodeletApp.c

# list of object files
O_FILES := $(C_FILES:.c=.o)

############################################################################
# default 
############################################################################

default: dspApp

############################################################################
# Rules for building files/dependencies
############################################################################

# Rule for compiling (always first)
%.o: %.c
	$(CC) $(CFLAGS) $< -c -o $@

# Rule for building dependencies from source (always second)
%.d: %.c
	$(CC) -M $(CFLAGS) -DIX_GENERATING_DEPENDENCIES $< > $@ 

############################################################################
# Automatic source file dependencies
############################################################################

# include the dependencies (always third)
D_FILES := $(O_FILES:.o=.d)
include $(D_FILES)

############################################################################
# targets 
############################################################################

.PHONY: dspApp
dspApp: $(O_FILES)
	$(CC) $(O_FILES) -o IxDspCodeletApp  $(LDFLAGS) 


clean: 
	rm -f $(O_FILES) $(D_FILES) IxDspCodeletApp
	rm -f *.o *.d ../*.o ../*.d

