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) (heavily modified by kpfleming)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370481 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming 2012-07-25 12:21:54 +00:00
parent 38f1081fd3
commit 7d4ccea736
14 changed files with 215 additions and 37 deletions

View File

@ -399,6 +399,8 @@ Core
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
------------------

View File

@ -27,6 +27,7 @@ IXJUSER=@PBX_IXJUSER@
JACK=@PBX_JACK@
KQUEUE=@PBX_KQUEUE@
LDAP=@PBX_LDAP@
LIBEDIT=@PBX_LIBEDIT@
LIBXML2=@PBX_LIBXML2@
LTDL=@PBX_LTDL@
LUA=@PBX_LUA@

161
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 369346 .
# From configure.ac Revision: 370407 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for asterisk trunk.
#
@ -649,6 +649,9 @@ CONFIG_NEON
CONFIG_MYSQLCLIENT
PBX_MISDN_FAC_ERROR
PBX_MISDN_FAC_RESULT
LIBEDIT_LIBS
LIBEDIT_CFLAGS
LIBEDIT_INTERNAL
ILBC_LIBS
ILBC_CFLAGS
ILBC_INTERNAL
@ -934,6 +937,10 @@ PBX_LIBXML2
LIBXML2_DIR
LIBXML2_INCLUDE
LIBXML2_LIB
PBX_LIBEDIT
LIBEDIT_DIR
LIBEDIT_INCLUDE
LIBEDIT_LIB
CURL_LIB
CURL_INCLUDE
_libcurl_config
@ -1214,6 +1221,7 @@ with_jack
with_kqueue
with_ldap
with_libcurl
with_libedit
with_libxml2
with_ltdl
with_lua
@ -1281,6 +1289,8 @@ PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
ILBC_CFLAGS
ILBC_LIBS
LIBEDIT_CFLAGS
LIBEDIT_LIBS
GMIME_CFLAGS
GMIME_LIBS
GTK2_CFLAGS
@ -1940,6 +1950,8 @@ Optional Packages:
--with-kqueue=PATH use kqueue support files in PATH
--with-ldap=PATH use OpenLDAP files in PATH
--with-libcurl=DIR look for the curl library in DIR
--with-libedit=PATH use NetBSD Editline library files in PATH, use
'internal' Editline otherwise
--with-libxml2=PATH use LibXML2 files in PATH
--with-ltdl=PATH use libtool files in PATH
--with-lua=PATH use Lua files in PATH
@ -2006,6 +2018,10 @@ Some influential environment variables:
path overriding pkg-config's built-in search path
ILBC_CFLAGS C compiler flags for ILBC, overriding pkg-config
ILBC_LIBS linker flags for ILBC, overriding pkg-config
LIBEDIT_CFLAGS
C compiler flags for LIBEDIT, overriding pkg-config
LIBEDIT_LIBS
linker flags for LIBEDIT, overriding pkg-config
GMIME_CFLAGS
C compiler flags for GMIME, overriding pkg-config
GMIME_LIBS linker flags for GMIME, overriding pkg-config
@ -9213,6 +9229,38 @@ _ACEOF
unset _libcurl_with
LIBEDIT_DESCRIP="NetBSD Editline library"
LIBEDIT_OPTION="libedit"
PBX_LIBEDIT=0
# Check whether --with-libedit was given.
if test "${with_libedit+set}" = set; then :
withval=$with_libedit;
case ${withval} in
n|no)
USE_LIBEDIT=no
# -1 is a magic value used by menuselect to know that the package
# was disabled, other than 'not found'
PBX_LIBEDIT=-1
;;
y|ye|yes)
ac_mandatory_list="${ac_mandatory_list} LIBEDIT"
;;
*)
LIBEDIT_DIR="${withval}"
ac_mandatory_list="${ac_mandatory_list} LIBEDIT"
;;
esac
fi
LIBXML2_DESCRIP="LibXML2"
LIBXML2_OPTION="libxml2"
PBX_LIBXML2=0
@ -17998,8 +18046,8 @@ $as_echo "#define HAVE_ILBC 1" >>confdefs.h
fi
fi
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
@ -18007,6 +18055,113 @@ fi
fi
fi
LIBEDIT_INTERNAL="yes"
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
if test "x${PBX_LIBEDIT}" != "x1" -a "${USE_LIBEDIT}" != "no"; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBEDIT" >&5
$as_echo_n "checking for LIBEDIT... " >&6; }
if test -n "$LIBEDIT_CFLAGS"; then
pkg_cv_LIBEDIT_CFLAGS="$LIBEDIT_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libedit\""; } >&5
($PKG_CONFIG --exists --print-errors "libedit") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBEDIT_CFLAGS=`$PKG_CONFIG --cflags "libedit" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$LIBEDIT_LIBS"; then
pkg_cv_LIBEDIT_LIBS="$LIBEDIT_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libedit\""; } >&5
($PKG_CONFIG --exists --print-errors "libedit") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBEDIT_LIBS=`$PKG_CONFIG --libs "libedit" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
LIBEDIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libedit" 2>&1`
else
LIBEDIT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libedit" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBEDIT_PKG_ERRORS" >&5
PBX_LIBEDIT=0
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
PBX_LIBEDIT=0
else
LIBEDIT_CFLAGS=$pkg_cv_LIBEDIT_CFLAGS
LIBEDIT_LIBS=$pkg_cv_LIBEDIT_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
PBX_LIBEDIT=1
LIBEDIT_INCLUDE="$LIBEDIT_CFLAGS"
LIBEDIT_LIB="$LIBEDIT_LIBS"
$as_echo "#define HAVE_LIBEDIT 1" >>confdefs.h
fi
fi
if test "$PBX_LIBEDIT" = "1"; then
LIBEDIT_INTERNAL="no"
fi
fi
if test "${LIBEDIT_INTERNAL}" = "yes"; then
PBX_LIBEDIT=1
fi
fi
if test "x${PBX_ICONV}" != "x1" -a "${USE_ICONV}" != "no"; then
pbxlibdir=""

