#
# Makefile for SBC Codec Plugin
#
# Copyright (C) 2008 Christian Hoene, All Rights Reserved
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is Open H323 library.
#
# The Initial Developer of the Original Code is Christian Hoene
#
# Contributor(s): ______________________________________.
#
# $Log: Makefile.in,v $
#

AC_PLUGIN_DIR=opal-3.5.2/codecs/audio
prefix=/home/robertj/opal
exec_prefix=${prefix}
libdir=${exec_prefix}/lib

SRCDIR	= .
PLUGINDIR=../..
SONAME	= sbccodec
SAMPLERATELIB = -Lsamplerate

CC	 	=gcc
CFLAGS	 	= -Os  
CXXFLAGS 	= -Os  
CXX	 	=g++
LDSO	 	=-shared -Wl,-soname,$(SONAME)
PLUGINEXT	=so
STDCCFLAGS	= -fPIC -DSBC_DISABLE_PTLIB=1 -DOPAL_G711PLC=1
LDFLAGS		=

SBC_CFLAGS	=@SBC_CFLAGS@
SBC_LIBS	=@SBC_LIBS@

SBC_SYSTEM= @SBC_SYSTEM@

SRCS   = $(SRCDIR)/sbccodec.cxx \
	 $(SRCDIR)/sbc.c \
	 $(SRCDIR)/g711a1_plc.cxx 

EXTRACCFLAGS	= -I$(PLUGINDIR)
EXTRALIBS 	= $(SAMPLERATE_LIB)

OBJDIR	= ./obj

vpath	%.o $(OBJDIR)
vpath	%.c $(SRCDIR)
vpath	%.cxx $(SRCDIR)

$(OBJDIR)/%.o : %.c
	@mkdir -p $(OBJDIR) >/dev/null 2>&1
	$(CC) -c $(STDCCFLAGS) $(CFLAGS) $(EXTRACCFLAGS) -o $@ $<

$(OBJDIR)/%.o : %.cxx
	@mkdir -p $(OBJDIR) >/dev/null 2>&1
	$(CXX) -c -I../../../include $(STDCCFLAGS) $(CXXFLAGS) $(EXTRACCFLAGS) -o $@ $<

PLUGIN	= ./sbc_audio_ptplugin.$(PLUGINEXT)

OBJECTS	= $(addprefix $(OBJDIR)/,$(patsubst %.cxx,%.o,$(patsubst %.c,%.o,$(notdir $(SRCS)))))

$(PLUGIN): $(OBJECTS)
	$(CXX) $(LDSO) -o $@ $^ $(EXTRALIBS)

$(SRCDIR)/g711a1_plc.cxx: ../../../src/codec/g711a1_plc.cxx
	ln -s ../../../src/codec/g711a1_plc.cxx $(SRCDIR)/g711a1_plc.cxx

install:
	mkdir -p $(DESTDIR)$(libdir)/$(AC_PLUGIN_DIR)
	install $(PLUGIN) $(DESTDIR)$(libdir)/$(AC_PLUGIN_DIR)

uninstall:
	rm -f $(DESTDIR)$(libdir)/$(AC_PLUGIN_DIR)/$(PLUGIN)

clean:
	rm -f $(OBJECTS) $(PLUGIN)

distclean: clean
	rm -f Makefile g711a1_plc.cxx

###########################################
