# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.56)
AC_INIT(WeeChat, 0.2.7-dev, flashcode@flashtux.org)
AC_CONFIG_SRCDIR([src/core/weechat.c])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([weechat], [0.2.7-dev])

# Checks for programs
AC_PROG_CC
AC_PROG_MAKE_SET
AC_GNU_SOURCE
AM_PROG_LIBTOOL
AC_CHECK_PROG(DBLATEX_FOUND, "dblatex", "yes")

# Add some flags for some OS
case "$host_os" in
freebsd* | openbsd*)
        CFLAGS="$CFLAGS -I/usr/local/include"
        LDFLAGS="$LDFLAGS -L/usr/local/lib"
        ;;
netbsd*)
        CFLAGS="$CFLAGS -I/usr/pkg/include"
        LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
        ;;
solaris*)
        LDFLAGS="$LDFLAGS -lsocket -lxnet"
        ;;
esac

# Gettext
ALL_LINGUAS="fr es cs hu de ru"
AM_GNU_GETTEXT([use-libtool])
AM_GNU_GETTEXT_VERSION([0.15])

# Checks for libraries
AC_CHECK_LIB(ncurses, initscr, LIBNCURSES_FOUND=1, LIBNCURSES_FOUND=0)
AC_CHECK_LIB(ncursesw, initscr, LIBNCURSESW_FOUND=1, LIBNCURSESW_FOUND=0)

# Checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h locale.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/types.h unistd.h pwd.h errno.h regex.h wchar.h sys/file.h])

if echo "$host_os" | grep "^openbsd" 1>/dev/null 2>&1 ; then
   AC_CHECK_HEADER(utf8/wchar.h, LDFLAGS="$LDFLAGS -lutf8", [AC_MSG_ERROR([
*** on OpenBSD systems, package libutf8 must be installed to compile WeeChat])])
fi

# Checks for typedefs, structures, and compiler characteristics
AC_HEADER_TIME
AC_STRUCT_TM

AC_MSG_CHECKING([for socklen_t])
AC_CACHE_VAL(ac_cv_type_socklen_t,
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[ #include <sys/types.h>
#include <sys/socket.h> ]],
[[ socklen_t t; ]])],
[ ac_cv_type_socklen_t=yes ],
[ ac_cv_type_socklen_t=no ],
)])
if test $ac_cv_type_socklen_t = no; then
AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
fi
AC_MSG_RESULT($ac_cv_type_socklen_t)

# Checks for library functions.
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([gethostbyname gethostname getsockname gettimeofday inet_ntoa memset mkdir select setlocale socket strcasecmp strchr strdup strndup strncasecmp strpbrk strrchr strstr regexec])

# Variables in config.h

