#
# Makefile for Voicetronics VPB LID plugin
#
# Copyright (C) 2006 Post Increment, 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 OPAL.
#
# The Initial Developer of the Original Code is Post Increment
#
# Contributor(s): ______________________________________.
#
# $Log: Makefile.in,v $
# Revision 1.5  2007/09/05 11:52:55  csoutheren
# Fix compilation on MacOSX
#
# Revision 1.4  2007/04/19 06:09:03  csoutheren
# Fixed plugin build system to use better detection for OSX
# Resolved 1636262 - Fix for audio plugins for OSX
#
# Revision 1.3  2006/10/10 01:42:54  csoutheren
# Applied patches from Ekiga bug 360869 - fix OpenSolaris build problems
# Thanks to Boying Lu
#
# Revision 1.2  2006/10/04 04:21:16  rjongbloed
# Fixed VPB plug in build under linux
#
# Revision 1.1  2006/10/02 13:30:53  rjongbloed
# Added LID plug ins
#
#

STDCCFLAGS += -fPIC -fPIC

PREFIX=/usr/local
exec_prefix = ${PREFIX}
LIBDIR=${exec_prefix}/lib

CC=gcc
CXX=g++
LDSO=-shared -Wl,-soname,$(SONAME)
PLUGINEXT=so

ifndef PREFIX
PREFIX=/usr/local
endif

SONAME	= vpb

ifndef OSTYPE
OSTYPE := $(shell uname -s)
endif

ifndef MACHTYPE
MACHTYPE := $(shell uname -m)
endif

ifneq (,$(findstring macos,$(OSTYPE)))
OSTYPE := Darwin
endif

ifeq ($(OSTYPE),darwin)
  OSTYPE := Darwin
endif

ifeq ($(OSTYPE),Darwin)
  # MacOS X or later / Darwin
	
  CFLAGS          += -fno-common -dynamic
  LDFLAGS         += -multiply_defined suppress
  STDCCFLAGS  	+= -D__MACOSX__
	 
  ifeq ($(MACHTYPE),x86)
    STDCCFLAGS      += -m486
  endif
	
  LDSO = -dynamiclib  -multiply_defined suppress 
  SONAME	= 
  PLUGINEXT     = dylib
endif # Darwin

SRCDIR	= ./src
OBJDIR	= ./obj

SRCS	+= vpb.cpp

vpath	%.o $(OBJDIR)
vpath	%.cpp $(SRCDIR)

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

PLUGIN	= ./vpb_lid_pwplugin.$(PLUGINEXT)

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

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

install:
	mkdir -p $(DESTDIR)$(LIBDIR)/ptlib/lid/
	cp $(PLUGIN) $(DESTDIR)$(LIBDIR)/ptlib/lid/

uninstall:
	rm -f $(DESTDIR)$(LIBDIR)/ptlib/lid/$(PLUGIN)

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

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