Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / configure.in
index 30e418c3ac2754c248ba2a844493a6b0a714a64f..aa65967f5c588d9fb3b72ed040d5a4f16c760cbf 100644 (file)
-AC_INIT(src)
+AC_INIT(SILC-Client, 0.8.16-rc1)
+AC_CONFIG_SRCDIR([src])
+AC_CONFIG_AUX_DIR(build-aux)
+AC_PREREQ(2.50)
 
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(Irssi-SILC, 0.7.98.3)
+AC_CONFIG_HEADERS([irssi-config.h])
+AM_INIT_AUTOMAKE([1.9 no-define foreign])
 
 AM_MAINTAINER_MODE
 
 AC_ISC_POSIX
 AC_PROG_CC
 AC_PROG_CPP
-AC_STDC_HEADERS
-AC_ARG_PROGRAM
 AM_PROG_LIBTOOL
 
-dnl * ahem.. :) we don't want static libraries for modules
-if test "x$lt_target" = "x"; then
-        if test "$target" = "NONE"; then
-               lt_target="$host"
-       else
-               lt_target="$target"
-       fi
-fi
-dnl * --disable-static isn't a good idea, complain if it's used
-if test "x$enable_static" = "xno"; then
-       AC_ERROR([Don't give --disable-static option to configure])
-fi
-
-${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --disable-static --output=libtool-shared --no-verify $ac_aux_dir/ltmain.sh $lt_target \
-|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
-${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
-|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
+AC_PATH_PROG(sedpath, sed)
+AC_PATH_PROG(perlpath, perl)
 
-AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h libintl.h)
+AC_CHECK_HEADERS(unistd.h dirent.h sys/ioctl.h sys/resource.h)
 
 # check posix headers..
 AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h)
 
-AC_ARG_WITH(big5,
-[  --with-big5             Build with tr-Chinese Big5 support],
-       if test x$withval = xyes; then
-               want_big5=yes
-       else
-               if test "x$withval" = xno; then
-                       want_big5=no
-               else
-                       want_big5=yes
-               fi
-       fi,
-       want_big5=no)
+AC_SYS_LARGEFILE
 
 AC_ARG_WITH(socks,
 [  --with-socks            Build with socks support],
-       if test x$withval = xyes; then
-               want_socks=yes
+       if test x$withval = xno; then
+               want_socks=no
        else
-               if test "x$withval" = xno; then
-                       want_socks=no
-               else
-                       want_socks=yes
-               fi
+               want_socks=yes
        fi,
        want_socks=no)
 
 AC_ARG_WITH(textui,
-[  --with-textui           Build text frontend],
-       if test x$withval = xyes; then
-               want_textui=yes
+[  --without-textui        Build without text frontend],
+       if test x$withval = xno; then
+               want_textui=no
        else
-               if test "x$withval" = xno; then
-                       want_textui=no
-               else
-                       want_textui=yes
-               fi
+               want_textui=yes
        fi,
        want_textui=yes)
 
 AC_ARG_WITH(bot,
 [  --with-bot              Build irssi-bot],
-       if test x$withval = xyes; then
-               want_irssibot=yes
+       if test x$withval = xno; then
+               want_irssibot=no
        else
-               if test "x$withval" = xno; then
-                       want_irssibot=no
-               else
-                       want_irssibot=yes
-               fi
+               want_irssibot=yes
        fi,
        want_irssibot=no)
 
 AC_ARG_WITH(proxy,
 [  --with-proxy            Build irssi-proxy],
-       if test x$withval = xyes; then
-               want_irssiproxy=yes
+       if test x$withval = xno; then
+               want_irssiproxy=no
        else
-               if test "x$withval" = xno; then
-                       want_irssiproxy=no
-               else
-                       want_irssiproxy=yes
-               fi
+               want_irssiproxy=yes
        fi,
        want_irssiproxy=no)
 
+AC_ARG_WITH(terminfo,
+[  --without-terminfo      Use curses backend instead of terminfo],
+       if test x$withval = xno; then
+               want_terminfo=no
+       else
+               want_terminfo=yes
+       fi,
+       want_terminfo=yes)
 
 AC_ARG_WITH(modules,
 [  --with-modules          Specify what modules to build in binary],
@@ -109,100 +74,138 @@ AC_ARG_WITH(modules,
                build_modules="$withval"
        fi)
 
-if test "x$prefix" = "xNONE"; then
-       PERL_LIB_DIR=""
-else
-       PERL_LIB_DIR="$prefix"
+if test "x$prefix" != "xNONE"; then
+       prefix=`eval echo $prefix`
+       PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=$prefix"
+       perl_library_dir="PERL_USE_LIB"
+       perl_set_use_lib=yes
+
+       perl_prefix_note=yes
 fi
 
-AC_ARG_ENABLE(perl-path,
-[  --enable-perl-path=dir  Specify where to install the Perl libraries for irssi],
-       if test x$enableval = xyes; then
-               want_perl=yes
+AC_ARG_WITH(gc,
+[  --with-gc               Use garbage collector],
+       if test x$withval = xno; then
+               want_gc=no
        else
-               if test "x$enableval" = xno; then
-                       want_perl=no
+               want_gc=yes
+       fi,
+       want_gc=no)
+
+AC_ARG_WITH(perl-staticlib,
+[  --with-perl-staticlib   Specify that we want to link perl libraries
+                          statically in irssi, default is no],
+       if test x$withval = xno; then
+               want_staticperllib=no
+       else
+               want_staticperllib=yes
+       fi,
+       want_staticperllib=no)
+
+
+AC_ARG_WITH(perl-lib,
+[  --with-perl-lib=[site|vendor|DIR]  Specify where to install the
+                          Perl libraries for irssi, default is site],
+       if test "x$withval" = xyes; then
+               want_perl=yes
+       elif test "x$withval" = xno; then
+               want_perl=no
+       elif test "x$withval" = xsite; then
+               want_perl=yes
+               perl_prefix_note=no
+               PERL_MM_PARAMS=""
+       elif test "x$withval" = xvendor; then
+               want_perl=yes
+               perl_prefix_note=no
+               if test -z "`$perlpath -v|grep '5\.0'`"; then
+                       PERL_MM_PARAMS="INSTALLDIRS=vendor"
                else
-                       want_perl=yes
-                       PERL_LIB_DIR="$enableval"
-                       perl_lib_dir_given=yes
+                       PERL_MM_PARAMS="INSTALLDIRS=perl PREFIX=`perl -e 'use Config; print $Config{prefix}'`"
                fi
+               perl_library_dir="(vendor default - `$perlpath -e 'use Config; print $Config{archlib}'`)"
+       else
+               want_perl=yes
+               perl_prefix_note=no
+               PERL_MM_PARAMS="INSTALLDIRS=perl LIB=$withval"
+               perl_library_dir="PERL_USE_LIB"
+               perl_set_use_lib=yes
        fi,
        want_perl=yes)
 
-AC_ARG_ENABLE(perl,
-[  --enable-perl[=yes|no|static]  Build with Perl support - also specifies
+AC_ARG_WITH(perl,
+[  --with-perl[=yes|no|module]  Build with Perl support - also specifies
                           if it should be built into main irssi binary
-                          (static) or as module (default)],
-       if test x$enableval = xyes; then
-               want_perl=yes
-       elif test x$enableval = xstatic; then
+                          (static, default) or as module],
+       if test x$withval = xyes; then
                want_perl=static
+       elif test x$withval = xstatic; then
+               want_perl=static
+       elif test x$withval = xmodule; then
+               want_perl=module
        else
                want_perl=no
        fi,
-       want_perl=yes)
-want_perl=no
-
-AC_ARG_WITH(tests,
-[  --with-tests           Run all the tests],
-       if test x$withval != xno; then
-               TEST_DIR=test
-       fi,
-       TEST_DIR=)
-AC_SUBST(TEST_DIR)
-
-AC_ARG_ENABLE(curses-windows,
-[  --enable-curses-windows Use curses windows],
-       if test x$enableval != xno; then
-               AC_DEFINE(USE_CURSES_WINDOWS)
-       fi,
-       AC_DEFINE(USE_CURSES_WINDOWS))
+       want_perl=static)
+
+# Irssi SILC Plugin support
+#
+SILC_IRSSIDIR=
+silc_plugin=false
+AC_MSG_CHECKING(whether to compile SILC Plugin for Irssi)
+AC_ARG_WITH(silc-plugin,
+  [[  --with-silc-plugin[=DIR] Compile the SILC Plugin for Irssi, specify
+                           Irssi location [/usr/lib/irssi]]],
+  [
+    case "${withval}" in
+      no)
+        AC_MSG_RESULT(no)
+        silc_plugin=false
+        ;;
+      yes)
+        AC_MSG_RESULT(yes)
+        silc_plugin=true
+       SILC_IRSSIDIR="/usr/lib/irssi/modules"
+       ;;
+      *)
+        AC_MSG_RESULT(yes)
+        silc_plugin=true
+        SILC_IRSSIDIR="$withval/modules"
+        ;;
+    esac
+  ])
+
+AM_CONDITIONAL(SILCPLUGIN, test x$silc_plugin = xtrue)
+AC_SUBST(SILC_IRSSIDIR)
 
-AC_ARG_ENABLE(memdebug,
-[  --enable-memdebug       Enable memory debugging],
-       if test x$enableval = xyes; then
-               want_memdebug=yes
+AC_ARG_ENABLE(ipv6,
+[  --disable-ipv6          Disable IPv6 support],
+       if test x$enableval = xno; then
+               want_ipv6=no
        else
-               if test "x$enableval" = xno; then
-                       want_memdebug=no
-               else
-                       want_memdebug=yes
-               fi
+               want_ipv6=yes
        fi,
-       want_memdebug=no)
+       want_ipv6=yes)
 
-AC_ARG_ENABLE(ipv6,
-[  --enable-ipv6           Enable IPv6 support],
-       if test x$enableval = xyes; then
-               want_ipv6=yes
+AC_ARG_ENABLE(dane,
+[  --enable-dane           Enable DANE support],
+       if test x$enableval = xno ; then
+               want_dane=no
        else
-               if test "x$enableval" = xno; then
-                       want_ipv6=no
-               else
-                       want_ipv6=yes
-               fi
+               want_dane=yes
        fi,
-       want_ipv6=no)
+       want_dane=no)
 
 dnl **
-dnl ** just some generic stuff...
+dnl ** SSL Library checks (OpenSSL)
 dnl **
 
-AC_CHECK_FUNCS(mkfifo fcntl)
-
-AC_CHECK_LIB(socket, socket, [
-       PROG_LIBS="$PROG_LIBS -lsocket"
-])
-
-AC_CHECK_LIB(nsl, inet_addr, [
-       PROG_LIBS="$PROG_LIBS -lnsl"
-], -lsocket)
+AC_ARG_ENABLE(ssl,
+[  --disable-ssl           Disable Secure Sockets Layer support],,
+       enable_ssl=yes)
 
-dnl * gcc specific options
-if test "x$ac_cv_prog_gcc" = "xyes"; then
-  CFLAGS="$CFLAGS -Wall"
-fi
+dnl **
+dnl ** just some generic stuff...
+dnl **
 
 dnl * OS specific options
 case "$host_os" in
@@ -213,6 +216,24 @@ case "$host_os" in
     ;;
 esac
 
+
+AC_CHECK_FUNC(socket, [], [
+       AC_CHECK_LIB(socket, socket, [
+               LIBS="$LIBS -lsocket"
+       ])
+])
+
+AC_CHECK_FUNC(inet_addr, [], [
+       AC_CHECK_LIB(nsl, inet_addr, [
+               LIBS="$LIBS -lnsl"
+       ])
+])
+
+dnl * gcc specific options
+if test "x$ac_cv_prog_gcc" = "xyes"; then
+  CFLAGS="$CFLAGS -Wall -Wno-deprecated-declarations"
+fi
+
 dnl * socklen_t - AC_CHECK_TYPE() would be _really_ useful if it only would
 dnl * accept header files where to find the typedef..
 AC_MSG_CHECKING([for socklen_t])
@@ -229,13 +250,41 @@ AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
 fi
 AC_MSG_RESULT($irssi_cv_type_socklen_t)
 
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(off_t)
+
+if test $ac_cv_sizeof_off_t = 8; then
+  offt_64bit=yes
+else
+  offt_64bit=no
+fi
+
+if test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_long; then
+  # try to use unsigned long always first
+  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "lu")
+  AC_DEFINE(UOFF_T_LONG)
+elif test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_int; then
+  # next try int
+  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "u")
+  AC_DEFINE(UOFF_T_INT)
+elif test x$ac_cv_sizeof_off_t = x$ac_cv_sizeof_long_long; then
+  # and finally long long
+  AC_DEFINE_UNQUOTED(PRIuUOFF_T, "llu")
+  AC_DEFINE(UOFF_T_LONG_LONG)
+else
+  AC_ERROR([Couldn't find integer type for off_t])
+fi
+
 dnl **
 dnl ** check for socks
 dnl **
 
 if test "x$want_socks" = "xyes"; then
        AC_CHECK_LIB(socks, connect, [
-               PROG_LIBS="$PROG_LIBS -lsocks"
+               AC_DEFINE(HAVE_SOCKS,, Build with socks support)
+               LIBS="$LIBS -lsocks"
                AC_CHECK_HEADER(socks.h, [
                        AC_DEFINE(HAVE_SOCKS_H)
                        CFLAGS="$CFLAGS -DSOCKS"
@@ -251,494 +300,121 @@ dnl **
 dnl ** fe-text checks
 dnl **
 
-AC_PATH_PROG(sedpath, sed)
-
-AC_DEFUN(AC_CHECK_GLIBDIR,[
-  AC_MSG_CHECKING([whether GLib is unpacked to irssi dir])
-
-  GLIB_DIR=`for d in *; do test -f $d/glib.h && echo $d; done`
-  if test "x$GLIB_DIR" != "x"; then
-    dnl * glib in irssi directory, use it
-    AC_MSG_RESULT([yes, using it])
-
-    dnl * we have to do this at this point so we know what libs gmodule needs
-    if test ! -f $GLIB_DIR/.libs/libglib.a; then
-      echo
-      echo "configuring GLib ..."
-      echo
-      cd $GLIB_DIR
-      if test ! -f glib-config; then
-        ./configure
-      fi
-      ${MAKE-make}
-      cd ..
-      echo
-    fi
-
-    GLIB_LDEXTRA=`$GLIB_DIR/glib-config --libs gmodule|$sedpath -e 's/-lglib//' -e 's/-lgmodule//' -e 's,-L/usr/local/lib ,,'|$sedpath 's/ \+/ /g'`
-    full_glib_dir="`pwd`/$GLIB_DIR"
-    GLIB_CFLAGS="-I$full_glib_dir -I$full_glib_dir/gmodule"
-    if test -f $full_glib_dir/.libs/libglib.a; then
-      GLIB_LIBS="$full_glib_dir/.libs/libglib.a $GLIB_LDEXTRA"
-      if test -f $full_glib_dir/gmodule/.libs/libgmodule.a; then
-       GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/.libs/libgmodule.a"
-        AC_DEFINE(HAVE_GMODULE)
-      fi
-    else
-      GLIB_LIBS="$full_glib_dir/libglib.a $GLIB_LDEXTRA"
-      if test -f $full_glib_dir/gmodule/libgmodule.a; then
-       GLIB_LIBS="$GLIB_LIBS $full_glib_dir/gmodule/libgmodule.a"
-        AC_DEFINE(HAVE_GMODULE)
-      fi
-    fi
-    AC_SUBST(GLIB_CFLAGS)
-    AC_SUBST(GLIB_LIBS)
+for try in 1 2; do
+  if test $try = 1; then
+    glib_modules=gmodule
   else
-    AC_MSG_RESULT([no])
-  fi
-])
-
-AC_CHECK_GLIBDIR
-
-if test "x$GLIB_DIR" = "x"; then
-  AM_PATH_GLIB(1.2.0,,, gmodule)
-  if test "x$GLIB_LIBS" = "x"; then
     echo "*** trying without -lgmodule"
-    glib_config_args=
-    AM_PATH_GLIB(1.2.0)
-  else
-    AC_DEFINE(HAVE_GMODULE)
+    glib_modules=
   fi
-
-  if test "x$GLIB_LIBS" = "x"; then
-    echo
-    echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org"
-    echo "*** If you can't install GLIB anywhere or if you don't want to,"
-    echo "*** you can just unpack it to Irssi's source directory and"
-    echo "*** Irssi will automatically compile and use it."
-    echo
-
-    dnl * I think it's pretty safe to assume GLib 1.2.9 since the next
-    dnl * will be 2.0 (or 1.4?) and it's not sure if irssi compiles
-    dnl * with it (yea, just a few weeks after I put this text for 1.2.8
-    dnl * the 1.2.9 came :) .. and then .10
-    glib_file=glib-1.2.10.tar.gz
-
-    dlcmd=
-    if test "x`ncftpget 2>/dev/null|grep -i ncftp`" != "x"; then
-      dlcmd="ncftpget ftp://ftp.gtk.org/pub/gtk/v1.2/$glib_file"
-    fi
-    if test "x`wget 2>/dev/null|grep -i wget`" != "x"; then
-      dlcmd="wget http://irssi.org/files/$glib_file"
-    fi
-    if test "x$dlcmd" != "x"; then
-      echo "*** I can download GLib for you now. If you don't want to, press CTRL-C now."
-      read answer
-      eval $dlcmd
-      if `gunzip $glib_file`; then
-       glib_file=`echo $glib_file|$sedpath s/\.gz$//`
-       if `tar xf $glib_file`; then
-         rm -f $glib_file
-         AC_CHECK_GLIBDIR
-       fi
-      fi
-    fi
-
-    if test "x$GLIB_LIBS" = "x"; then
-      AC_ERROR([GLIB is required to build irssi.])
+  AM_PATH_GLIB_2_0(2.6.0,,, $glib_modules)
+  if test "$GLIB_LIBS"; then
+    if test $glib_modules = gmodule; then
+      AC_DEFINE(HAVE_GMODULE)
+      have_gmodule=yes
     fi
+    break
   fi
-fi
-
-PROG_LIBS="$PROG_LIBS $GLIB_LIBS"
-
-dnl **
-dnl ** check if we can link dynamic libraries to modules
-dnl ** also checks if libraries are built to .libs dir
-dnl **
-
-AC_MSG_CHECKING([if we can link dynamic libraries with modules])
-DYNLIB_MODULES=no
+done
 
-dnl ** compile object file
-cat > conftest.c <<EOF
-#include <math.h>
-int modfunc(void){return (int)floor(1.2);}
-EOF
+if test -z "$GLIB_LIBS"; then
+  echo
+  echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org/pub/glib/"
+  echo "*** We recommend you get the latest stable GLIB 2 version."
+  echo "*** Compile and install it, and make sure pkg-config finds it,"
+  echo "*** by adding the path where the .pc file is located to PKG_CONFIG_PATH"
+  echo
 
-./libtool --mode=compile $CC $CFLAGS -c conftest.c 2> /dev/null > /dev/null
-if test ! -s conftest.lo; then
-  AC_ERROR([error compiling test module])
+  AC_ERROR([GLIB is required to build irssi.])
 fi
 
-dnl ** link to library
-./libtool --mode=link $CC $CFLAGS $LDFLAGS -rpath /usr/lib conftest.lo -lm -o libconftest.la > /dev/null
-if test ! -s .libs/libconftest.a; then
-  AC_ERROR([error, can't even find .a library])
-fi
+LIBS="$LIBS $GLIB_LIBS"
 
-dnl ** check if dynamic linking worked
-libfile=`grep '^library_names' libconftest.la|$sedpath "s/library_names='\(.*\)'.*/\1/"|$sedpath 's/.* \([[^ ]]*\)$/\1/'`
-if test ! -s .libs/$libfile; then
-  AC_MSG_RESULT([no, error linking test module])
-else
-  cat > conftest.c <<EOF
-#include <gmodule.h>
-main() {
-GModule *m; int (*modfunc)(void);
-m = g_module_open(".libs/$libfile", 0);
-if (!m) g_print("error loading: %s", g_module_error());
-else if (!g_module_symbol(m, "modfunc", (gpointer *) &modfunc))
-  g_print("modfunc() symbol not found from module");
-else if (modfunc() == 1) g_print("ok"); else g_print("wrong result?! 1 vs %d", modfunc());
-return 0; }
-EOF
-  $CC $CFLAGS conftest.c -o conftest $GLIB_CFLAGS $GLIB_LIBS 2> /dev/null > /dev/null
-  if test ! -s conftest; then
-    AC_MSG_RESULT([no, error compiling test program])
+have_openssl=no
+if test "$enable_ssl" = "yes"; then
+  PKG_CHECK_MODULES(SSL, openssl, :, :)
+  if test "$SSL_LIBS"; then
+    CFLAGS="$CFLAGS $SSL_CFLAGS"
+    have_openssl=yes
   else
-    status="`./conftest`"
-    if test "x$status" = "xok"; then
-      DYNLIB_MODULES=yes
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_RESULT([no, error running: $status])
-    fi
+    AC_CHECK_LIB(ssl, SSL_read, [
+      AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
+       SSL_LIBS="-lssl -lcrypto"
+       have_openssl=yes
+      ])
+    ],, -lcrypto)
+  fi
+  if test "$have_openssl" = "yes"; then
+    AC_DEFINE(HAVE_OPENSSL,, Build with OpenSSL support)
+    LIBS="$LIBS $SSL_LIBS"
   fi
 fi
-rm -rf conftest conftest.* libconftest.* .libs
 
 dnl **
-dnl ** curses checks
+dnl ** Garbage Collector
 dnl **
+have_gc=no
+if test "x$want_gc" = xyes; then
+  AC_CHECK_LIB(gc, GC_malloc, [
+    AC_CHECK_HEADER(gc/gc.h, [
+      AC_DEFINE(HAVE_GC_GC_H)
+      AC_DEFINE(USE_GC)
+      LIBS="$LIBS -lgc"
+      have_gc=yes
+    ], [
+      AC_CHECK_HEADER(gc.h, [
+       AC_DEFINE(HAVE_GC_H)
+       AC_DEFINE(USE_GC)
+       LIBS="$LIBS -lgc"
+       have_gc=yes
+      ])
+    ])
+  ])
+fi
 
-dnl Curses detection: Munged from Midnight Commander's configure.in
-dnl
-dnl What it does:
-dnl =============
-dnl
-dnl - Determine which version of curses is installed on your system
-dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
-dnl   symbols 
-dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
-dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
-dnl   Makefile.in's
-dnl - Modify the following configure variables (these are the only
-dnl   curses.m4 variables you can access from within configure.in)
-dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
-dnl                       an ncurses.h that's been renamed to curses.h
-dnl                       is found.
-dnl   CURSES_LIBS       - sets -L and -l's appropriately
-dnl   CFLAGS            - if --with-sco, add -D_SVID3 
-dnl   has_curses        - exports result of tests to rest of configure
-dnl
-dnl Usage:
-dnl ======
-dnl 1) Add lines indicated below to acconfig.h
-dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
-dnl 3) Instead of #include <curses.h> you should use the following to
-dnl    properly locate ncurses or curses header file
-dnl
-dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
-dnl    #include <ncurses.h>
-dnl    #else
-dnl    #include <curses.h>
-dnl    #endif
-dnl
-dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
-dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
-dnl
-dnl Notes with automake:
-dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
-dnl   configure.in
-dnl - your Makefile.am can look something like this
-dnl   -----------------------------------------------
-dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
-dnl   if HAS_CURSES
-dnl   CURSES_TARGETS=name_of_curses_prog
-dnl   endif
-dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
-dnl   other_programs_SOURCES = blah blah blah
-dnl   name_of_curses_prog_SOURCES = blah blah blah
-dnl   other_programs_LDADD = blah
-dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
-dnl   -----------------------------------------------
-dnl
-dnl
-dnl The following lines should be added to acconfig.h:
-dnl ==================================================
-dnl
-dnl /*=== Curses version detection defines ===*/
-dnl /* Found some version of curses that we're going to use */
-dnl #undef HAS_CURSES
-dnl    
-dnl /* Use SunOS SysV curses? */
-dnl #undef USE_SUNOS_CURSES
-dnl 
-dnl /* Use old BSD curses - not used right now */
-dnl #undef USE_BSD_CURSES
-dnl 
-dnl /* Use SystemV curses? */
-dnl #undef USE_SYSV_CURSES
-dnl 
-dnl /* Use Ncurses? */
-dnl #undef USE_NCURSES
-dnl 
-dnl /* If you Curses does not have color define this one */
-dnl #undef NO_COLOR_CURSES
-dnl 
-dnl /* Define if you want to turn on SCO-specific code */
-dnl #undef SCO_FLAVOR
-dnl 
-dnl /* Set to reflect version of ncurses *
-dnl  *   0 = version 1.*
-dnl  *   1 = version 1.9.9g
-dnl  *   2 = version 4.0/4.1 */
-dnl #undef NCURSES_970530
-dnl
-dnl /*=== End new stuff for acconfig.h ===*/
-dnl 
-
-
-AC_DEFUN(AC_CHECK_CURSES,[
-       search_ncurses=true
-       screen_manager=""
-       has_curses=false
-
-       CFLAGS=${CFLAGS--O}
-
-       AC_SUBST(CURSES_LIBS)
-       AC_SUBST(CURSES_INCLUDEDIR)
-
-       AC_ARG_WITH(sco,
-         [  --with-sco              Use this to turn on SCO-specific code],[
-         if test x$withval = xyes; then
-               AC_DEFINE(SCO_FLAVOR)
-               CFLAGS="$CFLAGS -D_SVID3"
-         fi
-       ])
-
-       AC_ARG_WITH(sunos-curses,
-         [  --with-sunos-curses     Used to force SunOS 4.x curses],[
-         if test x$withval = xyes; then
-               AC_USE_SUNOS_CURSES
-         fi
-       ])
-
-       AC_ARG_WITH(osf1-curses,
-         [  --with-osf1-curses      Used to force OSF/1 curses],[
-         if test x$withval = xyes; then
-               AC_USE_OSF1_CURSES
-         fi
-       ])
-
-       AC_ARG_WITH(vcurses,
-         [  --with-vcurses[=incdir] Used to force SysV curses],
-         if test x$withval != xyes; then
-               CURSES_INCLUDEDIR="-I$withval"
-         fi
-         AC_USE_SYSV_CURSES
-       )
-
-       AC_ARG_WITH(ncurses,
-         [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
-         if test x$withval = xno ; then
-               search_ncurses=false
-         elif test x$withval != xyes ; then
-               AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
-         fi
-       )
-
-       if $search_ncurses
-       then
-               AC_SEARCH_NCURSES()
-       fi
-])
-
-
-AC_DEFUN(AC_USE_SUNOS_CURSES, [
-       search_ncurses=false
-       screen_manager="SunOS 4.x /usr/5include curses"
-       AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
-       AC_DEFINE(USE_SUNOS_CURSES)
-       AC_DEFINE(HAS_CURSES)
-       has_curses=true
-       AC_DEFINE(NO_COLOR_CURSES)
-       AC_DEFINE(USE_SYSV_CURSES)
-       CURSES_INCLUDEDIR="-I/usr/5include"
-       CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
-       AC_MSG_RESULT(Please note that some screen refreshs may fail)
-])
-
-AC_DEFUN(AC_USE_OSF1_CURSES, [
-       AC_MSG_RESULT(Using OSF1 curses)
-       search_ncurses=false
-       screen_manager="OSF1 curses"
-       AC_DEFINE(HAS_CURSES)
-       has_curses=true
-       AC_DEFINE(NO_COLOR_CURSES)
-       AC_DEFINE(USE_SYSV_CURSES)
-       CURSES_LIBS="-lcurses"
-])
-
-AC_DEFUN(AC_USE_SYSV_CURSES, [
-       AC_MSG_RESULT(Using SysV curses)
-       AC_DEFINE(HAS_CURSES)
-       has_curses=true
-       AC_DEFINE(USE_SYSV_CURSES)
-       search_ncurses=false
-       screen_manager="SysV/curses"
-       CURSES_LIBS="-lcurses"
-])
-
-dnl AC_ARG_WITH(bsd-curses,
-dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
-dnl    search_ncurses=false
-dnl    screen_manager="Ultrix/cursesX"
-dnl    if test $system = ULTRIX
-dnl    then
-dnl        THIS_CURSES=cursesX
-dnl        else
-dnl        THIS_CURSES=curses
-dnl    fi
-dnl
-dnl    CURSES_LIBS="-l$THIS_CURSES -ltermcap"
-dnl    AC_DEFINE(HAS_CURSES)
-dnl    has_curses=true
-dnl    AC_DEFINE(USE_BSD_CURSES)
-dnl    AC_MSG_RESULT(Please note that some screen refreshs may fail)
-dnl    AC_WARN(Use of the bsdcurses extension has some)
-dnl    AC_WARN(display/input problems.)
-dnl    AC_WARN(Reconsider using xcurses)
-dnl)
-
-       
-dnl
-dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
-dnl
-AC_DEFUN(AC_NCURSES, [
-    if $search_ncurses
-    then
-        if test -f $1/$2
-       then
-           AC_MSG_RESULT(Found ncurses on $1/$2)
-
-           CURSES_LIBS="$3"
-           AC_CHECK_LIB(ncurses, initscr, [
-           ], [
-                CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
-               AC_CHECK_LIB(curses, initscr, [
-                       CURSES_LIBS="$CHECKLIBS"
-               ],, $CHECKLIBS)
-           ], $CURSES_LIBS)
-           CURSES_INCLUDEDIR="$4"
-           search_ncurses=false
-           screen_manager=$5
-            AC_DEFINE(HAS_CURSES)
-            has_curses=true
-           has_ncurses=true
-           AC_DEFINE(USE_NCURSES)
-       fi
-    fi
-])
-
-AC_DEFUN(AC_SEARCH_NCURSES, [
-    AC_CHECKING("location of ncurses.h file")
-
-    AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
-    AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
-    AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
-    AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
-    AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
-    AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
-
-    AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
-
-    AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
-
-    dnl
-    dnl We couldn't find ncurses, try SysV curses
-    dnl
-    if $search_ncurses 
-    then
-        AC_EGREP_HEADER(init_color, /usr/include/curses.h,
-           AC_USE_SYSV_CURSES)
-       AC_EGREP_CPP(USE_NCURSES,[
-#include <curses.h>
-#ifdef __NCURSES_H
-#undef USE_NCURSES
-USE_NCURSES
-#endif
-],[
-       CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
-        AC_DEFINE(HAS_CURSES)
-       has_curses=true
-       has_ncurses=true
-        AC_DEFINE(USE_NCURSES)
-        search_ncurses=false
-        screen_manager="ncurses installed as curses"
-])
-    fi
-
-    dnl
-    dnl Try SunOS 4.x /usr/5{lib,include} ncurses
-    dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
-    dnl should be replaced by a more fine grained selection routine
-    dnl
-    if $search_ncurses
-    then
-       if test -f /usr/5include/curses.h
-       then
-           AC_USE_SUNOS_CURSES
-        fi
-    fi
-
-    dnl use whatever curses there happens to be
-    if $search_ncurses
-    then
-       if test -f /usr/include/curses.h
-       then
-         CURSES_LIBS="-lcurses"
-         AC_DEFINE(HAS_CURSES)
-         has_curses=true
-         search_ncurses=false
-         screen_manager="curses"
-       fi
-    fi
-])
+dnl **
+dnl ** curses checks
+dnl **
 
 if test "x$want_textui" = "xyes"; then
        AC_CHECK_CURSES
 
-       if test "x$has_ncurses" != "x"; then
-               AC_CHECK_LIB(ncurses, use_default_colors, [
-                       AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS)
-               ],, $CURSES_LIBS)
-               AC_CHECK_LIB(ncurses, idcok, [
-                       AC_DEFINE(HAVE_CURSES_IDCOK)
-               ],, $CURSES_LIBS)
-               AC_CHECK_LIB(ncurses, resizeterm, [
-                       AC_DEFINE(HAVE_CURSES_RESIZETERM)
-               ],, $CURSES_LIBS)
-               AC_CHECK_LIB(ncurses, wresize, [
-                       AC_DEFINE(HAVE_CURSES_WRESIZE)
-               ],, $CURSES_LIBS)
-       elif test "x$has_curses" = "xtrue"; then
-               AC_CHECK_LIB(curses, idcok, [
-                       AC_DEFINE(HAVE_CURSES_IDCOK)
-               ],, $CURSES_LIBS)
-               AC_CHECK_LIB(curses, resizeterm, [
-                       AC_DEFINE(HAVE_CURSES_RESIZETERM)
-               ],, $CURSES_LIBS)
-               AC_CHECK_LIB(curses, wresize, [
-                       AC_DEFINE(HAVE_CURSES_WRESIZE)
-               ],, $CURSES_LIBS)
+       TEXTUI_LIBS="$CURSES_LIBS"
+       if test "x$has_curses" = "xtrue"; then
+               old_libs=$LIBS
+               LIBS="$LIBS $CURSES_LIBS"
+               if test $want_terminfo = no; then
+                       AC_CHECK_FUNC(use_default_colors, AC_DEFINE(HAVE_NCURSES_USE_DEFAULT_COLORS))
+                       AC_CHECK_FUNC(idcok, AC_DEFINE(HAVE_CURSES_IDCOK))
+                       AC_CHECK_FUNC(resizeterm, AC_DEFINE(HAVE_CURSES_RESIZETERM))
+                       AC_CHECK_FUNC(wresize, AC_DEFINE(HAVE_CURSES_WRESIZE))
+               fi
+               AC_CHECK_FUNC(setupterm,, [
+                       want_termcap=yes
+               ])
+               LIBS=$old_libs
        else
-               want_textui=no
-               curses_error=yes
-        fi
-else
-       has_curses=false
+               AC_CHECK_LIB(tinfo, setupterm, [
+                 TEXTUI_LIBS="-ltinfo"
+                 want_terminfo=yes
+               ], AC_CHECK_LIB(termlib, tgetent, [
+                 TEXTUI_LIBS="-ltermlib"
+                 want_termcap=yes
+               ], AC_CHECK_LIB(termcap, tgetent, [
+                 TEXTUI_LIBS="-ltermcap"
+                 want_termcap=yes
+               ], [
+                 AC_ERROR(Terminfo/termcap not found - install ncurses-devel package)
+                 want_textui=no
+               ])))
+       fi
+       AC_SUBST(TEXTUI_LIBS)
+
+       if test "x$want_termcap" = "xyes"; then
+               AC_CHECK_FUNC(tparm,, need_tparm=yes)
+       else
+               AC_DEFINE(HAVE_TERMINFO)
+       fi
 fi
 
 dnl **
@@ -746,52 +422,36 @@ dnl ** perl checks
 dnl **
 
 if test "$want_perl" != "no"; then
-       AC_PATH_PROG(perlpath, perl)
        AC_MSG_CHECKING(for working Perl support)
 
-       if test "x$perlpath" = "x"; then
-                       perl_check_error="perl binary not found"
+       if test -z "$perlpath"; then
+               perl_check_error="perl binary not found"
        else
                PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
        fi
 
-       if test "x$PERL_CFLAGS" = "x"; then
-               perl_check_error="Error getting perl CFLAGS"
+       if test "x$ac_cv_prog_gcc" = "xyes" -a -z "`echo $host_os|grep 'bsd\|linux'`"; then
+               dnl * several systems have Perl compiled with native compiler
+               dnl * but irssi is being compiled with GCC. Here we try to
+               dnl * fix those command line options a bit so GCC won't
+               dnl * complain about them. Normally there's only few options
+               dnl * that we want to keep:
+               dnl * -Ddefine -Uundef -I/path -fopt -mopt
+               PERL_CFLAGS=`echo $PERL_CFLAGS | $perlpath -pe 's/^(.* )?-[^DUIfm][^ ]+/\1/g; s/^(.* )?\+[^ ]+/\1/g'`
+
+               PERL_EXTRA_OPTS="CCCDLFLAGS=\"-fPIC\""
+               AC_SUBST(PERL_EXTRA_OPTS)
+       fi
+
+       if test -z "$PERL_CFLAGS"; then
+               if test -n "$perl_check_error"; then
+                       perl_check_error="Error getting perl CFLAGS"
+               fi
                AC_MSG_RESULT([not found, building without Perl])
                want_perl=no
        else
                PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts 2>/dev/null`
 
-               dnl * Perl 5.004 and older use perl_xxx variables while
-               dnl * later use PL_perl_xxx variables ..
-               have_pl_perl=`$perlpath -e 'print $] < 5.005 ? "no" : "yes";'`
-                if test "x$have_pl_perl" = "xyes"; then
-                       AC_DEFINE(HAVE_PL_PERL)
-               fi
-
-               if test "x$DYNLIB_MODULES" = "xno" -a "$want_perl" != "static"; then
-                       dnl * wanted perl as module, won't get it.
-                       want_perl=static
-                       perl_mod_error="Dynamic library dependencies don't work with modules"
-               fi
-
-               if test "$want_perl" != "static"; then
-                       dnl * dynaloader.a -> libperl_dynaloader.la
-                       DYNALOADER_A=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*([[^ ]]*DynaLoader\.a).*/\2/'`
-               fi
-
-               dnl * don't check libperl.a if dynaloader.a wasn't found..
-               if test "x$DYNALOADER_A" != "x"; then
-                       dnl * find either libperl.a or libperl.so
-                       LIBPERL_A=`echo "$PERL_LDFLAGS -L/usr/lib"|$perlpath -e 'foreach (split(/ /, <STDIN>)) { if (/^-L(.*)/) { my $dir=$1; if (\`ls $dir/libperl.so* 2>/dev/null\`) { print "-lperl"; last; }; if (-e "$dir/libperl.a") { print "$dir/libperl.a"; last } } };'`
-                       if test "x$LIBPERL_A" = "x"; then
-                               perl_mod_error="Didn't find location of -lperl"
-                               DYNALOADER_A=
-                       elif test "$LIBPERL_A" = "-lperl"; then
-                               LIBPERL_A=
-                       fi
-               fi
-
                dnl * remove all database stuffs
                dnl * nsl is already in ldflags
                dnl * libc is of course linked without needing -lc
@@ -815,44 +475,25 @@ if test "$want_perl" != "no"; then
                esac
 
                dnl * check that perl's ldflags actually work
-               AC_CACHE_VAL(irssi_cv_lib_perl_works, [
-                       echo "main(){perl_alloc(); return 0;}" > conftest.c
-                       $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> /dev/null > /dev/null
-                       if test -s conftest; then
-                               irssi_cv_lib_perl_works=yes
-                       else
-                               irssi_cv_lib_perl_works=no
-                       fi
-               ])
-
-               if test "x$irssi_cv_lib_perl_works" = "xno"; then
-                       perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS"
+               echo "main(){perl_alloc(); return 0;}" > conftest.c
+               $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null
+               if test ! -s conftest -a "x$ignore_perl_errors" = "x"; then
+                       perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS: `cat perl.error.tmp`"
                        AC_MSG_RESULT([error linking with perl libraries, building without Perl])
                        want_perl=no
                fi
+
+               rm -f perl.error.tmp
        fi
 
        if test "x$want_perl" != "xno"; then
-               if test "x$want_perl" = "xstatic"; then
-                       AC_MSG_RESULT(ok)
-               elif test "x$DYNALOADER_A" = "x"; then
-                       AC_MSG_RESULT([error parsing ldopts, building Perl into irssi binary instead of as module])
-                       want_perl=static
-               else
-                       AC_MSG_RESULT(ok)
-                       PERL_LDFLAGS=`echo $PERL_LDFLAGS | $perlpath -pe 's/^(.* )*[[^ ]]*DynaLoader\.a/\1libperl_dynaloader.la/'`
-                       if test "x$LIBPERL_A" != "x"; then
-                               PERL_LDFLAGS=`echo $PERL_LDFLAGS | $sedpath -e 's/-lperl /libperl_orig.la /' -e 's/-lperl$/libperl_orig.la$/'`
-                       fi
-                       AC_SUBST(LIBPERL_A)
-                       AC_SUBST(DYNALOADER_A)
-               fi
+               AC_MSG_RESULT(ok)
 
                if test "x$want_perl" = "xstatic"; then
                        dnl * building with static perl support
                        dnl * all PERL_LDFLAGS linking is done in fe-text
-                       PERL_LDFLAGS="../perl/libperl_static.la $PERL_LDFLAGS"
-                       PERL_LINK_LIBS="$PERL_LDFLAGS"
+                       PERL_LINK_FLAGS="$PERL_LDFLAGS"
+                       PERL_LINK_LIBS="../perl/libperl_core_static.la"
                        PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
                        PERL_LDFLAGS=
                        AC_DEFINE(HAVE_STATIC_PERL)
@@ -860,31 +501,48 @@ if test "$want_perl" != "no"; then
                        dnl * build only static library of perl module
                        perl_module_lib=
                        perl_module_fe_lib=
-                       perl_static_lib=libperl_static.la
+                       perl_static_lib=libperl_core_static.la
                        perl_static_fe_lib=libfe_perl_static.la
-                       PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool'
                else
-                       dnl * build dynamic library of perl module,
-                       dnl * use libtool-shared to prevent creating of
-                       dnl * libperl.a
+                       dnl * build dynamic library of perl module
                        perl_module_lib=libperl_core.la
                        perl_module_fe_lib=libfe_perl.la
                        perl_static_lib=
                        perl_static_fe_lib=
-                       PERL_LIBTOOL='$(SHELL) $(top_builddir)/libtool-shared'
                fi
+
+               if test "x$want_staticperllib" = "xyes"; then
+                       PERL_MM_PARAMS="$PERL_MM_PARAMS LINKTYPE=static"
+                       PERL_LINK_LIBS="$PERL_LINK_LIBS ../perl/common/blib/arch/auto/Irssi/Irssi.a ../perl/irc/blib/arch/auto/Irssi/Irc/Irc.a ../perl/ui/blib/arch/auto/Irssi/UI/UI.a ../perl/textui/blib/arch/auto/Irssi/TextUI/TextUI.a"
+                       PERL_STATIC_LIBS=1
+               else
+                       PERL_STATIC_LIBS=0
+               fi
+
+               # figure out the correct @INC path - we'll need to do this
+               # through MakeMaker since it's difficult to get it right
+               # otherwise.
+               if test "x$perl_set_use_lib" = "xyes"; then
+                       perl -e 'use ExtUtils::MakeMaker; WriteMakefile("NAME" => "test", "MAKEFILE" => "Makefile.test");' $PERL_MM_PARAMS >/dev/null
+                       PERL_USE_LIB=`perl -e 'open(F, "Makefile.test"); while (<F>) { chomp; if (/^(\w+) = (.*$)/) { $keys{$1} = $2; } }; $key = $keys{INSTALLARCHLIB}; while ($key =~ /\\$\((\w+)\)/) { $value = $keys{$1}; $key =~ s/\\$\($1\)/$value/; }; print $key;'`
+                       rm -f Makefile.test
+               fi
+
                AC_SUBST(perl_module_lib)
                AC_SUBST(perl_static_lib)
                AC_SUBST(perl_module_fe_lib)
                AC_SUBST(perl_static_fe_lib)
-               AC_SUBST(PERL_LIBTOOL)
 
+               AC_SUBST(PERL_LINK_FLAGS)
                AC_SUBST(PERL_LINK_LIBS)
                AC_SUBST(PERL_FE_LINK_LIBS)
 
                AC_SUBST(PERL_LDFLAGS)
                AC_SUBST(PERL_CFLAGS)
-               AC_SUBST(PERL_LIB_DIR)
+
+               AC_SUBST(PERL_USE_LIB)
+               AC_SUBST(PERL_MM_PARAMS)
+               AC_SUBST(PERL_STATIC_LIBS)
        fi
 fi
 
@@ -892,11 +550,13 @@ dnl ** check what we want to build
 AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
 AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
 AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
-AM_CONDITIONAL(BUILD_PLUGINS, test "$want_plugins" = "yes")
-AM_CONDITIONAL(BUILD_SERVERTEST, test "x$TEST_DIR" != "x")
 AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
-AM_CONDITIONAL(HAVE_STATIC_PERL, test "$want_perl" = "static")
+AM_CONDITIONAL(NEED_TPARM, test "$need_tparm" = "yes")
+AM_CONDITIONAL(USE_CURSES, test "$want_terminfo" != "yes" -a "$want_termcap" != "yes")
 
+# move LIBS to PROG_LIBS so they're not tried to be used when linking eg. perl libraries
+PROG_LIBS=$LIBS
+LIBS=
 AC_SUBST(PROG_LIBS)
 
 dnl **
@@ -907,17 +567,16 @@ dnl ** (these could be made configurable)
 
 CHAT_MODULES="silc"
 silc_MODULES=""
-if test "x$build_modules" != "x"; then
+if test -n "$build_modules"; then
        silc_MODULES="$silc_MODULES $build_modules"
 fi
-#PROG_LIBS="$PROG_LIBS -lsilc"
 
 dnl ****************************************
 
 AC_SUBST(CHAT_MODULES)
 AC_SUBST(silc_MODULES)
 
-CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a ../lib-popt/libpopt.a"
+CORE_LIBS="../core/libcore.a ../lib-config/libirssi_config.a"
 FE_COMMON_LIBS=""
 
 CHAT_LIBS=""
@@ -931,73 +590,94 @@ for c in $CHAT_MODULES; do
                FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/libfe_common_$c.a "
        fi
        for s in `eval echo \\$${c}_MODULES`; do
-               CHAT_LIBS="$CHAT_LIBS ../$c/$s/.libs/lib${c}_$s.a"
+               CHAT_LIBS="$CHAT_LIBS ../$c/$s/lib${c}_$s.a"
                module_inits="$module_inits ${c}_${s}_init();"
                module_deinits="${c}_${s}_deinit(); $module_deinits"
                if test -f $srcdir/src/fe-common/$c/$s/module.h; then
-                       FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/.libs/libfe_${c}_$s.a "
+                       FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/$c/$s/libfe_${c}_$s.a "
                        fe_module_inits="$fe_module_inits fe_${c}_${s}_init();"
                        fe_module_deinits="fe_${c}_${s}_deinit(); $fe_module_deinits"
                fi
        done
 
-       file="$srcdir/src/$c/$c.c"
-        echo "/* this file is automatically generated by configure - don't change */" > $file
-       echo "void ${c}_core_init(void); void ${c}_core_init_finish(void); void ${c}_core_deinit(void);" >> $file
-       if test "x$module_inits" != "x"; then
-               echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
-               echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
+       mkdir -p src/$c
+       file="src/$c/$c.c"
+       echo "/* this file is automatically generated by configure - don't change */" > $file
+       echo "void ${c}_core_init(void); void ${c}_core_deinit(void);" >> $file
+       if test -n "$module_inits"; then
+               echo "$module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
+               echo "$module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
        fi
-        echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
-        echo "void ${c}_init_finish(void) { ${c}_core_init_finish(); $module_inits }" >> $file
-        echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
+       echo "void ${c}_init(void) { ${c}_core_init(); $module_inits }" >> $file
+       echo "void ${c}_deinit(void) { $module_deinits ${c}_core_deinit(); }" >> $file
 
        if test -f $srcdir/src/fe-common/$c/module.h; then
-               file="$srcdir/src/fe-common/$c/${c}-modules.c"
-               echo "/* this file is automatically generated by configure - don't change */" > $file
-                if test "x$fe_module_inits" != "x"; then
-                       echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
-                       echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
+               mkdir -p src/fe-common/$c
+               file="src/fe-common/$c/${c}-modules.c"
+               echo "/* this file is automatically generated by configure - don't change */" > $file
+               if test -n "$fe_module_inits"; then
+                       echo "$fe_module_inits" | $sedpath -e 's/()/(void)/g' -e 's/ /void /g' >> $file
+                       echo "$fe_module_deinits" | $sedpath -e 's/ *$//' -e 's/()/(void)/g' -e 's/ /void /g' -e 's/^/void /' >> $file
                fi
-               echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
-               echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
+               echo "void fe_${c}_modules_init(void) { $fe_module_inits }" >> $file
+               echo "void fe_${c}_modules_deinit(void) { $fe_module_deinits }" >> $file
        fi
 done
 
 FE_COMMON_LIBS="$FE_COMMON_LIBS../fe-common/core/libfe_common_core.a"
 
 dnl ** common libraries needed by frontends
-COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS $INTLLIBS"
+COMMON_NOUI_LIBS="$CHAT_LIBS $CORE_LIBS"
 COMMON_LIBS="$FE_COMMON_LIBS $COMMON_NOUI_LIBS"
 AC_SUBST(COMMON_NOUI_LIBS)
 AC_SUBST(COMMON_LIBS)
 
 dnl **
-dnl ** memory debugging
+dnl ** IPv6 support
 dnl **
 
-if test "x$want_memdebug" = "xyes"; then
-       AC_DEFINE(MEM_DEBUG)
+have_ipv6=no
+if test "x$want_ipv6" = "xyes"; then
+       AC_MSG_CHECKING([for IPv6])
+       AC_CACHE_VAL(irssi_cv_type_in6_addr,
+       [AC_TRY_COMPILE([
+       #include <sys/types.h>
+       #include <sys/socket.h>
+       #include <netinet/in.h>
+       #include <netdb.h>
+       #include <arpa/inet.h>],
+       [struct in6_addr i;],
+       have_ipv6=yes,
+       )])
+       if test $have_ipv6 = yes; then
+               AC_DEFINE(HAVE_IPV6)
+       fi
+       AC_MSG_RESULT($have_ipv6)
 fi
-AM_CONDITIONAL(BUILD_MEMDEBUG, test "x$want_memdebug" = "xyes")
-
-dnl **
-dnl ** tr-Chinese Big5 support
-dnl **
 
-if test "x$want_big5" = "xyes"; then
-       AC_DEFINE(WANT_BIG5)
+if test "x$want_dane" = "xyes"; then
+       AC_MSG_CHECKING([for DANE])
+       AC_CHECK_LIB(val-threads, val_getdaneinfo,
+       [
+               LIBS="$LIBS -lval-threads -lsres"
+               AC_DEFINE([HAVE_DANE], [], [DANE support])
+               have_dane=yes
+       ], [], [-lssl -lcrypto -lsres -lpthread])
+
+       if test x$have_dane = "xyes" ; then
+               if test x$have_openssl = "xno" ; then
+                       AC_ERROR([SSL is required to build Irssi with DANE support enabled.])
+               fi
+       fi
 fi
 
-dnl **
-dnl ** IPv6 support
-dnl **
-
-if test "x$want_ipv6" = "xyes"; then
-       AC_DEFINE(HAVE_IPV6)
-fi
+#
+# Glue into SILC build system
+#
+INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
+AC_SUBST(INCLUDE_DEFINES_INT)
 
-AC_OUTPUT(
+AC_CONFIG_FILES([
 Makefile
 src/Makefile
 src/core/Makefile
@@ -1006,23 +686,33 @@ src/fe-common/core/Makefile
 src/fe-common/silc/Makefile
 src/fe-text/Makefile
 src/lib-config/Makefile
-src/lib-popt/Makefile
 src/silc/Makefile
 src/silc/core/Makefile
+src/perl/Makefile
+src/perl/common/Makefile.PL
+src/perl/ui/Makefile.PL
+src/perl/textui/Makefile.PL
+src/perl/silc/Makefile.PL
+scripts/Makefile
+scripts/examples/Makefile
 docs/Makefile
 docs/help/Makefile
 docs/help/in/Makefile
-stamp.h
-irssi.spec
 irssi-version.h
-irssi-config)
+irssi-config
+])
 
-dnl ** for building from objdir
-if test "x$want_perl" != "xno"; then
-       old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
+AC_OUTPUT
 
-       if test "x$old_dir" != "x$whole_dir"; then
-               for file in $whole_dir/src/perl/*.[[ch]] $whole_dir/src/perl/libperl_orig.la $whole_dir/src/perl/libperl_dynaloader.la $whole_dir/src/perl/common/typemap $whole_dir/src/perl/common/module.h $whole_dir/src/perl/common/*.xs $whole_dir/src/perl/irc/typemap $whole_dir/src/perl/irc/module.h $whole_dir/src/perl/irc/*.xs; do
+dnl ** for building from objdir
+old_dir=`pwd` && cd $srcdir && whole_dir=`pwd` && cd $old_dir
+if test "x$old_dir" != "x$whole_dir"; then
+       if test "x$want_perl" != "xno"; then
+               subdirfiles=""
+               for i in $whole_dir/src/perl/common $whole_dir/src/perl/irc $whole_dir/src/perl/ui $whole_dir/src/perl/textui; do
+                       subdirfiles=`echo $subdirfiles $i/typemap $i/module.h $i/*.pm $i/*.xs`
+               done
+               for file in $whole_dir/src/perl/module.h $subdirfiles; do
                        link=`echo $file|$sedpath "s?$whole_dir/??"`
                        rm -f $link
                        $LN_S $file $link
@@ -1032,27 +722,35 @@ fi
 
 echo
 
-if test "x$curses_error" != "xyes"; then
-       echo "Building text frontend ..... : $want_textui"
+if test "x$want_textui" = "xno"; then
+       text=no
+elif test "x$want_termcap" = "xyes"; then
+       text="yes, using termcap"
+elif test "x$want_terminfo" = "xyes"; then
+       text="yes, using terminfo"
 else
-       echo "Building text frontend ..... : NO!!"
-       echo " - Because curses was not found, specify the path to it with"
-       echo "   --with-curses=/dir and make sure you have the curses headers"
-       echo "   installed (usually in ncurses-devel package)"
+       text="yes, using curses"
+fi
+echo "Building text frontend ........... : $text"
+echo "Building irssi bot ............... : $want_irssibot"
+echo "Building irssi proxy ............. : $want_irssiproxy"
+if test "x$have_gmodule" = "xyes"; then
+       echo "Building with module support ..... : yes"
+else
+       echo "Building with module support : NO!! /LOAD will not work!"
+       echo " - You're missing gmodule (comes with glib) for some reason,"
+       echo "   or it doesn't work in your system."
 fi
-echo "Building irssi bot ......... : $want_irssibot"
-echo "Building irssi proxy ....... : $want_irssiproxy"
-echo "Building with IPv6 support . : $want_ipv6"
 
 if test "x$want_perl" = "xstatic"; then
-       echo "Building with Perl support . : static (in irssi binary)"
-elif test "x$want_perl" = "xyes"; then
-       echo "Building with Perl support . : module"
+       echo "Building with Perl support ....... : static (in irssi binary)"
+elif test "x$want_perl" = "xmodule"; then
+       echo "Building with Perl support ....... : module"
 else
-       if test "x$perl_check_error" = "x"; then
-               echo "Building with Perl support . : no"
+       if test -z "$perl_check_error"; then
+               echo "Building with Perl support ....... : no"
        else
-               echo "Building with Perl support . : NO!"
+               echo "Building with Perl support ....... : NO!"
                echo " - $perl_check_error"
        fi
 fi
@@ -1061,21 +759,36 @@ if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then
        echo " - NOTE: Perl support will be compiled statically to irssi, not as"
        echo "   a module as requested. Reason:"
        echo "   $perl_mod_error"
+
+       if test -f /etc/debian_version; then
+               echo " - Try: apt-get install libperl-dev"
+       fi
 fi
 
-if test "x$want_perl" = "xyes"; then
-       if test "x$PERL_LIB_DIR" = "x"; then
-               echo "Perl library directory ..... : (default - usually /usr/local/lib/perl_site)"
-       else
-               echo "Perl library directory ..... : $PERL_LIB_DIR"
-               if test "x$perl_lib_dir_given" != "xyes"; then
-                       echo " - NOTE: This was automatically set to the same directory you gave with"
-                       echo "   --prefix. If you want the perl libraries to install to their 'correct'"
-                       echo "   path, you'll need to give --enable-perl-path= (nothing after '=') option"
-                       echo "   to configure. Anyway, installing perl to this directory should work"
-                       echo "   just as well.."
-               fi
+if test "x$want_perl" != "xno"; then
+       if test "$perl_library_dir" = "PERL_USE_LIB"; then
+               perl_library_dir=$PERL_USE_LIB
+       fi
+       if test -z "$perl_library_dir"; then
+               perl_library_dir="(site default - `$perlpath -e 'use Config; print $Config{sitearch}'`)"
+       fi
+       echo "Perl library directory ........... : $perl_library_dir"
+       if test "x$perl_prefix_note" = "xyes"; then
+               echo "  - NOTE: This was automatically set to the same directory you gave with"
+               echo "  --prefix. If you want the perl libraries to install to their 'correct'"
+               echo "  path, you'll need to give --with-perl-lib=site option to configure."
+               echo "  Anyway, installing perl to this directory should work just as well."
        fi
 fi
-echo "Install prefix ............. : $prefix"
+echo "Install prefix ................... : $prefix"
+
+echo
+
+echo "Building with IPv6 support ....... : $have_ipv6"
+echo "Building with SSL support ........ : $have_openssl"
+echo "Building with 64bit DCC support .. : $offt_64bit"
+echo "Building with garbage collector .. : $have_gc"
+echo "Building with DANE support ....... : $have_dane"
 
+echo
+echo "If there are any problems, read the INSTALL file."