[asterisk-commits] kpfleming: trunk r370481 - in /trunk: ./ build_tools/ contrib/scripts/ includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 25 07:22:04 CDT 2012


Author: kpfleming
Date: Wed Jul 25 07:21:54 2012
New Revision: 370481

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370481
Log:
Enable usage of system-provided NetBSD editline library if available.

This patch changes the Asterisk configure script and build system to detect
the presence of the NetBSD editline library (libedit) on the system. If it is
found, it will be used in preference to the version included in the Asterisk
source tree.

(closes issue ASTERISK-18725)
Reported by: Jeffrey C. Ollie
Review: https://reviewboard.asterisk.org/r/1528/
Patches:
  0001-Allow-linking-building-against-an-external-editline.patch uploaded by jcollie (license #5373)


Added:
    trunk/main/editline/readline.h
      - copied unchanged from r370452, trunk/main/editline/readline/readline.h
Removed:
    trunk/main/editline/readline/
Modified:
    trunk/CHANGES
    trunk/build_tools/menuselect-deps.in
    trunk/configure
    trunk/configure.ac
    trunk/contrib/scripts/install_prereq
    trunk/include/asterisk/autoconfig.h.in
    trunk/main/Makefile
    trunk/main/asterisk.c
    trunk/main/cli.c
    trunk/main/editline/configure
    trunk/main/editline/configure.in
    trunk/main/editline/readline.c
    trunk/makeopts.in

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Jul 25 07:21:54 2012
@@ -399,6 +399,8 @@
    CONNECTED_LINE_SEND_SUB_ARGS.  For CCSS, use cc_callback_sub instead of
    cc_callback_macro in channel configurations.
 
+ * Asterisk can now use a system-provided NetBSD editline library (libedit) if it
+   is available.
 
 AGI
 ------------------

Modified: trunk/build_tools/menuselect-deps.in
URL: http://svnview.digium.com/svn/asterisk/trunk/build_tools/menuselect-deps.in?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/build_tools/menuselect-deps.in (original)
+++ trunk/build_tools/menuselect-deps.in Wed Jul 25 07:21:54 2012
@@ -27,6 +27,7 @@
 JACK=@PBX_JACK@
 KQUEUE=@PBX_KQUEUE@
 LDAP=@PBX_LDAP@
+LIBEDIT=@PBX_LIBEDIT@
 LIBXML2=@PBX_LIBXML2@
 LTDL=@PBX_LTDL@
 LUA=@PBX_LUA@

Modified: trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/trunk/configure.ac?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Jul 25 07:21:54 2012
@@ -406,6 +406,7 @@
 AST_EXT_LIB_SETUP([KQUEUE], [kqueue support], [kqueue])
 AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
 AST_LIBCURL_CHECK_CONFIG([], [7.10.1])
+AST_EXT_LIB_SETUP([LIBEDIT], [NetBSD Editline library], [libedit], [, use 'internal' Editline otherwise])
 AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
@@ -1262,12 +1263,32 @@
    fi
    if test "${ILBC_SYSTEM}" = "yes"; then
       AST_PKG_CONFIG_CHECK(ILBC, libilbc)
-      if test "$PBX_ILBC" = '1'; then
-	 ILBC_INTERNAL='no'
+      if test "$PBX_ILBC" = "1"; then
+	 ILBC_INTERNAL="no"
       fi
    fi
    if test "${ILBC_INTERNAL}" = "yes"; then
       PBX_ILBC=1
+   fi
+fi
+
+LIBEDIT_INTERNAL="yes"
+AC_SUBST(LIBEDIT_INTERNAL)
+LIBEDIT_SYSTEM="yes"
+if test "${USE_LIBEDIT}" != "no"; then
+   if test "${LIBEDIT_DIR}" = "internal"; then
+      LIBEDIT_SYSTEM="no"
+   elif test "${LIBEDIT_DIR}" != ""; then
+      LIBEDIT_INTERNAL="no"
+   fi
+   if test "${LIBEDIT_SYSTEM}" = "yes"; then
+      AST_PKG_CONFIG_CHECK(LIBEDIT, libedit)
+      if test "$PBX_LIBEDIT" = "1"; then
+	 LIBEDIT_INTERNAL="no"
+      fi
+   fi
+   if test "${LIBEDIT_INTERNAL}" = "yes"; then
+      PBX_LIBEDIT=1
    fi
 fi
 

Modified: trunk/contrib/scripts/install_prereq
URL: http://svnview.digium.com/svn/asterisk/trunk/contrib/scripts/install_prereq?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/contrib/scripts/install_prereq (original)
+++ trunk/contrib/scripts/install_prereq Wed Jul 25 07:21:54 2012
@@ -27,11 +27,11 @@
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev"
+PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev"
 PACKAGES_RH="automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
 PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
 PACKAGES_RH="$PACKAGES_RH libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"
-PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel"
+PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel"
 
 PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"
 

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Wed Jul 25 07:21:54 2012
@@ -375,6 +375,9 @@
 
 /* Define to 1 if you have the OpenLDAP library. */
 #undef HAVE_LDAP
+
+/* Define if your system has the LIBEDIT libraries. */
+#undef HAVE_LIBEDIT
 
 /* Define to 1 if you have the <libintl.h> header file. */
 #undef HAVE_LIBINTL_H

Modified: trunk/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/main/Makefile?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/main/Makefile (original)
+++ trunk/main/Makefile Wed Jul 25 07:21:54 2012
@@ -144,7 +144,14 @@
 	$(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
 	rm ast_expr2.o ast_expr2f.o
 
+ifneq ($(LIBEDIT_INTERNAL),no)
+LIBEDIT_OBJ=editline/libedit.a
+LIBEDIT_INCLUDE=-Ieditline
+endif
+
 db.o: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
+asterisk.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
+cli.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
 
 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
 http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)
@@ -228,13 +235,13 @@
 
 endif
 
-$(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) editline/libedit.a $(AST_EMBED_LDSCRIPTS)
+$(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS)
 	@$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS)
