#
# Copyright (C) 2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=sofia-sip
PKG_VERSION:=1.12.11
PKG_RELEASE:=1

PKG_SOURCE:=sofia-sip-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/sofia-sip/
PKG_MD5SUM:=f3582c62080eeecd3fa4cd5d4ccb4225

PKG_BUILD_DIR=$(BUILD_DIR)/sofia-sip-$(PKG_VERSION)

PKG_INSTALL:=1

# Dependencies from other packages
PKG_BUILD_DEPENDS += PACKAGE_libopenssl:libopenssl



include $(INCLUDE_DIR)/package.mk



#
# Package defaults
#

# Defaults for all packages
define Package/sofia-sip/Default
  URL:=http://sourceforge.net/projects/sofia-sip
  MAINTAINER:=Arnold Schulz <theosch@gmx.net>
endef
      
define Package/sofia-sip/description/Default
  Sofia-SIP is an open-source SIP User-Agent library, compliant with the IETF
  RFC3261 specification.
  It can be used as a building block for SIP client software for uses such as
  VoIP, IM, and many other real-time and person-to-person communication services.
  The primary target platform for Sofia-SIP is GNU/Linux. Sofia-SIP is based on
  a SIP stack developed at the Nokia Research Center.
  Sofia-SIP is licensed under the LGPL.

endef



#
#  Our packages
#

define Package/libsofia-sip-ua
  $(call Package/sofia-sip/Default)
  SUBMENU:=Telephony
  SECTION:=lib
  CATEGORY:=Libraries
  TITLE:=Sofia SIP User Agent Library
  DEPENDS:=+libpthread +PACKAGE_libopenssl:libopenssl
endef

        
define Package/libsofia-sip-ua/description
  $(call Package/sofia-sip/description/Default)
  This package provides the libraries needed by some programs using the SIP protocol.

  Note that libsofia-sip-ua is compiled for openssl support iff package libopenssl is enabled.
endef
            

            
define Package/sofia-sip-bin
  $(call Package/sofia-sip/Default)
  SUBMENU:=Telephony
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Sofia SIP tools
  DEPENDS:=+libsofia-sip-ua
endef


define Package/sofia-sip-bin/description
  $(call Package/sofia-sip/description/Default)
  This package provides a set of console tools and helper applications for use in
  scripts, testing and other uses. All the tools utilize the Sofia-SIP library.

endef
            

#
#  Specialities for configuring and building
#

define Build/Configure
	$(call Build/Configure/Default,						\
		$(if $(PACKAGE_libopenssl),--with-openssl,--without-openssl) 	\
	)
endef

            
#
#  Installation of files possibly required by other packages for
#  package building (i.e. not required at runtime).
#

define Build/InstallDev
	$(INSTALL_DIR)  $(1)/usr/lib
	$(CP)  -r  $(PKG_INSTALL_DIR)/usr/lib/libsofia-*	$(1)/usr/lib/
	$(INSTALL_DIR)  $(1)/usr/lib/pkgconfig
	$(CP)  -r  $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/sofia-*	$(1)/usr/lib/pkgconfig
	$(INSTALL_DIR)  $(1)/usr/include
	$(CP)  -r  $(PKG_INSTALL_DIR)/usr/include/sofia-*	$(1)/usr/include/
endef


# Assumed not longer neccessary (done automaticaly!?!)
#define Build/UninstallDev
#	rm -rf	$(1)/usr/lib/libsofia-*			\
#		$(1)/usr/lib/pkgconfig/sofia-*		\
#		$(1)/usr/include/sofia-*
#endef
                                                        
                                                                
#
#  Installation of runtime files.
#

define Package/libsofia-sip-ua/install
	$(INSTALL_DIR)  $(1)/usr/lib
	$(CP)  $(PKG_INSTALL_DIR)/usr/lib/libsofia-sip-ua.so*	$(1)/usr/lib/
endef


define Package/sofia-sip-bin/install
	$(INSTALL_DIR)  $(1)/usr/bin
	$(CP)  $(PKG_INSTALL_DIR)/usr/bin/*			$(1)/usr/bin/
endef





$(eval $(call BuildPackage,libsofia-sip-ua))
$(eval $(call BuildPackage,sofia-sip-bin))