AH_VERBATIM([PREFIX], [#undef PREFIX])
AH_VERBATIM([WEECHAT_LIBDIR], [#undef WEECHAT_LIBDIR])
AH_VERBATIM([WEECHAT_SHAREDIR], [#undef WEECHAT_SHAREDIR])
AH_VERBATIM([HAVE_GNUTLS], [#undef HAVE_GNUTLS])
AH_VERBATIM([HAVE_FLOCK], [#undef HAVE_FLOCK])
AH_VERBATIM([PLUGIN_ALIAS], [#undef PLUGIN_ALIAS])
AH_VERBATIM([PLUGIN_ASPELL], [#undef PLUGIN_ASPELL])
AH_VERBATIM([PLUGIN_CHARSET], [#undef PLUGIN_CHARSET])
AH_VERBATIM([PLUGIN_DEMO], [#undef PLUGIN_DEMO])
AH_VERBATIM([PLUGIN_FIFO], [#undef PLUGIN_FIFO])
AH_VERBATIM([PLUGIN_IRC], [#undef PLUGIN_IRC])
AH_VERBATIM([PLUGIN_LOGGER], [#undef PLUGIN_LOGGER])
AH_VERBATIM([PLUGIN_NOTIFY], [#undef PLUGIN_NOTIFY])
AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL])
AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON])
AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY])
AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA])
AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL])
AH_VERBATIM([PLUGIN_TRIGGER], [#undef PLUGIN_TRIGGER])
AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER])
AH_VERBATIM([DOC], [#undef DOC])

# Arguments for ./configure

AC_ARG_ENABLE(ncurses,      [  --disable-ncurses       turn off ncurses interface (default=compiled if found)],enable_ncurses=$enableval,enable_ncurses=yes)
AC_ARG_ENABLE(wxwidgets,    [  --enable-wxwidgets      turn on WxWidgets interface (default=off)],enable_wxwidgets=$enableval,enable_wxwidgets=no)
AC_ARG_ENABLE(gtk,          [  --enable-gtk            turn on Gtk interface (default=off)],enable_gtk=$enableval,enable_gtk=no)
AC_ARG_ENABLE(qt,           [  --enable-qt             turn on Qt interface (default=off)],enable_qt=$enableval,enable_qt=no)
AC_ARG_ENABLE(gnutls,       [  --disable-gnutls        turn off gnutls support (default=compiled if found)],enable_gnutls=$enableval,enable_gnutls=yes)
AC_ARG_ENABLE(largefile,    [  --disable-largefile     turn off Large File Support (default=on)],enable_largefile=$enableval,enable_largefile=yes)
AC_ARG_ENABLE(alias,        [  --disable-alias         turn off Alias plugin (default=compiled)],enable_alias=$enableval,enable_alias=yes)
AC_ARG_ENABLE(aspell,       [  --disable-aspell        turn off Aspell plugin (default=compiled)],enable_aspell=$enableval,enable_aspell=yes)
AC_ARG_ENABLE(charset,      [  --disable-charset       turn off Charset plugin (default=compiled if found)],enable_charset=$enableval,enable_charset=yes)
AC_ARG_ENABLE(demo,         [  --enable-demo           turn on Demo plugin (default=off)],enable_demo=$enableval,enable_demo=no)
AC_ARG_ENABLE(fifo,         [  --disable-fifo          turn off Fifo plugin (default=compiled)],enable_fifo=$enableval,enable_fifo=yes)
AC_ARG_ENABLE(irc,          [  --disable-irc           turn off IRC plugin (default=compiled)],enable_irc=$enableval,enable_irc=yes)
AC_ARG_ENABLE(logger,       [  --disable-logger        turn off Logger plugin (default=compiled)],enable_logger=$enableval,enable_logger=yes)
AC_ARG_ENABLE(notify,       [  --disable-notify        turn off Notify plugin (default=compiled)],enable_notify=$enableval,enable_notify=yes)
AC_ARG_ENABLE(scripts,      [  --disable-scripts       turn off script plugins (default=compiled if found)],enable_scripts=$enableval,enable_scripts=yes)
AC_ARG_ENABLE(perl,         [  --disable-perl          turn off Perl script plugin (default=compiled if found)],enable_perl=$enableval,enable_perl=yes)
AC_ARG_ENABLE(python,       [  --disable-python        turn off Python script plugin (default=compiled if found)],enable_python=$enableval,enable_python=yes)
AC_ARG_ENABLE(ruby,         [  --disable-ruby          turn off Ruby script plugin (default=compiled if found)],enable_ruby=$enableval,enable_ruby=yes)
AC_ARG_ENABLE(lua,          [  --disable-lua           turn off Lua script plugin (default=compiled if found)],enable_lua=$enableval,enable_lua=yes)
AC_ARG_ENABLE(tcl,          [  --disable-tcl           turn off Tcl script plugin (default=compiled if found)],enable_tcl=$enableval,enable_tcl=yes)
AC_ARG_ENABLE(trigger,      [  --enable-trigger        turn on Trigger plugin (default=off)],enable_trigger=$enableval,enable_trigger=no)
AC_ARG_ENABLE(xfer,         [  --disable-xfer          turn off Xfer (file transfer) plugin (default=compiled if found)],enable_xfer=$enableval,enable_xfer=yes)
AC_ARG_WITH(lua-inc,        [  --with-lua-inc=DIR,     lua include files are in DIR (default=autodetect)],lua_inc=$withval,lua_inc='')
AC_ARG_WITH(lua-lib,        [  --with-lua-lib=DIR,     lua library files are in DIR (default=autodetect)],lua_lib=$withval,lua_lib='')
AC_ARG_WITH(lua-suffix,     [  --with-lua-suffix=ARG   lua is suffixed with ARG (default=autodetect)],lua_suffix=$withval,lua_suffix='')
AC_ARG_ENABLE(doc,          [  --disable-doc           turn off documentation (default=built)],enable_doc=$enableval,enable_doc=yes)
AC_ARG_WITH(doc_xsl_prefix, [  --with-doc-xsl-prefix=DIR docbook html/chunk.xsl is in DIR (default=autodetect)],doc_xsl_prefix=$withval,doc_xsl_prefix='')
AC_ARG_WITH(debug,          [  --with-debug            debugging: 0=no debug, 1=debug compilation (default=1)],debug=$withval,debug=1)

not_asked=""
not_found=""

# ------------------------------------------------------------------------------
#                                dynamic loader
# ------------------------------------------------------------------------------

PLUGINS_LFLAGS=

AC_CHECK_FUNCS(dlopen, LIBDL_FOUND=yes, LIBDL_FOUND=no)
if test "$LIBDL_FOUND" != "yes"; then
    AC_CHECK_LIB(dl, dlopen, [LIBDL_FOUND=yes; PLUGINS_LFLAGS=-ldl], LIBDL_FOUND=no)
fi
if test "$LIBDL_FOUND" != "yes"; then
    AC_MSG_ERROR([
*** "dl" library (dynamic library loader) couldn't be found in your system.
*** Try to install it with your software package manager.])
fi
AC_SUBST(PLUGINS_LFLAGS)

# ------------------------------------------------------------------------------
#                                    gui
# ------------------------------------------------------------------------------

if test "x$enable_ncurses" = "xyes" ; then
    if test "$LIBNCURSESW_FOUND" = "0" ; then
        if test "$LIBNCURSES_FOUND" = "0" ; then
            AC_MSG_WARN([
*** ncurses library not found!
*** WeeChat will be built without ncurses support.])
            enable_ncurses="no"
            not_found="$not_found ncurses"
        else
            AC_MSG_WARN([
*** ncursesw library not found! Falling back to "ncurses"
*** Be careful, UTF-8 display may not work properly if your locale is UTF-8.])
            NCURSES_LFLAGS="-lncurses"
        fi
    else
        NCURSES_LFLAGS="-lncursesw"
    fi
    AC_CHECK_HEADERS([ncurses.h ncursesw/curses.h])
    AC_SUBST(NCURSES_LFLAGS)
else
    not_asked="$not_asked ncurses"
fi

#if test "x$enable_wxwidgets" = "xyes" ; then
#    AM_OPTIONS_WXCONFIG
#    AM_PATH_WXCONFIG(2.3.4, wxWin=1)
#
#    if test "$wxWin" != 1; then
#        AC_MSG_ERROR([
#*** wxWindows must be installed on your system
#*** but wx-config script couldn't be found.
#
#*** Please check that wx-config is in path, the directory
#*** where wxWindows libraries are installed (returned by
#*** 'wx-config --libs' command) is in LD_LIBRARY_PATH or
#*** equivalent variable and wxWindows version is 2.3.4 or above.
#        ])
#    fi
#
#    CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
#    CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
#    CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
#    LDFLAGS="$LDFLAGS $WX_LIBS"
#
#    WXWIDGETS_CFLAGS=""
#    WXWIDGETS_LIBS=""
#fi

if test "x$enable_gtk" = "xyes" ; then
    AM_PATH_GTK_2_0(2.4.0, LIBGTK_FOUND=1, LIBGTK_FOUND=0)
    if test "$LIBGTK_FOUND" = "0" ; then
        AC_MSG_WARN([
*** Gtk library not found!
*** WeeChat will be built without Gtk support.])
        enable_gtk="no"
        not_found="$not_found gtk"
    else
        GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
        GTK_LFLAGS=`pkg-config --libs gtk+-2.0`
        AC_SUBST(GTK_CFLAGS)
        AC_SUBST(GTK_LFLAGS)
    fi
else
    not_asked="$not_asked gtk"
fi

# ------------------------------------------------------------------------------
#                                    iconv
# ------------------------------------------------------------------------------

ICONV_LFLAGS=""

iconv_found="no"
AC_CHECK_HEADER(iconv.h,ac_found_iconv_header="yes",ac_found_iconv_header="no")
if test "x$ac_found_iconv_header" = "xyes" ; then
   AC_CHECK_LIB(iconv,iconv_open,ac_found_iconv_lib="yes",ac_found_iconv_lib="no")
   if test "x$ac_found_iconv_lib" = "xno" ; then
      AC_CHECK_LIB(iconv,libiconv_open,ac_found_iconv_lib="yes",ac_found_iconv_lib="no")
   fi
   if test "x$ac_found_iconv_lib" = "xyes" ; then
      ICONV_LFLAGS="-liconv"
      LIBS="$LIBS $ICONV_LFLAGS"
   fi
   AC_MSG_CHECKING(for iconv usability in programs)   
   AC_TRY_RUN([
	#include <iconv.h>
	int main(int argc, char **argv) {
	    iconv_t conv = iconv_open("ISO8859-1", "UTF-8");
            if (conv != (iconv_t) -1) {
	      return 0;
            }
	    return 1;
      }],iconv_found="yes")
  if test "x$iconv_found" = "xno" ; then
     AC_MSG_RESULT(no)
  else
     AC_MSG_RESULT(yes)
  fi
fi

if test "x$iconv_found" = "xno" ; then
   AC_MSG_ERROR([
*** Iconv headers and/or libraries couldn't be found in your system.
*** Try to install them with your software package manager.
*** WeeChat can't be built without Iconv support.])
fi

# ------------------------------------------------------------------------------
#                                   plugins
# ------------------------------------------------------------------------------

if test "x$enable_scripts" = "xno" ; then
    enable_perl="no"
    enable_python="no"
    enable_ruby="no"
    enable_lua="no"
    enable_tcl="no"
fi

# ---------------------------------- alias -------------------------------------

if test "x$enable_alias" = "xyes" ; then
    ALIAS_CFLAGS=""
    ALIAS_LFLAGS=""
    AC_SUBST(ALIAS_CFLAGS)
    AC_SUBST(ALIAS_LFLAGS)
    AC_DEFINE(PLUGIN_ALIAS)
else
    not_asked="$not_asked alias"
fi

# ---------------------------------- aspell ------------------------------------

if test "x$enable_aspell" = "xyes" ; then
    ASPELL_CFLAGS=""
    ASPELL_LFLAGS=""

    AC_CHECK_HEADER(aspell.h,ac_found_aspell_header="yes",ac_found_aspell_header="no")
    AC_CHECK_LIB(aspell,new_aspell_speller,ac_found_aspell_lib="yes",ac_found_aspell_lib="no")

    AC_MSG_CHECKING(for aspell headers and librairies)    
    if test "x$ac_found_aspell_header" = "xno" -o "x$ac_found_aspell_lib" = "xno" ; then
       AC_MSG_RESULT(no)
       AC_MSG_WARN([
*** Aspell headers and/or libraries couldn't be found in your system.
*** Try to install them with your software package manager.
*** WeeChat will be built without Aspell support.])
       enable_aspell="no"
       not_found="$not_found aspell"
    else
	AC_MSG_RESULT(yes)
	ASPELL_LFLAGS="$ASPELL_LFLAGS -laspell"
    fi
else
    not_asked="$not_asked aspell"
fi

if test "x$enable_aspell" = "xyes" ; then
    AC_SUBST(ASPELL_CFLAGS)
    AC_SUBST(ASPELL_LFLAGS)
    AC_DEFINE(PLUGIN_ASPELL)
fi

# --------------------------------- charset ------------------------------------

if test "x$enable_charset" = "xyes" ; then
    CHARSET_CFLAGS=""
    CHARSET_LFLAGS="$ICONV_LFLAGS"
    AC_SUBST(CHARSET_CFLAGS)
    AC_SUBST(CHARSET_LFLAGS)
    AC_DEFINE(PLUGIN_CHARSET)
else
    not_asked="$not_asked charset"
fi

# ---------------------------------- demo --------------------------------------

if test "x$enable_demo" = "xyes" ; then
    DEMO_CFLAGS=""
    DEMO_LFLAGS=""
    AC_SUBST(DEMO_CFLAGS)
    AC_SUBST(DEMO_LFLAGS)
    AC_DEFINE(PLUGIN_DEMO)
else
    not_asked="$not_asked demo"
fi

# ---------------------------------- fifo --------------------------------------

if test "x$enable_fifo" = "xyes" ; then
    FIFO_CFLAGS=""
    FIFO_LFLAGS=""
    AC_SUBST(FIFO_CFLAGS)
    AC_SUBST(FIFO_LFLAGS)
    AC_DEFINE(PLUGIN_FIFO)
else
    not_asked="$not_asked fifo"
fi

# ----------------------------------- irc --------------------------------------

if test "x$enable_irc" = "xyes" ; then
    AC_DEFINE(PLUGIN_IRC)
else
    not_asked="$not_asked irc"
fi

# --------------------------------- logger -------------------------------------

if test "x$enable_logger" = "xyes" ; then
    LOGGER_CFLAGS=""
    LOGGER_LFLAGS=""
    AC_SUBST(LOGGER_CFLAGS)
    AC_SUBST(LOGGER_LFLAGS)
    AC_DEFINE(PLUGIN_LOGGER)
else
    not_asked="$not_asked logger"
fi

# --------------------------------- notify -------------------------------------

if test "x$enable_notify" = "xyes" ; then
    NOTIFY_CFLAGS=""
    NOTIFY_LFLAGS=""
    AC_SUBST(NOTIFY_CFLAGS)
    AC_SUBST(NOTIFY_LFLAGS)
    AC_DEFINE(PLUGIN_NOTIFY)
else
    not_asked="$not_asked notify"
fi

# ---------------------------------- perl --------------------------------------

PERL_VERSION=

if test "x$enable_perl" = "xyes" ; then
    AC_PATH_PROGS(PERL, perl perl5)
    if test -z $PERL ; then
        AC_MSG_WARN([
*** Perl must be installed on your system but perl interpreter couldn't be found in path.
*** Please check that perl is in path, or install it with your software package manager.
*** WeeChat will be built without Perl support.])
        enable_perl="no"
        not_found="$not_found perl"
    else
	PERL_VERSION=`perl -V:version | sed "s/version='\(.*\)';/\1/"`
        AC_MSG_CHECKING(for Perl headers files)
        
        PERL_HEADER_TEST=`PT=perltest.c ; echo "#include <EXTERN.h>" > $PT;  echo "#include <perl.h>" >> $PT;  echo "#include <XSUB.h>" >> $PT ;  echo "int main() { return 0; }" >> $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ccopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
        
        if test "x$PERL_HEADER_TEST" = "x0" ; then
            PERL_CFLAGS=`$PERL -MExtUtils::Embed -e ccopts`
            AC_MSG_RESULT(found)
            AC_MSG_CHECKING(for Perl library)
            PERL_LIB_TEST=`PT=perltest.c ; echo "int main() { return 0; }" > $PT ; $CC -Wall $PT -o $PT.out $($PERL -MExtUtils::Embed -e ldopts) 1>/dev/null 2>&1; echo $?; rm -f $PT $PT.out 1>/dev/null 2>&1`
            if test "x$PERL_LIB_TEST" = "x0" ; then	        
                PERL_LFLAGS=`$PERL -MExtUtils::Embed -e ldopts`
                AC_MSG_RESULT(found)
            else
                AC_MSG_WARN([
*** Perl library couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Perl support.])
                enable_perl="no"
                not_found="$not_found perl"
            fi
        else
            AC_MSG_WARN([
*** Perl headers couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Perl support.])
            enable_perl="no"
            not_found="$not_found perl"
        fi
    fi
else
    not_asked="$not_asked perl"
fi

if test "x$enable_perl" = "xyes" ; then
    AC_SUBST(PERL_CFLAGS)
    AC_SUBST(PERL_LFLAGS)
    AC_DEFINE(PLUGIN_PERL)
fi

# --------------------------------- python -------------------------------------

PYTHON_VERSION=

if test "x$enable_python" = "xyes" ; then
    AC_PATH_PROGS(PYTHON, python python2.5 python2.4 python2.3 python2.2)
    if test -z $PYTHON ; then
        AC_MSG_WARN([
*** Python must be installed on your system but python interpreter couldn't be found in path.
*** Please check that python is in path, or install it with your software package manager.
*** WeeChat will be built without Python support.])
        enable_python="no"
        not_found="$not_found python"
    else
        PYTHON_SYSPREFIX=`$PYTHON -c 'import sys; print "%s" % sys.prefix'`
        PYTHON_VERSION=`$PYTHON -c 'import sys ; print sys.version[[:3]]'`
        PYTHON_INCLUDE=`$PYTHON -c "import distutils.sysconfig,string; print distutils.sysconfig.get_config_var('CONFINCLUDEPY')"`
        
        AC_MSG_CHECKING(for Python header files)
        if test -r "$PYTHON_INCLUDE/Python.h"; then
            PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
            AC_MSG_RESULT(found)
            PYTHON_LIB=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBPL')"`
            PYTHON_LFLAGS="-lpython$PYTHON_VERSION "`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBS')+' '+distutils.sysconfig.get_config_var('SYSLIBS')+' '+distutils.sysconfig.get_config_var('LINKFORSHARED')"`
            AC_MSG_CHECKING(for Python library)
            if test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.so"; then
               PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
               AC_MSG_RESULT(found)
            elif test -r "$PYTHON_LIB/libpython$PYTHON_VERSION.a"; then
               PYTHON_LFLAGS="-L$PYTHON_LIB $PYTHON_LFLAGS"
               AC_MSG_RESULT(found)
            elif test -r "$PYTHON_SYSPREFIX/lib/libpython$PYTHON_VERSION.so"; then
               PYTHON_LFLAGS="-L$PYTHON_SYSPREFIX/lib/ $PYTHON_LFLAGS"
               AC_MSG_RESULT(found)
            else
                AC_MSG_WARN([
*** Python library couldn't be found in your system.            
*** Try to install it with your software package manager.
*** WeeChat will be built without Python support.])
                enable_python="no"
                not_found="$not_found python"
            fi
        else
            AC_MSG_WARN([
*** Python header files couldn't be found in your system.
*** Try to install them with your software package manager.
*** WeeChat will be built without Python support.])
            enable_python="no"
            not_found="$not_found python"
        fi
    fi
else
    not_asked="$not_asked python"
fi

if test "x$enable_python" = "xyes" ; then
    AC_SUBST(PYTHON_CFLAGS)
    AC_SUBST(PYTHON_LFLAGS)
    AC_DEFINE(PLUGIN_PYTHON)
fi

# ---------------------------------- ruby --------------------------------------

RUBY_VERSION=

if test "x$enable_ruby" = "xyes" ; then
    AC_PATH_PROGS(RUBY, ruby ruby1.8 ruby1.9)
    if test -z $RUBY ; then
        AC_MSG_WARN([
*** Ruby must be installed on your system but ruby interpreter couldn't be found in path.
*** Please check that ruby is in path, or install it with your software package manager.
*** WeeChat will be built without Ruby support.])
        enable_ruby="no"
        not_found="$not_found ruby"
    else
	RUBY_VERSION=`$RUBY -rrbconfig -e "puts Config::CONFIG[['ruby_version']]"`
        RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts Config::CONFIG[['archdir']]"`
        AC_MSG_CHECKING(for Ruby header files)
        if test -r "$RUBY_INCLUDE/ruby.h"; then
            RUBY_CFLAGS="-I$RUBY_INCLUDE"
        else
            AC_MSG_WARN([
*** Ruby header files couldn't be found in your system.
*** Try to install them with your software package manager.
*** WeeChat will be built without Ruby support.])
            enable_ruby="no"
            not_found="$not_found ruby"
        fi
        AC_MSG_RESULT(found)
        RUBY_LFLAGS=`$RUBY -rrbconfig -e "puts Config::CONFIG[['LIBRUBYARG_SHARED']]"`
    fi
else
    not_asked="$not_asked ruby"
fi

if test "x$enable_ruby" = "xyes" ; then
    AC_SUBST(RUBY_CFLAGS)
    AC_SUBST(RUBY_LFLAGS)
    AC_DEFINE(PLUGIN_RUBY)
fi

# ---------------------------------- lua --------------------------------------

LUA_VERSION=

if test "x$enable_lua" = "xyes" ; then
    ac_save_CPPFLAGS="$CPPFLAGS"
    ac_save_CFLAGS="$CFLAGS"
    ac_save_LDFLAGS="$LDFLAGS"

    LUA_CFLAGS=""
    LUA_LFLAGS=""

    if test -n "$lua_inc"; then
       CFLAGS="$CFLAGS -I$lua_inc"
       CPPFLAGS="$CPPFLAGS -I$lua_inc"
    fi
    if test -n "$lua_lib"; then
       LDFLAGS="$LDFLAGS -L$lua_lib"
    fi
    
    if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then
        PKGCONFIG=""
        AC_CHECK_PROGS(PKGCONFIG, pkg-config)
        if test "x$PKGCONFIG" != "x"; then
	    AC_MSG_CHECKING(for Lua headers and librairies with pkg-config)
	    echo
	    for l in "$lua_suffix" "" "51" "5.1" "50" "5.0" ; do
	        pkgconfig_lua_found=`$PKGCONFIG --exists lua$l 2>/dev/null`
	        if test "x$?" = "x0" ; then
		    LUA_VERSION=`$PKGCONFIG --modversion lua$l`
                    LUA_CFLAGS="$LUA_CFLAGS "`$PKGCONFIG --cflags lua$l`
                    LUA_LFLAGS="$LUA_LFLAGS "`$PKGCONFIG --libs lua$l`

		    pkgconfig_lualib_found=`$PKGCONFIG --exists lualib$l 2>/dev/null`
		    if test  "x$?" = "x0"; then
		       LUA_CFLAGS="$LUA_CFLAGS "`$PKGCONFIG --cflags lualib$l`
		       LUA_LFLAGS="$LUA_LFLAGS "`$PKGCONFIG --libs lualib$l`
		    fi
                    break
                fi
            done
        fi
    fi    

    if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then
        LUACONFIG=""
        AC_CHECK_PROGS(LUACONFIG, lua-config lua-config51 lua-config5.1 lua-config50 lua-config5.0)
        if test "x$LUACONFIG" != "x" ; then
            AC_MSG_CHECKING(for Lua headers and librairies with lua-config)
	    echo
            LUA_CFLAGS=`$LUACONFIG --include`
            LUA_LFLAGS=`$LUACONFIG --libs`
	    LUA_VERSION="5.0.x"
        fi
    fi

    if test "x$LUA_CFLAGS" = "x" -o "x$LUA_LFLAGS" = "x" ; then       
        AC_MSG_CHECKING(for Lua headers and librairies)
	echo
        AC_CHECK_HEADER(lua.h,ac_found_lua_header="yes",ac_found_lua_header="no")
        AC_CHECK_HEADER(lualib.h,ac_found_liblua_header="yes",ac_found_liblua_header="no")
        if test "x$ac_found_lua_header" = "xyes" -a "x$ac_found_liblua_header" = "xyes"; then
            LUA_CFLAGS="$CFLAGS"
        fi
        for l in "$lua_suffix" "" "51" "5.1" "50" "5.0" ; do
            AC_CHECK_LIB(lua$l,lua_call,ac_found_lua_lib="yes",ac_found_lua_lib="no")
            if test "x$ac_found_lua_lib" = "xyes" ; then
	        LUA_VERSION=">=5.1.0"	       

	        LUA_LFLAGS="$LDFLAGS -llua$l -lm"
		
		ac2_save_LDFLAGS="$LDFLAGS"
		LDFLAGS="$LDFLAGS -llua$l -lm"		

		if echo "$host_os" | grep "^linux" 1>/dev/null 2>&1 ; then
		   LDFLAGS="$LDFLAGS -ldl"
		fi

		AC_CHECK_LIB(lualib$l,luaL_openlib,ac_found_liblua_lib="yes",ac_found_liblua_lib="no")
		if test "x$ac_found_liblua_lib" = "xyes" ; then
		   LUA_VERSION="5.0.x"
		   
		   LUA_LFLAGS="$LUA_LFLAGS -llualib$l"

		   if echo "$host_os" | grep "^linux" 1>/dev/null 2>&1 ; then
		      LUA_LFLAGS="$LUA_LFLAGS -ldl"
		   fi		   
		fi

		LDFLAGS="$ac2_save_LDFLAGS"
		break
	    fi
        done
    fi

    AC_MSG_CHECKING(for Lua compiling and linking)
    LUA_TEST=`LT=luatest.c ; echo "#include <lua.h>" > $LT;  echo "#include <lualib.h>" >> $LT; echo "int main() { luaopen_base((lua_State *)lua_open()); return 0; }" >> $LT ; $CC -Wall $LT -o $LT.out $LUA_CFLAGS $LUA_LFLAGS $CFLAGS $LDFLAGS 1>/dev/null 2>&1 ; echo $?; rm -f $LT $LT.out 1>/dev/null 2>&1`
    if test "x$LUA_TEST" != "x0" ; then
        AC_MSG_RESULT(no)
        AC_MSG_WARN([
*** Lua (>=5.0) headers and/or librairies couldn't be found in your system.
*** Try to install liblua, liblualib and liblua-dev with your software package manager.
*** WeeChat will be built without Lua support.])
        enable_lua="no"
        not_found="$not_found lua"
    else
        AC_MSG_RESULT(yes)
    fi

    CFLAGS="$ac_save_CFLAGS"
    CPPFLAGS="$ac_save_CPPFLAGS"
    LDFLAGS="$ac_save_LDFLAGS"
else
    not_asked="$not_asked lua"
fi

if test "x$enable_lua" = "xyes" ; then
    AC_SUBST(LUA_CFLAGS)
    AC_SUBST(LUA_LFLAGS)
    AC_DEFINE(PLUGIN_LUA)
fi

# --------------------------------- tcl -------------------------------------
TCL_VERSION=

if test "x$enable_tcl" = "xyes" ; then
    enable_plugins="yes"
    
    AC_PATH_PROGS(TCL, tclsh tclsh8.5 tclsh8.4)
    if test -z $TCL ; then
        AC_MSG_WARN([
*** Tcl must be installed on your system but tcl interpreter couldn't be found in path.
*** Please check that tclsh is in path, or install it with your software package manager.
*** WeeChat will be built without Tcl support.])
        enable_tcl="no"
        not_found="$not_found tcl"
    else
	echo "for grepp"
        TCL_VERSION=`echo 'puts $tcl_version' | $TCL`
        TCL_PATCHLEVEL=`echo 'puts $tcl_patchLevel' | $TCL`
        
	AC_MSG_CHECKING(for Tcl headers files)
        TCL_HEADER_TEST=`TT=tcltest.c ; echo "#include <tcl.h>" > $TT; echo "int main() { return 0; }" >> $TT ; $CC -Wall $TT -o $TT.out 1>/dev/null 2>&1; echo $?; rm -f $TT $TT.out 1>/dev/null 2>&1`
        if test "x$TCL_HEADER_TEST" = "x0" ; then
            TCL_CFLAGS="-fPIC"
            AC_MSG_RESULT(found)
            AC_MSG_CHECKING(for Tcl library)
            TCL_LIB_TEST=`TT=tcltest.c ; echo "int main() { return 0; }" > $TT ; $CC -Wall $TT -o $TT.out -ltcl$TCL_VERSION 1>/dev/null 2>&1; echo $?; rm -f $TT $TT.out 1>/dev/null 2>&1`
            if test "x$TCL_LIB_TEST" = "x0" ; then	        
                TCL_LFLAGS="-ltcl$TCL_VERSION -ldl -export-dynamic"
                AC_MSG_RESULT(found)
            else
                AC_MSG_WARN([
*** Tcl library couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Tcl support.])
                enable_tcl="no"
                not_found="$not_found tcl"
            fi
        else
            AC_MSG_WARN([
*** Tcl headers couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Tcl support.])
            enable_tcl="no"
            not_found="$not_found tcl"
        fi
    fi
fi

if test "x$enable_tcl" = "xyes" ; then
    AC_SUBST(TCL_CFLAGS)
    AC_SUBST(TCL_LFLAGS)
    AC_DEFINE(PLUGIN_TCL)
fi

# --------------------------------- trigger ------------------------------------

if test "x$enable_trigger" = "xyes" ; then
    TRIGGER_CFLAGS=""
    TRIGGER_LFLAGS=""
    AC_SUBST(TRIGGER_CFLAGS)
    AC_SUBST(TRIGGER_LFLAGS)
    AC_DEFINE(PLUGIN_TRIGGER)
else
    not_asked="$not_asked trigger"
fi

# ---------------------------------- xfer --------------------------------------

if test "x$enable_xfer" = "xyes" ; then
    XFER_CFLAGS=""
    XFER_LFLAGS=""
    AC_SUBST(XFER_CFLAGS)
    AC_SUBST(XFER_LFLAGS)
    AC_DEFINE(PLUGIN_XFER)
else
    not_asked="$not_asked xfer"
fi

# ------------------------------------------------------------------------------
#                                   gnutls
# ------------------------------------------------------------------------------

if test "x$enable_gnutls" = "xyes" ; then
    found_gnutls="no"
    AM_PATH_LIBGNUTLS( 1.0.0, found_gnutls=yes, AC_MSG_WARN([[
*** libgnutls was not found. You may want to get it from ftp://ftp.gnutls.org/pub/gnutls/
*** WeeChat will be built without GnuTLS support.]]))
    if test "x$found_gnutls" = "xyes" ; then
        GNUTLS_CFLAGS=`libgnutls-config --cflags`
        GNUTLS_LFLAGS=`libgnutls-config --libs`
        AC_SUBST(GNUTLS_CFLAGS)
        AC_SUBST(GNUTLS_LFLAGS)
        AC_DEFINE(HAVE_GNUTLS)
        CFLAGS="$CFLAGS -DHAVE_GNUTLS"
    else
        enable_gnutls="no"
        not_found="$not_found gnutls"
    fi
else
    not_asked="$not_asked gnutls"
fi

# ------------------------------------------------------------------------------
#                                   flock
# ------------------------------------------------------------------------------

enable_flock="no"
AC_CACHE_CHECK([for flock() support], ac_have_flock, [
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[ #include <sys/file.h>]],
[[ flock(0, LOCK_SH); ]])],
[ ac_have_flock="yes" ],
[ ac_have_flock="no" ])])

if test "x$ac_have_flock" = "xyes"; then
    enable_flock="yes"
    AC_DEFINE(HAVE_FLOCK)
else
    not_found="$not_found flock"
fi

# ------------------------------------------------------------------------------
#                               large file support
# ------------------------------------------------------------------------------
if test "x$enable_largefile" = "xyes" ; then
   CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
else
   not_asked="$not_asked largefile"
fi

# ------------------------------------------------------------------------------
#                                  backtrace
# ------------------------------------------------------------------------------

enable_backtrace="no"
if test "x$debug" != "x0" ; then
    AC_CACHE_CHECK([for execinfo.h and backtrace], ac_have_backtrace, [
        AC_LINK_IFELSE([AC_LANG_PROGRAM(
            [[ #include <execinfo.h> ]],
            [[ void *trace[128]; int n = backtrace(trace, 128); ]])],
            [ ac_have_backtrace="yes" ],
            [ ac_have_backtrace="no"  ])])
    if test "x$ac_have_backtrace" = "xyes"; then
        enable_backtrace="yes"
        AC_DEFINE(HAVE_BACKTRACE,1,[glibc backtrace function])
    else
        not_found="$not_found backtrace"
    fi
fi

# ------------------------------------------------------------------------------
#                               documentation
# ------------------------------------------------------------------------------

msg_doc=""

if test "x$enable_doc" = "xyes" ; then
    AC_DEFINE(DOC)
    if test "x$DBLATEX_FOUND" = "xyes"; then
        msg_doc="pdf $msg_doc"
    else
        not_found="$not_found doc(pdf)"
    fi

    AC_MSG_CHECKING(for html/chunk.xsl)
    DOC_XSL_PREFIX=""

    if test -n "$doc_xsl_prefix"; then
        doc_xsl_prefix_path="$doc_xsl_prefix"
    else
        doc_xsl_prefix_path="/usr/share/xml/docbook/xsl-stylesheets-1.69"
        doc_xsl_prefix_path="${doc_xsl_prefix_arr} /usr/share/xml/docbook/stylesheet/nwalsh"
    fi

    for p in $doc_xsl_prefix_path; do
        if test -f ${p}/html/chunk.xsl; then
            DOC_XSL_PREFIX="$p"
        fi
    done

    if test "x$DOC_XSL_PREFIX" = "x"; then
        AC_MSG_RESULT(no)
        AC_MSG_WARN([
*** Docbook XSL files not found
*** WeeChat will be built without documentation.
*** Try ./configure --with-doc-xsl-prefix=DIR if you have DIR/html/chunk.xsl file])
        not_found="$not_found doc(html)"
    else
        AC_MSG_RESULT($DOC_XSL_PREFIX)
        AC_SUBST(DOC_XSL_PREFIX)
        msg_doc="html $msg_doc"
    fi
else
    not_asked="$not_asked doc"
    msg_doc=""
fi

# ------------------------------------------------------------------------------
#                                general vars
# ------------------------------------------------------------------------------

if test "x$prefix" = "xNONE" ; then
    prefix="$ac_default_prefix"
fi

if test "x$exec_prefix" = "xNONE" ; then
    exec_prefix="$prefix"
fi

AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")

WEECHAT_LIBDIR=`eval eval echo ${libdir}/weechat`
AC_DEFINE_UNQUOTED(WEECHAT_LIBDIR, "$WEECHAT_LIBDIR")

WEECHAT_SHAREDIR=`eval eval echo ${datadir}/weechat`
AC_DEFINE_UNQUOTED(WEECHAT_SHAREDIR, "$WEECHAT_SHAREDIR")

weechat_libdir=${libdir}/weechat
AC_SUBST(weechat_libdir)

COMMON_CFLAGS="-Wall -W -Werror-implicit-function-declaration"
AC_MSG_CHECKING([whether we have GNU assembler])
GAS=`as --version < /dev/null 2>/dev/null | grep GNU`
if test "$GAS"; then
    COMMON_CFLAGS="${COMMON_CFLAGS} -pipe"
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi

CFLAGS=`echo $CFLAGS | sed 's/ -g //g'`
CFLAGS=`echo $CFLAGS | sed 's/^-g //g'`
CFLAGS=`echo $CFLAGS | sed 's/ -g$//g'`
CFLAGS=`echo $CFLAGS | sed 's/^-g$//g'`
if test "x$debug" = "x0" ; then
    CFLAGS="$COMMON_CFLAGS $CFLAGS"
else
    CFLAGS="$COMMON_CFLAGS $CFLAGS -g -O0"
fi

LIBS="$LIBS $INTLLIBS"

case "$host_os" in
freebsd*)
        if test "x$enable_perl" = "xyes" -o "x$enable_python" = "xyes" ; then
            CFLAGS="$CFLAGS -pthread"
        fi
        CFLAGS="$CFLAGS $CPPFLAGS"
        ;;
openbsd*)
        if test "x$enable_python" = "xyes" ; then
            CFLAGS="$CFLAGS -pthread"
        fi
        ;;
netbsd*)
        if test "x$enable_perl" = "xyes" -o "x$enable_python" = "xyes" ; then
            CFLAGS="$CFLAGS -pthread"
        fi
        CFLAGS="$CFLAGS $CPPFLAGS"
        ;;
gnu*)	
        LDFLAGS="$LDFLAGS -lpthread"
        ;;
*)
        ;;
esac

CFLAGS="$CFLAGS -DWEECHAT_VERSION=\\\"$VERSION\\\""

# ------------------------------------------------------------------------------
#                                output Makefiles
# ------------------------------------------------------------------------------

AM_CONDITIONAL(HAVE_GNUTLS,    test "$enable_gnutls" = "yes")
AM_CONDITIONAL(HAVE_FLOCK,     test "$enable_flock" = "yes")
AM_CONDITIONAL(DBLATEX_FOUND,  test "$DBLATEX_FOUND" = "yes")
AM_CONDITIONAL(GUI_NCURSES,    test "$enable_ncurses" = "yes")
AM_CONDITIONAL(GUI_WXWIDGETS,  test "$enable_wxwidgets" = "yes")
AM_CONDITIONAL(GUI_GTK,        test "$enable_gtk" = "yes")
AM_CONDITIONAL(GUI_QT,         test "$enable_qt" = "yes")
AM_CONDITIONAL(PLUGIN_ALIAS,   test "$enable_alias" = "yes")
AM_CONDITIONAL(PLUGIN_ASPELL,  test "$enable_aspell" = "yes")
AM_CONDITIONAL(PLUGIN_CHARSET, test "$enable_charset" = "yes")
AM_CONDITIONAL(PLUGIN_DEMO,    test "$enable_demo" = "yes")
AM_CONDITIONAL(PLUGIN_FIFO,    test "$enable_fifo" = "yes")
AM_CONDITIONAL(PLUGIN_IRC,     test "$enable_irc" = "yes")
AM_CONDITIONAL(PLUGIN_LOGGER,  test "$enable_logger" = "yes")
AM_CONDITIONAL(PLUGIN_NOTIFY,  test "$enable_notify" = "yes")
AM_CONDITIONAL(PLUGIN_PERL,    test "$enable_perl" = "yes")
AM_CONDITIONAL(PLUGIN_PYTHON,  test "$enable_python" = "yes")
AM_CONDITIONAL(PLUGIN_RUBY,    test "$enable_ruby" = "yes")
AM_CONDITIONAL(PLUGIN_LUA,     test "$enable_lua" = "yes")
AM_CONDITIONAL(PLUGIN_TCL,     test "$enable_tcl" = "yes")
AM_CONDITIONAL(PLUGIN_TRIGGER, test "$enable_trigger" = "yes")
AM_CONDITIONAL(PLUGIN_XFER,    test "$enable_xfer" = "yes")
AM_CONDITIONAL(DOC,            test "$enable_doc" = "yes")

AC_OUTPUT([Makefile
           doc/Makefile
           doc/en/Makefile
           doc/fr/Makefile
           doc/de/Makefile
           doc/ru/Makefile
           doc/pl/Makefile
           doc/cs/Makefile
           doc/sco/Makefile
           doc/sv/Makefile
           src/Makefile
           src/core/Makefile
           src/plugins/Makefile
           src/plugins/alias/Makefile
           src/plugins/aspell/Makefile
           src/plugins/charset/Makefile
           src/plugins/demo/Makefile
           src/plugins/fifo/Makefile
           src/plugins/irc/Makefile
           src/plugins/logger/Makefile
           src/plugins/notify/Makefile
           src/plugins/scripts/Makefile
           src/plugins/scripts/perl/Makefile
           src/plugins/scripts/python/Makefile
           src/plugins/scripts/ruby/Makefile
           src/plugins/scripts/lua/Makefile
           src/plugins/scripts/tcl/Makefile
           src/plugins/trigger/Makefile
           src/plugins/xfer/Makefile
           src/gui/Makefile
           src/gui/curses/Makefile
           src/gui/wxwidgets/Makefile
           src/gui/gtk/Makefile
           src/gui/qt/Makefile
           intl/Makefile
           po/Makefile.in])

# ------------------------------------------------------------------------------
#                                  end message
# ------------------------------------------------------------------------------

listgui=""
if test "x$enable_ncurses" = "xyes" ; then
    listgui="$listgui ncurses"
fi
if test "x$enable_wxwidgets" = "xyes"; then
   listgui="$listgui wxwidgets"
fi
if test "x$enable_gtk" = "xyes" ; then
    listgui="$listgui gtk"
fi
if test "x$enable_qt" = "xyes" ; then
    listgui="$listgui qt"
fi

if test "x$listgui" = "x" ; then
    AC_MSG_ERROR([
*** No interface specified...
*** Please enable at least ncurses, WxWidgets, Gtk or Qt.])
fi

listplugins=""
if test "x$enable_alias" = "xyes"; then
    listplugins="$listplugins alias"
fi
if test "x$enable_aspell" = "xyes"; then
    listplugins="$listplugins aspell"
fi
if test "x$enable_charset" = "xyes"; then
    listplugins="$listplugins charset"
fi
if test "x$enable_demo" = "xyes"; then
    listplugins="$listplugins demo"
fi
if test "x$enable_fifo" = "xyes"; then
    listplugins="$listplugins fifo"
fi
if test "x$enable_irc" = "xyes" ; then
    listplugins="$listplugins irc"
fi
if test "x$enable_logger" = "xyes"; then
    listplugins="$listplugins logger"
fi
if test "x$enable_notify" = "xyes"; then
    listplugins="$listplugins notify"
fi
if test "x$enable_perl" = "xyes"; then
    listplugins="$listplugins perl($PERL_VERSION)"
fi
if test "x$enable_python" = "xyes"; then
    listplugins="$listplugins python($PYTHON_VERSION)"
fi
if test "x$enable_ruby" = "xyes"; then
    listplugins="$listplugins ruby($RUBY_VERSION)"
fi
if test "x$enable_lua" = "xyes"; then
    listplugins="$listplugins lua($LUA_VERSION)"
fi
if test "x$enable_tcl" = "xyes"; then
    listplugins="$listplugins tcl($TCL_PATCHLEVEL)"
fi
if test "x$enable_trigger" = "xyes"; then
    listplugins="$listplugins trigger"
fi
if test "x$enable_xfer" = "xyes"; then
    listplugins="$listplugins xfer"
fi

listoptional=""
if test "x$enable_gnutls" = "xyes"; then
    listoptional="$listoptional gnutls"
fi
if test "x$enable_flock" = "xyes"; then
    listoptional="$listoptional flock"
fi
if test "x$enable_largefile" = "xyes"; then
    listoptional="$listoptional largefile"
fi
if test "x$enable_backtrace" = "xyes"; then
    listoptional="$listoptional backtrace"
fi

msg_debug="no"
if test "x$debug" != "x0"; then
    msg_debug="yes"
fi

if test "x$msg_doc" = "x"; then
    msg_doc="no"
else
    msg_doc="yes: $msg_doc"
fi

echo ""
echo "Enabled features:"
echo "   Interfaces........... :$listgui"
echo "   Plugins.............. :$listplugins"
echo "   Optional features.... :$listoptional"
echo "   Compile with debug... : $msg_debug"
echo "   Documentation........ : $msg_doc"

if test "x$not_asked" != "x" || test "x$not_found" != "x"; then
    echo ""
    echo "Disabled features:"
    if test "x$not_asked" != "x"; then
        echo "   - not asked:$not_asked"
    fi
    if test "x$not_found" != "x"; then
        echo "   - not found:$not_found"
    fi
fi

echo ""
eval echo "WeeChat will be installed in $bindir."
echo ""
echo "configure complete, now type 'make' to build WeeChat $VERSION"
echo ""