-	$(ECHO_PREFIX) echo "   [LD] $(OBJS) editline/libedit.a $(AST_EMBED_LDSCRIPTS) -> $@"
+	$(ECHO_PREFIX) echo "   [LD] $(OBJS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) -> $@"
 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
-	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) editline/libedit.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS)
-else
-	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) editline/libedit.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
+	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
+else
+	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
 endif
 
 ifeq ($(GNU_LD),1)

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Jul 25 07:21:54 2012
@@ -98,6 +98,7 @@
 #endif
 #endif
 #include <regex.h>
+#include <histedit.h>
 
 #if defined(SOLARIS)
 int daemon(int, int);  /* defined in libresolv of all places */
@@ -2704,7 +2705,7 @@
 			int mlen = 0, maxmbuf = 2048;
 			/* Start with a 2048 byte buffer */
 			if (!(mbuf = ast_malloc(maxmbuf))) {
-				lf->cursor[0] = savechr;
+				*((char *) lf->cursor) = savechr;
 				return (char *)(CC_ERROR);
 			}
 			snprintf(buf, sizeof(buf), "_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr);
@@ -2716,7 +2717,7 @@
 					/* Every step increment buffer 1024 bytes */
 					maxmbuf += 1024;
 					if (!(mbuf = ast_realloc(mbuf, maxmbuf))) {
-						lf->cursor[0] = savechr;
+						*((char *) lf->cursor) = savechr;
 						return (char *)(CC_ERROR);
 					}
 				}
@@ -2778,7 +2779,7 @@
 		ast_free(matches);
 	}
 
-	lf->cursor[0] = savechr;
+	*((char *) lf->cursor) = savechr;
 
 	return (char *)(long)retval;
 }
@@ -2861,29 +2862,13 @@
 
 static int ast_el_read_history(char *filename)
 {
-	char buf[MAX_HISTORY_COMMAND_LENGTH];
-	FILE *f;
-	int ret = -1;
-
-	if (el_hist == NULL || el == NULL)
+	HistEvent ev;
+
+	if (el_hist == NULL || el == NULL) {
 		ast_el_initialize();
-
-	if ((f = fopen(filename, "r")) == NULL)
-		return ret;
-
-	while (!feof(f)) {
-		if (!fgets(buf, sizeof(buf), f))
-			break;
-		if (!strcmp(buf, "_HiStOrY_V2_\n"))
-			continue;
-		if (ast_all_zeros(buf))
-			continue;
-		if ((ret = ast_el_add_history(buf)) == -1)
-			break;
-	}
-	fclose(f);
-
-	return ret;
+	}
+
+	return history(el_hist, &ev, H_LOAD, filename);
 }
 
 static void ast_remotecontrol(char *data)

Modified: trunk/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cli.c?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Wed Jul 25 07:21:54 2012
@@ -39,6 +39,7 @@
 #include <regex.h>
 #include <pwd.h>
 #include <grp.h>
+#include <editline/readline.h>
 
 #include "asterisk/cli.h"
 #include "asterisk/linkedlists.h"
@@ -48,7 +49,6 @@
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 #include "asterisk/lock.h"
-#include "editline/readline/readline.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/translate.h"
 

Modified: trunk/main/editline/configure.in
URL: http://svnview.digium.com/svn/asterisk/trunk/main/editline/configure.in?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/main/editline/configure.in (original)
+++ trunk/main/editline/configure.in Wed Jul 25 07:21:54 2012
@@ -235,7 +235,7 @@
 dnl Add files to the lists if readline compatibility is enabled.
 if test "x$enable_readline" = "xyes" ; then
   CCSRCS="$CCSRCS readline.c"
-  IHDRS="$IHDRS readline/readline.h"
+  IHDRS="$IHDRS readline.h"
   IHDR_LINKS="readline.h readline/history.h"
   HDR_DIRS="$HDR_DIRS include/readline"
   LIB_A_LINKS="$LIB_A_LINKS libedit.a libreadline.a"

Modified: trunk/main/editline/readline.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/editline/readline.c?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/main/editline/readline.c (original)
+++ trunk/main/editline/readline.c Wed Jul 25 07:21:54 2012
@@ -58,7 +58,7 @@
 #endif
 
 #include "histedit.h"
-#include "readline/readline.h"
+#include "readline.h"
 #include "el.h"
 #include "fcns.h"		/* for EL_NUM_FCNS */
 

Modified: trunk/makeopts.in
URL: http://svnview.digium.com/svn/asterisk/trunk/makeopts.in?view=diff&rev=370481&r1=370480&r2=370481
==============================================================================
--- trunk/makeopts.in (original)
+++ trunk/makeopts.in Wed Jul 25 07:21:54 2012
@@ -169,6 +169,10 @@
 LDAP_INCLUDE=@LDAP_INCLUDE@
 LDAP_LIB=@LDAP_LIB@
 
+LIBEDIT_INTERNAL=@LIBEDIT_INTERNAL@
+LIBEDIT_INCLUDE=@LIBEDIT_INCLUDE@
+LIBEDIT_LIB=@LIBEDIT_LIB@
+
 LUA_INCLUDE=@LUA_INCLUDE@
 LUA_LIB=@LUA_LIB@
 




More information about the asterisk-commits mailing list