# ============================================================================
# Makefile	WAN Echo Canceler Chip configurator.  Make Script.
#
# Copyright	(c) 1995-1997 Sangoma Technologies Inc.  All Rights Reserved.
# ----------------------------------------------------------------------------
# Augc 25, 2005		Alex Feldman	Initial version.
# ============================================================================

####### DEFINES ##############################################################

# Build Options.
PROD	= wan_oct6100_setup
VERSION	= 1.0
DEBUG	= 2
YACC	= byacc

# Project File Paths.
TMPDIR	= tmp
OUTDIR	= mod/ 
LOCINC	= /usr/src/linux/include
VPATH	= $(LOCINC):$(TMPDIR)
ARCH    = $(shell uname -m)
WAN_OCT6100_LIB_DIR = .
WAN_OCT6100_DAEMON = YES

CFLAGS	= -Wall -O2 -D__LINUX__ -DCONFIG_PRODUCT_WANPIPE_TDMV_EC -D_DEBUG_=$(DEBUG) -D_GNUC_ -I$(LOCINC) -Ioct6100_api/include

LDFLAGS=-L$(WAN_OCT6100_LIB_DIR) -loct6100api

ifeq "${WAN_OCT6100_DAEMON}" "YES"
PRODS=wan_oct6100_lib wan_oct6100_client wan_oct6100d
CFLAGS+=-DWAN_OCT6100_DAEMON
else
PRODS=wan_oct6100_lib wan_oct6100_setup
endif


####### RULES ################################################################

all:	wan_oct6100_lib wan_oct6100_setup 
	@echo "Ok."

wan_oct6100_lib:
	@$(MAKE) -r -C oct6100_api/octdeviceapiw/oct6100_apiw_linux/ -f oct6100api.mak

wan_oct6100_setup:	wan_ecmain.c wan_oct6100.c wan_oct6100api.c
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

install:
	@echo "Installing Wanpipe OCT6100 API in $(WAN_VIRTUAL)/usr/sbin"
	\cp -f image/OCT6126-128S.ima /etc/wanpipe/oct6100/
	install -D $(PROD) $(WAN_VIRTUAL)/usr/sbin/$(PROD)

uninstall:
	@echo "Un-installing Wanpipe OCT6100 API from $(WAN_VIRTUAL)/usr/sbin"
	rm -f $(WAN_VIRTUAL)/usr/sbin/$(PROD)

clean:
	rm -f $(PROD)
	@$(MAKE) -r -C oct6100_api/octdeviceapiw/oct6100_apiw_linux/ -f oct6100api.mak clean
