#
# Copyright (C) 2010-2012 Jo-Philipp Wich <jow@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:=sphinx
PKG_VERSION:=2.2.2
PKG_REVISION:=4446
PKG_SUFFIX:=stemmer
PKG_RELEASE=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REVISION)-$(PKG_SUFFIX).tar.gz
PKG_MAINTAINER:=Aleksey Vinogradov <klirichek@sphinxsearch.com>
PKG_SOURCE_URL:=http://klirik.dyndns.org/r/sphinxsearch
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REVISION)-$(PKG_SUFFIX)

include $(INCLUDE_DIR)/package.mk

define Package/sphinx
  SECTION:=net
  CATEGORY:=Network
  SUBMENU:=Web Servers/Proxies
  TITLE:=sphinxsearch - fast FT search engine server
  DEPENDS:=+libstdcpp +libmysqlclient +libpthread +librt
endef

define Package/sphinx/conffiles
  /etc/sphinxsearch/sphinx.conf
endef

define Package/sphinx/description
 This is placeholder for sphinxsearch description
endef

CONFIGURE_VARS += \
	ac_cv_func_realloc_0_nonnull=yes \
	ac_cv_func_malloc_0_nunnul=yes \
	sphinx_cv_unaligned_ram_access=yes

CONFIGURE_ARGS += \
	--prefix=/ \
	--sysconfdir=/etc/sphinx \
	--with-mysql \
	--without-unixodbc \
	--without-libexpat \
	--with-syslog \
	--with-libstemmer \
	--enable-dl

define Package/sphinx/install
	$(INSTALL_DIR) $(1)/etc/sphinx
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/searchd $(1)/usr/sbin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/indexer $(1)/usr/sbin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/indextool $(1)/usr/sbin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/spelldump $(1)/usr/sbin/
endef

$(eval $(call BuildPackage,sphinx))
