tags 570506 +patch
thanks

> Could this package support libstemmer_c? (so the libstemmer contents 
> extracted over libstemmer_c

I agree with this request but the Debian proper way to do it is to use the 
Debian packaged version of libstemmer.

This requires two patches to be applied:
1) Enable sphinxsearch to search for libstemmer in the system locations, not 
only locally. This patch is available from 
http://sphinxsearch.com/bugs/view.php?id=180 and I'm attaching them aswell. 
After patching you need to rerun autoconf/automake.
2) Add the build dependency and the configure switch.


I have built and tested packages with these patches and they work great.
Please consider.


Thanks,
Thijs
diff -burN sphinx-0.9.8.orig/acinclude.m4 sphinx-0.9.8/acinclude.m4
--- sphinx-0.9.8.orig/acinclude.m4	2008-08-03 02:22:01.000000000 +0200
+++ sphinx-0.9.8/acinclude.m4	2008-08-05 03:57:54.000000000 +0200
@@ -254,6 +254,83 @@
 ])
 
 dnl ---------------------------------------------------------------------------
+dnl Macro: AC_CHECK_LIBSTEMMER
+dnl Author: Adam Golebiowski <[email protected]>
+dnl First check for custom libstemmer include path in --with-libstemmer=* option
+dnl If not given, try to guess.
+dnl ---------------------------------------------------------------------------
+
+AC_DEFUN([AC_CHECK_LIBSTEMMER],[
+
+# cflags and libs
+LIBSTEMMER_CFLAGS=
+LIBSTEMMER_LIBS=
+
+# possible includedir paths
+includedirs="/usr/include /usr/include/libstemmer /usr/include/libstemmer_c"
+
+# possible libdirs -- 64bit first in case of multiarch environments
+libdirs="/usr/lib64 /usr/local/lib64 /usr/lib /usr/local/lib"
+
+# possible libnames -- shared one first, then static one
+libnames="stemmer stemmer_c"
+
+# was (include) path explicitely given?
+if test [ -n "$ac_cv_use_libstemmer" -a x$ac_cv_use_libstemmer != xyes]; then
+	includedirs=$ac_cv_use_libstemmer
+fi
+
+# try to find header files
+for includedir in $includedirs
+do
+	if test [ -f $includedir/libstemmer.h ]; then
+		LIBSTEMMER_CFLAGS="-I$includedir"
+		break
+	fi
+done
+
+# try to find shared library
+for libname in $libnames
+do
+	for libdir in $libdirs
+	do
+		if test [ -f $libdir/lib${libname}.so ]; then
+			LIBSTEMMER_LIBS="-L$libdir -l$libname"
+			break 2
+		fi
+	done
+done
+
+# if not found, check static libs
+if test [ -z "$LIBSTEMMER_LIBS" ]; then
+	for libname in $libnames
+	do
+		for libdir in $libdirs
+		do
+			if test [ -f $libdir/lib${libname}.a ]; then
+				LIBSTEMMER_LIBS="$libdir/lib${libname}.a"
+				break 2
+			fi
+		done
+	done
+fi
+
+# if LIBSTEMMER_LIBS is not set at this moment,
+# our last chanceis to check for existance of internal copy of libstemmer_c
+# in case it doesn't exist -- we lost
+if test [ -z "$LIBSTEMMER_LIBS" ]; then
+	if test [ -d ./libstemmer_c ]; then
+		ac_cv_use_internal_libstemmer=1
+		LIBSTEMMER_LIBS="\$(top_srcdir)/libstemmer_c/libstemmer.a"
+		LIBSTEMMER_CFLAGS="-I\$(top_srcdir)/libstemmer_c/include"
+	else
+		AC_MSG_ERROR([not found])
+	fi
+fi
+
+])
+
+dnl ---------------------------------------------------------------------------
 dnl Macro: SPHINX_CONFIGURE_PART
 dnl
 dnl Tells what stage is ./configure running now, nicely formatted
diff -burN sphinx-0.9.8.orig/configure.ac sphinx-0.9.8/configure.ac
--- sphinx-0.9.8.orig/configure.ac	2008-08-03 02:22:01.000000000 +0200
+++ sphinx-0.9.8/configure.ac	2008-08-05 03:26:57.000000000 +0200
@@ -142,9 +142,6 @@
 AM_CONDITIONAL(USE_PGSQL, test x$ac_cv_use_pgsql != xno)
 
 
-# we can now set preprocessor flags for both C and C++ compilers
-CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS $PGSQL_CFLAGS"
-
 dnl ---
 
 AC_MSG_CHECKING([whether to use 64-bit document/word IDs])
@@ -169,22 +166,23 @@
 
 AC_MSG_CHECKING([whether to compile with libstemmer support])
 if test x$ac_cv_use_libstemmer != xno; then
-	if test -d libstemmer_c && test -f libstemmer_c/include/libstemmer.h; then
+	ac_cv_use_internal_libstemmer=0
 		AC_MSG_RESULT([yes])