View File

@ -406,6 +406,7 @@ AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
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,8 +1263,8 @@ if test "${USE_ILBC}" != "no"; then
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
@ -1271,6 +1272,26 @@ if test "${USE_ILBC}" != "no"; then
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
AST_EXT_LIB_CHECK([ICONV], [iconv], [iconv_open], [iconv.h])
# GNU libiconv #define's iconv_open to libiconv_open, so we need to search for that symbol
AST_EXT_LIB_CHECK([ICONV], [iconv], [libiconv_open], [iconv.h])

View File

@ -27,11 +27,11 @@ PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libog
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"

View File

@ -376,6 +376,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

View File

@ -144,7 +144,14 @@ testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
$(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
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)
$(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) editline/libedit.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
$(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)

View File

@ -98,6 +98,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ static char *cli_complete(EditLine *editline, int ch)
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 @@ static char *cli_complete(EditLine *editline, int ch)
/* 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 @@ static char *cli_complete(EditLine *editline, int ch)
ast_free(matches);
}
lf->cursor[0] = savechr;
*((char *) lf->cursor) = savechr;
return (char *)(long)retval;
}
@ -2861,29 +2862,13 @@ static int ast_el_write_history(char *filename)
static int ast_el_read_history(char *filename)
{
char buf[MAX_HISTORY_COMMAND_LENGTH];
FILE *f;
int ret = -1;
HistEvent ev;
if (el_hist == NULL || el == NULL)
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)

View File

@ -39,6 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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"

View File

@ -2031,7 +2031,7 @@ TCSRCS="TEST/test.c"
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"

View File

@ -235,7 +235,7 @@ TCSRCS="TEST/test.c"
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"

View File

@ -58,7 +58,7 @@ __RCSID("$NetBSD: readline.c,v 1.21 2002/03/18 16:20:36 christos Exp $");
#endif
#include "histedit.h"
#include "readline/readline.h"
#include "readline.h"
#include "el.h"
#include "fcns.h" /* for EL_NUM_FCNS */

View File

@ -169,6 +169,10 @@ JACK_LIB=@JACK_LIB@
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@