diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/Makefile.am plugin/HandlerSocket/Makefile.am
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/Makefile.am	2011-01-01 23:59:13.000000000 +0100
+++ plugin/HandlerSocket/Makefile.am	2011-01-04 18:07:42.000000000 +0100
@@ -2,6 +2,7 @@
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = @HANDLERSOCKET_SUBDIRS@
+EXTRA_DIST= plug.in
 
 perl:
 	cd perl-Net-HandlerSocket && perl Makefile.PL && make
diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/client/Makefile.am plugin/HandlerSocket/client/Makefile.am
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/client/Makefile.am	2011-01-01 23:59:13.000000000 +0100
+++ plugin/HandlerSocket/client/Makefile.am	2011-01-04 18:55:03.000000000 +0100
@@ -1,4 +1,5 @@
-AM_INCLUDES= -I../libhsclient
+CXXFLAGS += -fimplicit-templates
+AM_INCLUDES= -I$(srcdir)/../libhsclient
 bin_PROGRAMS=hsclient 
 hsclient_SOURCES= hsclient.cpp
 hsclient_LDFLAGS= -static -L../libhsclient -lhsclient
diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/handlersocket/Makefile.am plugin/HandlerSocket/handlersocket/Makefile.am
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/handlersocket/Makefile.am	2011-01-01 23:59:13.000000000 +0100
+++ plugin/HandlerSocket/handlersocket/Makefile.am	2011-01-04 18:54:46.000000000 +0100
@@ -1,10 +1,11 @@
+CXXFLAGS += -fimplicit-templates
 pkgplugindir =  $(PLUGIN_DIR)
 noinst_HEADERS = database.hpp hstcpsvr.hpp hstcpsvr_worker.hpp mysql_incl.hpp
 pkgplugin_LTLIBRARIES = handlersocket.la
 handlersocket_la_LDFLAGS = -module ../libhsclient/libhsclient.la
 handlersocket_la_CFLAGS = $(MYSQL_INC) $(MYSQL_CFLAGS) $(AM_CFLAGS) \
-	-I../libhsclient
+	-I$(srcdir)/../libhsclient
 handlersocket_la_CXXFLAGS = $(MYSQL_INC) $(MYSQL_CFLAGS) $(AM_CFLAGS) \
-	-I../libhsclient
+	-I$(srcdir)/../libhsclient
 handlersocket_la_SOURCES = database.cpp handlersocket.cpp \
 	hstcpsvr_worker.cpp hstcpsvr.cpp
diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/handlersocket/database.cpp plugin/HandlerSocket/handlersocket/database.cpp
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/handlersocket/database.cpp	2011-01-01 23:59:13.000000000 +0100
+++ plugin/HandlerSocket/handlersocket/database.cpp	2011-01-04 15:05:04.000000000 +0100
@@ -779,19 +779,19 @@
   for (uint32_t i = 0; i < limit + skip; ++i) {
     if (i == 0) {
       const key_part_map kpm = (1U << args.kvalslen) - 1;
-      r = hnd->index_read_map(table->record[0], key_buf, kpm, find_flag);
+      r = hnd->ha_index_read_map(table->record[0], key_buf, kpm, find_flag);
     } else {
       switch (find_flag) {
       case HA_READ_BEFORE_KEY:
       case HA_READ_KEY_OR_PREV:
-	r = hnd->index_prev(table->record[0]);
+	r = hnd->ha_index_prev(table->record[0]);
 	break;
       case HA_READ_AFTER_KEY:
       case HA_READ_KEY_OR_NEXT:
-	r = hnd->index_next(table->record[0]);
+	r = hnd->ha_index_next(table->record[0]);
 	break;
       case HA_READ_KEY_EXACT:
-	r = hnd->index_next_same(table->record[0], key_buf, kplen_sum);
+	r = hnd->ha_index_next_same(table->record[0], key_buf, kplen_sum);
 	break;
       default:
 	r = HA_ERR_END_OF_FILE; /* to finish the loop */
diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/libhsclient/Makefile.am plugin/HandlerSocket/libhsclient/Makefile.am
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/libhsclient/Makefile.am	2011-01-01 23:59:13.000000000 +0100
+++ plugin/HandlerSocket/libhsclient/Makefile.am	2011-01-04 17:03:19.000000000 +0100
@@ -1,3 +1,4 @@
+CXXFLAGS += -fimplicit-templates
 instdir = $(includedir)/handlersocket
 # TODO: these headers should be in dena/
 inst_HEADERS = allocator.hpp config.hpp mutex.hpp string_util.hpp \
@@ -7,6 +8,6 @@
 lib_LTLIBRARIES = libhsclient.la
 libhsclient_la_SOURCES = config.cpp escape.cpp fatal.cpp hstcpcli.cpp \
 	socket.cpp string_util.cpp
-libhsclient_la_LDFLAGS = -static
+#libhsclient_la_LDFLAGS = -static
 libhsclient_la_CFLAGS = $(AM_CFLAGS) 
 libhsclient_la_CXXFLAGS = $(AM_CFLAGS) 
diff -ru plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/plug.in plugin/HandlerSocket/plug.in
--- plugin/ahiguti-HandlerSocket-Plugin-for-MySQL-34cb96a/plug.in	2011-01-04 17:30:24.000000000 +0100
+++ plugin/HandlerSocket/plug.in	2011-01-04 17:33:22.000000000 +0100
@@ -0,0 +1,19 @@
+MYSQL_PLUGIN(handlersocket, [HandlerSocket], [HandlerSocket], [max])
+MYSQL_PLUGIN_DYNAMIC(handlersocket, handlersocket.la)
+MYSQL_PLUGIN_ACTIONS(handlersocket,
+[
+  ac_mysql_source_dir='$(top_srcdir)'
+  MYSQL_INC="-I$ac_mysql_source_dir/sql"
+  MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/include"
+  MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/regex"
+  MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir"
+  MYSQL_LIB='-L$(top_builddir)/libservices -lmysqlservices'
+  PLUGIN_DIR='$(pkglibdir)/plugin'
+  HANDLERSOCKET_SUBDIRS="libhsclient handlersocket client"
+
+  AC_SUBST(MYSQL_INC)
+  AC_SUBST(MYSQL_CFLAGS)
+  AC_SUBST(MYSQL_LIB)
+  AC_SUBST(PLUGIN_DIR)
+  AC_SUBST(HANDLERSOCKET_SUBDIRS)
+])