-		AC_DEFINE(USE_LIBSTEMMER, 1, [libstemmer support])
-	else
-		AC_MSG_ERROR([missing libstemmer sources from libstemmer_c.
-
-Please download the C version of libstemmer library from
-http://snowball.tartarus.org/ and extract its sources over libstemmer_c/
-subdirectory in order to build Sphinx with libstemmer support.
-])
-	fi
+	AC_CHECK_LIBSTEMMER([$ac_cv_use_listemmer])
+	AC_DEFINE(USE_LIBSTEMMER, 1, [Define to 1 if you want to compile with libstemmer support])
+	AC_DEFINE(USE_INTERNAL_LIBSTEMMER, $ac_cv_use_internal_libstemmer, [Define to 1 if you want to compile with internal libstemmer library])
+	AC_SUBST([LIBSTEMMER_LIBS])
+	AC_SUBST([LIBSTEMMER_CFLAGS])
 else
 	AC_MSG_RESULT([no])
-	AC_DEFINE(USE_LIBSTEMMER, 0, [libstemmer support])
 fi
 AM_CONDITIONAL(USE_LIBSTEMMER, test x$ac_cv_use_libstemmer != xno)
+AM_CONDITIONAL(USE_INTERNAL_LIBSTEMMER, test x$ac_cv_use_internal_libstemmer != x0)
+
+dnl ---
+
+# we can now set preprocessor flags for both C and C++ compilers
+CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS $PGSQL_CFLAGS $LIBSTEMMER_CFLAGS"
 
 dnl ---
 
diff -burN sphinx-0.9.8.orig/Makefile.am sphinx-0.9.8/Makefile.am
--- sphinx-0.9.8.orig/Makefile.am	2008-08-03 02:22:01.000000000 +0200
+++ sphinx-0.9.8/Makefile.am	2008-08-03 02:56:01.000000000 +0200
@@ -1,4 +1,4 @@
-if USE_LIBSTEMMER
+if USE_INTERNAL_LIBSTEMMER
 SUBDIRS = libstemmer_c src test
 else
 SUBDIRS = src test
diff -burN sphinx-0.9.8.orig/src/Makefile.am sphinx-0.9.8/src/Makefile.am
--- sphinx-0.9.8.orig/src/Makefile.am	2008-08-03 02:22:01.000000000 +0200
+++ sphinx-0.9.8/src/Makefile.am	2008-08-03 12:32:28.000000000 +0200
@@ -19,13 +19,7 @@
 extract-version:
 	if test -d ../.svn; then svn info .. --xml | perl svnxrev.pl; fi;
 
-if USE_LIBSTEMMER
-LIBSTEMMER_LIBS = $(top_srcdir)/libstemmer_c/libstemmer.a
-AM_CPPFLAGS = -I$(top_srcdir)/libstemmer_c/include -DSYSCONFDIR="\"$(sysconfdir)\""
-else
-LIBSTEMMER_LIBS =
 AM_CPPFLAGS = -DSYSCONFDIR="\"$(sysconfdir)\""
-endif
 
 COMMON_LIBS = libsphinx.a $(LIBSTEMMER_LIBS) $(MYSQL_LIBS) $(PGSQL_LIBS)
 LDADD = $(COMMON_LIBS)
diff -burN sphinx-0.9.8.orig/src/sphinx.cpp sphinx-0.9.8/src/sphinx.cpp
--- sphinx-0.9.8.orig/src/sphinx.cpp	2008-08-03 02:22:01.000000000 +0200
+++ sphinx-0.9.8/src/sphinx.cpp	2008-08-03 02:22:11.000000000 +0200
@@ -31,7 +31,7 @@
 #include <float.h>
 
 #if USE_LIBSTEMMER
-#include "libstemmer.h"
+#include <libstemmer.h>
 #endif
 
 #if USE_LIBEXPAT
diff -u sphinxsearch-0.9.9/debian/rules sphinxsearch-0.9.9/debian/rules
--- sphinxsearch-0.9.9/debian/rules
+++ sphinxsearch-0.9.9/debian/rules
@@ -30,7 +30,7 @@
 config.status: configure
 	dh_testdir
 	# Add here commands to configure the package.
-	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --localstatedir=/var/lib/sphinxsearch --sysconfdir=/etc/sphinxsearch --with-pgsql CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
+	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --localstatedir=/var/lib/sphinxsearch --sysconfdir=/etc/sphinxsearch --with-libstemmer --with-pgsql CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
 
 build: patch build-stamp
 
diff -u sphinxsearch-0.9.9/debian/control sphinxsearch-0.9.9/debian/control
--- sphinxsearch-0.9.9/debian/control
+++ sphinxsearch-0.9.9/debian/control
@@ -2,7 +2,7 @@
 Section: misc
 Priority: optional
 Maintainer: Radu Spineanu <[email protected]>
-Build-Depends: debhelper (>= 7), autotools-dev, gawk, libmysqlclient-dev, dpatch, libpq-dev, autoconf, libtool, automake, docbook-to-man, libexpat-dev
+Build-Depends: debhelper (>= 7), autotools-dev, gawk, libmysqlclient-dev, dpatch, libpq-dev, autoconf, libtool, automake, docbook-to-man, libexpat-dev, libstemmer-dev
 Standards-Version: 3.8.3
 
 Package: sphinxsearch

Reply via email to