From a31222acbaf11e77ab9cdd8e6e9164b160d2235b Mon Sep 17 00:00:00 2001
From: Mathieu Rene <mrene@avgs.ca>
Date: Mon, 19 Jul 2010 16:10:10 -0400
Subject: [PATCH] mod_hash: fix build

---
 configure.in                              |  1 +
 src/mod/applications/mod_hash/Makefile    |  4 ----
 src/mod/applications/mod_hash/Makefile.am | 13 +++++++++++++
 src/mod/applications/mod_hash/mod_hash.c  | 11 ++++++-----
 4 files changed, 20 insertions(+), 9 deletions(-)
 delete mode 100644 src/mod/applications/mod_hash/Makefile
 create mode 100644 src/mod/applications/mod_hash/Makefile.am

diff --git a/configure.in b/configure.in
index b643d69d7a..8d2307640b 100644
--- a/configure.in
+++ b/configure.in
@@ -899,6 +899,7 @@ AC_CONFIG_FILES([Makefile
 		src/mod/applications/mod_fax/Makefile
 		src/mod/applications/mod_spandsp/Makefile
 		src/mod/applications/mod_stress/Makefile
+		src/mod/applications/mod_hash/Makefile
 		src/mod/endpoints/mod_portaudio/Makefile
 		src/mod/endpoints/mod_skinny/Makefile
 		src/mod/endpoints/mod_skypopen/Makefile
diff --git a/src/mod/applications/mod_hash/Makefile b/src/mod/applications/mod_hash/Makefile
deleted file mode 100644
index 0ee5f7731f..0000000000
--- a/src/mod/applications/mod_hash/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_CFLAGS=-I../../../../libs/esl/src/include
-LOCAL_LDFLAGS=-L../../../../libs/esl -lesl
-BASE=../../../..
-include $(BASE)/build/modmake.rules
diff --git a/src/mod/applications/mod_hash/Makefile.am b/src/mod/applications/mod_hash/Makefile.am
new file mode 100644
index 0000000000..2a28c1d9ab
--- /dev/null
+++ b/src/mod/applications/mod_hash/Makefile.am
@@ -0,0 +1,13 @@
+include $(top_srcdir)/build/modmake.rulesam
+
+MODNAME=mod_hash
+ESL_DIR=$(switch_srcdir)/libs/esl
+
+mod_LTLIBRARIES = mod_hash.la
+mod_hash_la_SOURCES  = mod_hash.c
+mod_hash_la_CFLAGS   = $(AM_CFLAGS) -I$(ESL_DIR)/src/include
+mod_hash_la_LIBADD   = $(switch_builddir)/libfreeswitch.la $(ESL_DIR)/libesl.so
+mod_hash_la_LDFLAGS  = -avoid-version -module -no-undefined -shared -L$(ESL_DIR) -lesl
+
+$(ESL_DIR)/libesl.so:
+	cd $(ESL_DIR) && $(MAKE) -j1
diff --git a/src/mod/applications/mod_hash/mod_hash.c b/src/mod/applications/mod_hash/mod_hash.c
index 4822f0ca08..c0e8b55c15 100644
--- a/src/mod/applications/mod_hash/mod_hash.c
+++ b/src/mod/applications/mod_hash/mod_hash.c
@@ -744,16 +744,16 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
 	while (remote->state > REMOTE_OFF) {
 		if (remote->state != REMOTE_UP) {
 			if  (esl_connect(&remote->handle, remote->host, remote->port, remote->username, remote->password) == ESL_SUCCESS) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to remote FreeSWITCH at %s:%d\n",
-					remote->host, remote->port);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to remote FreeSWITCH (%s) at %s:%d\n",
+					remote->name, remote->host, remote->port);
 				
 				remote->state = REMOTE_UP;
 			}
 		} else {
 			if (esl_send_recv(&remote->handle, "api hash_dump limit") != ESL_SUCCESS) {
 				esl_disconnect(&remote->handle);
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Disconnected from remote FreeSWITCH at %s:%d\n",
-					remote->host, remote->port);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Disconnected from remote FreeSWITCH (%s) at %s:%d\n",
+					remote->name, remote->host, remote->port);
 				memset(&remote->handle, 0, sizeof(remote->handle));
 				remote->state = REMOTE_DOWN;
 				/* Delete all remote tracking entries */
@@ -780,7 +780,8 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
 							int argc = switch_split(p+2, '/', argv);
 							
 							if (argc < 5) {
-								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Protocol error: missing argument in line: %s\n", p);
+								switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "[%s] Protocol error: missing argument in line: %s\n", 
+									remote->name, p);
 							} else {
 								limit_hash_item_t *item;
 								switch_thread_rwlock_wrlock(remote->rwlock);