Skip to content

Commit

Permalink
Enable usage of system-provided NetBSD editline library if available.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Kevin P. Fleming committed Jul 25, 2012
1 parent 38f1081 commit 7d4ccea
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 37 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -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
------------------
Expand Down
1 change: 1 addition & 0 deletions build_tools/menuselect-deps.in
Expand Up @@ -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@
Expand Down
161 changes: 158 additions & 3 deletions configure
@@ -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.
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1214,6 +1221,7 @@ with_jack
with_kqueue
with_ldap
with_libcurl
with_libedit
with_libxml2
with_ltdl
with_lua
Expand Down Expand Up @@ -1281,6 +1289,8 @@ PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
ILBC_CFLAGS
ILBC_LIBS
LIBEDIT_CFLAGS
LIBEDIT_LIBS
GMIME_CFLAGS
GMIME_LIBS
GTK2_CFLAGS
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -17998,15 +18046,122 @@ $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
PBX_ILBC=1
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=""
Expand Down
25 changes: 23 additions & 2 deletions configure.ac
Expand Up @@ -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])
Expand Down Expand Up @@ -1262,15 +1263,35 @@ 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
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

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])
Expand Down
4 changes: 2 additions & 2 deletions contrib/scripts/install_prereq
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions include/asterisk/autoconfig.h.in
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions main/Makefile
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7d4ccea

Please sign in to comment.