From: Vincent Bernat Date: Sat, 5 Jan 2013 15:59:41 +0000 (+0100) Subject: configure: detect libedit without pkg-config X-Git-Tag: 0.7.0~14^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68e3821232717a19906a207b1a5098db2c1f3e48;p=thirdparty%2Flldpd.git configure: detect libedit without pkg-config BSD comes with libedit shipped and without pkg-config being able to detect it. Fallback to manual detection of the headers and check if we can compile a program with it. --- diff --git a/configure.ac b/configure.ac index 4b69dd35..cc0327ef 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no]) lldp_CHECK_LIBEVENT # editline -PKG_CHECK_MODULES([EDITLINE], [libedit >= 2.9]) +lldp_CHECK_EDITLINE ####################### ### Options diff --git a/m4/libedit.m4 b/m4/libedit.m4 new file mode 100644 index 00000000..10d67fb3 --- /dev/null +++ b/m4/libedit.m4 @@ -0,0 +1,40 @@ +# +# lldp_CHECK_EDITLINE +# + +AC_DEFUN([lldp_CHECK_EDITLINE], [ + _save_LIBS="$LIBS" + _save_CFLAGS="$CFLAGS" + + # First, try with pkg-config + PKG_CHECK_MODULES([EDITLINE], [libedit >= 2.9], [], [ + # Nothing appropriate. Maybe it is installed anyway. + AC_CHECK_HEADER([histedit.h], [], + [AC_MSG_ERROR([*** unable to find editline/libedit])]) + EDITLINE_CFLAGS="" + EDITLINE_LIBS="-ledit -lcurses" + ]) + + # Check if everything works as expected + LIBS="$LIBS $EDITLINE_LIBS" + CFLAGS="$CFLAGS $EDITLINE_CFLAGS" + AC_MSG_CHECKING([if libedit version is compatible]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +@%:@include +@%:@include + ]], [[ +int i = H_SETSIZE; (void)i; +el_init("", NULL, NULL, NULL); +exit(0); + ]])], + [ AC_MSG_RESULT([yes]) ], + [ AC_MSG_RESULT([no]) + AC_MSG_ERROR([*** libedit does not work as expected])])]) + + LIBS="$_save_LIBS" + CFLAGS="$_save_CFLAGS" + + AC_SUBST([EDITLINE_CFLAGS]) + AC_SUBST([EDITLINE_LIBS]) +])