dnl =======================================================
dnl FILE: ./admin/configure.in.min
dnl =======================================================

dnl    This file is part of the KDE libraries/packages
dnl    Copyright (C) 2001 Stephan Kulow (coolo@kde.org)
 
dnl    This file is free software; you can redistribute it and/or
dnl    modify it under the terms of the GNU Library General Public
dnl    License as published by the Free Software Foundation; either
dnl    version 2 of the License, or (at your option) any later version.
 
dnl    This library is distributed in the hope that it will be useful,
dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl    Library General Public License for more details.
 
dnl    You should have received a copy of the GNU Library General Public License
dnl    along with this library; see the file COPYING.LIB.  If not, write to
dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dnl    Boston, MA 02111-1307, USA.

# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas

dnl Process this file with autoconf to produce a configure script.

AC_INIT(acinclude.m4) dnl a source file from your sub dir

dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)

dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH

dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM 
dnl Perform program name transformation
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(sim, 0.9.5) dnl searches for some needed programs

AC_ARG_ENABLE(kde,
    AC_HELP_STRING([--disable-kde],[don't use kde]),
    use_kde=$enableval, use_kde=yes)

if test "$use_kde" = "yes"; then
  KDE_SET_PREFIX
else
  SIM_SET_PREFIX
  KDE_FAST_CONFIGURE
fi

dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done

dnl Checks for programs.
AC_CHECK_COMPILERS
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
AC_LIBTOOL_DLOPEN
KDE_PROG_LIBTOOL

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS
if test "x$use_kde" != "xyes"; then
  KDE_CHECK_STL
  include_ARTS_TRUE='#'
  include_ARTS_FALSE=
fi
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================

#MIN_CONFIG
AC_PREREQ(2.50)
AC_LANG_CPLUSPLUS
dnl PACKAGE set before
AC_PROG_LIBTOOL
AC_STDC_HEADERS
AC_C_BIGENDIAN
KDE_NEED_FLEX
LFLAGS="-o${LEX_OUTPUT_ROOT}.c"
AC_SUBST(LFLAGS)
if test "$CYGWIN" = "yes"; then
 LDFLAGS="$LDFLAGS --enable-auto-import"
fi
if ! echo $CXXFLAGS | fgrep '-fno-strict-aliasing' >/dev/null 2>&1 ; then 
	old_cxxflags=$CXXFLAGS 
    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" 
    AC_TRY_COMPILE([], [return 0;], , CXXFLAGS=$old_cxxflags) 
fi 
RELEASE_BUILD="no"
AC_ARG_ENABLE(
 release,
 [  --enable-release        enable release build],
 RELEASE_BUILD="$enableval")
if test "$RELEASE_BUILD" != "yes"; then
 AC_DEFINE(CVS_BUILD, 1, [CVS build])
fi

AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_STRUCT_TM

AC_PATH_X
if test $have_x = yes; then
   AC_DEFINE(HAVE_X,1,[Have X Window System])
fi

AC_HEADER_SYS_WAIT
AC_FUNC_FORK
AC_C_INLINE
AC_C_CONST
KDE_CHECK_SSL
AC_HEADER_STDBOOL
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MMAP
AC_FUNC_MKTIME
AC_FUNC_MEMCMP
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT

AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
  AC_TRY_COMPILE([
    #include <time.h>
  ], [
    struct tm tm;
    tm.tm_gmtoff = 1;
  ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
if test $ac_cv_struct_tm_gmtoff = yes; then
  AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if you have a tm_gmtoff member in struct tm])
fi

AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h])
AC_CHECK_HEADERS([fcntl.h limits.h netdb.h stddef.h termios.h])

AC_CHECK_FUNCS([dup2 gethostbyname gethostname inet_ntoa])
AC_CHECK_FUNCS([memset mkdir munmap rmdir socket])
AC_CHECK_FUNCS([strcspn strdup strerror strstr strtol strtoul])

AC_CHECK_FUNC(strcasecmp,[AC_DEFINE(HAVE_STRCASECMP,1,[Have strcasecmp])])
AC_CHECK_FUNC(chmod,[AC_DEFINE(HAVE_CHMOD,1,[Have chmod])])
AC_CHECK_FUNC(uname,[AC_DEFINE(HAVE_UNAME,1,[Have uname])])

AC_EGREP_HEADER(in_addr_t, netinet/in.h,, AC_DEFINE(in_addr_t,int,[defaults in_addr_t to int]))
AC_EGREP_HEADER(socklen_t, sys/socket.h,, AC_DEFINE(socklen_t,int,[defaults socklen_t to int]))

AC_CHECK_LIB(xnet,inet_addr)
AC_CHECK_LIB(socket, socket)

AC_MSG_CHECKING([for The Ultimate Answer])
AC_MSG_RESULT([42])

EXTRA_LIBS=""
KDE_CHECK_HEADER(qsyntaxhighlighter.h,[AC_DEFINE(HAVE_QSYNTAXHIGHLIGHTER_H,1,[Have qsyntaxhighlighter.h])])
AC_DEFINE_UNQUOTED(PREFIX, "$prefix", [Install prefix])
AC_SUBST(EXTRA_LIBS)
if test "${exec_prefix}" = "NONE" ; then
  exec_prefix=$prefix
fi
libdir=`eval echo $libdir`

sim_plugindir="${libdir}/sim"
sim_stylesdir="\${sim_plugindir}/styles"
AC_SUBST(sim_plugindir)
AC_SUBST(sim_stylesdir)
AC_DEFINE_UNQUOTED(PLUGIN_PATH,"${sim_plugindir}",[Plugins path])

LIB_XML2=""
AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
if test "x$XML2_CONFIG" = "xno" ; then
   AC_MSG_ERROR([Executable xml2-config not found!
Seems you have no libxml2 devel files installed.
You can download it from http://xmlsoft.org/download.html
])
fi

LIB_XML2=`$XML2_CONFIG --libs 2>/dev/null`
CPPFLAGS="$CPPFLAGS `$XML2_CONFIG --cflags`"

LIB_XSLT=""
AC_PATH_PROG(XSLT_CONFIG, xslt-config, no)
if test "x$XSLT_CONFIG" = "xno" ; then
   AC_MSG_ERROR([Executable xslt-config not found!
Seems you have no libxslt devel files installed.
You can download it from http://xmlsoft.org/download.html
])
fi

LIB_XSLT=`$XSLT_CONFIG --libs 2>/dev/null`
CPPFLAGS="$CPPFLAGS `$XSLT_CONFIG --cflags`"

AC_SUBST(LIB_XML2)
AC_SUBST(LIB_XSLT)

ZIP_FLAGS="-j"
AC_PATH_PROG(ZIP, zip, no)
if test "x$ZIP" = "xno" ; then
   AC_MSG_ERROR([Executable zip not found!])
fi
AC_SUBST(ZIP)
AC_SUBST(ZIP_FLAGS)

if test "$have_ssl" != "yes" -a "$want_ssl" != "no"; then
  AC_MSG_ERROR([SIM requires OpenSSL library.
Please install OpenSSL (libraries and headers).
OpenSSL can be found at http://www.openssl.org
or as RPM from your local distribution site.
])
fi

AM_CONDITIONAL(QT_WIN, test "$kde_use_qt_win" = "yes")

if test "$kde_use_qt_win" = "yes"; then
   AC_SUBST(SIM_RC_OBJ, "sim_rc.o")
   AC_SUBST(GMSGFMT, "$GMSGFMT --qt")
   AC_DEFINE(SIMAPI_EXPORTS, 1, [build libsim.dll])
fi

AM_CONDITIONAL(ENABLE_UPDATE, false)
AM_CONDITIONAL(ENABLE_STYLES_WOOD, false)
AM_CONDITIONAL(ENABLE_STYLES_METAL, false)

dnl =======================================================
dnl FILE: ./plugins/__homedir/configure.in.in
dnl =======================================================

if test "$kde_use_qt_win" = "yes"; then
	__HOMEDIR_OBJ=homedircfg.lo
	AC_SUBST([__HOMEDIR_OBJ])
fi

dnl =======================================================
dnl FILE: ./plugins/autoaway/configure.in.in
dnl =======================================================

if test "x$kde_use_qt_win" = "xno"; then
	compile_plugin="no"
	save_CPPFLAGS="$CPPFLAGS"
	save_LDFLAGS="$LDFLAGS"
	LDFLAGS="$LDFLAGS $all_libraries"
	CPPFLAGS="$CPPFLAGS $X_INCLUDES"
	AC_CHECK_LIB(Xext, XScreenSaverRegister,[XSS_LIBS=""],[], [-lX11 -lXext -lm])
	AC_CHECK_LIB(Xss, XScreenSaverRegister,[XSS_LIBS="-lXss"],[],[-lX11 -lXext -lm])
	if test \! "$XSS_LIBS" = "no"; then
		KDE_CHECK_HEADER(X11/extensions/scrnsaver.h,[compile_plugin="yes"],[])
	else
		XSS_LIBS=""
		AC_CHECK_HEADER(Carbon/Carbon.h,[compile_plugin="yes"])
	fi
	AC_SUBST(XSS_LIBS)
	if test "x$compile_plugin" = "xno"; then
		AC_MSG_WARN([ScreenSaver extension not found. AutoAway plugin is disabled])
	fi
	AM_CONDITIONAL(ENABLE_AUTOAWAY, test "x$compile_plugin" = "xyes")
else
	AM_CONDITIONAL(ENABLE_AUTOAWAY, true)
fi

dnl =======================================================
dnl FILE: ./plugins/gpg/configure.in.in
dnl =======================================================

if test "$kde_use_qt_win" = "yes"; then
	GPG_OBJ=gpgfind.lo
	AC_SUBST([GPG_OBJ])
fi

dnl =======================================================
dnl FILE: ./plugins/icq/configure.in.in
dnl =======================================================

if test "$have_ssl" != yes; then
  AC_MSG_WARN([OpenSSL library disabled. ICQ plugin is disabled])
fi
AM_CONDITIONAL(ENABLE_ICQ, test "$have_ssl" = "yes")

dnl =======================================================
dnl FILE: ./plugins/livejournal/configure.in.in
dnl =======================================================

if test "$have_ssl" != yes; then
  AC_MSG_WARN([OpenSSL library disabled. LiveJournal plugin is disabled])
fi
AM_CONDITIONAL(ENABLE_LIVEJOURNAL, test "$have_ssl" = "yes")
dnl =======================================================
dnl FILE: ./plugins/msn/configure.in.in
dnl =======================================================

if test "$have_ssl" != yes; then
  AC_MSG_WARN([OpenSSL library disabled. MSN plugin is disabled])
fi

AM_CONDITIONAL(ENABLE_MSN, test "$have_ssl" = "yes")
dnl =======================================================
dnl FILE: ./plugins/ontop/configure.in.in
dnl =======================================================

AM_CONDITIONAL(ENABLE_ONTOP, test "$use_kde" = "yes" || test "$kde_use_qt_win" = "yes")
dnl =======================================================
dnl FILE: ./plugins/remote/configure.in.in
dnl =======================================================

AM_CONDITIONAL(ENABLE_REMOTE, test "$kde_use_qt_win" != "yes")
dnl =======================================================
dnl FILE: ./plugins/shortcuts/configure.in.in
dnl =======================================================

AM_CONDITIONAL(ENABLE_SHORTCUTS, test "$kde_use_qt_mac" != "yes")
dnl =======================================================
dnl FILE: ./plugins/spell/configure.in.in
dnl =======================================================

compile_plugin="no"
if test "$use_kde" != "yes" ; then
  AC_CHECK_HEADER(aspell.h, compile_plugin="yes")
fi

if test "x$compile_plugin" = "xyes"; then
  compile_plugin="no"
  AC_CHECK_LIB(aspell, get_aspell_dict_info_list, [compile_plugin="yes"; LIB_ASPELL="-laspell"])
  AC_SUBST(LIB_ASPELL)
fi

if test "$kde_use_qt_win" = "yes"; then
	SPELL_OBJ=spellfind.lo
	AC_SUBST([SPELL_OBJ])
fi
AM_CONDITIONAL(ENABLE_SPELL, test "x$compile_plugin" != "xno")

dnl =======================================================
dnl FILE: ./plugins/transparent/configure.in.in
dnl =======================================================

compile_plugin="no"
if test "$use_kde" = "yes"; then
 compile_plugin="yes"
 TRANSPARENT_OBJ=transtop.lo
 AC_SUBST([TRANSPARENT_OBJ])
fi                        
if test "$kde_use_qt_win" = "yes"; then
  compile_plugin="yes"
fi
AM_CONDITIONAL(ENABLE_TRANSPARENT, test "x$compile_plugin" = "xyes")
dnl =======================================================
dnl FILE: ./plugins/windock/configure.in.in
dnl =======================================================

AM_CONDITIONAL(ENABLE_WINDOCK, test "$kde_use_qt_win" = "yes")
dnl =======================================================
dnl FILE: ./plugins/yahoo/configure.in.in
dnl =======================================================

if test "$have_ssl" != yes; then
  AC_MSG_WARN([OpenSSL library disabled. Yahoo! plugin is disabled])
fi
AM_CONDITIONAL(ENABLE_YAHOO, test "$have_ssl" = "yes")
KDE_CREATE_SUBDIRSLIST
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ po/Makefile ])
AC_CONFIG_FILES([ sim/Makefile ])
AC_CONFIG_FILES([ sim/png/Makefile ])
AC_CONFIG_FILES([ sim/qzip/Makefile ])
AC_CONFIG_FILES([ plugins/__homedir/Makefile ])
AC_CONFIG_FILES([ plugins/__migrate/Makefile ])
AC_CONFIG_FILES([ plugins/_core/Makefile ])
AC_CONFIG_FILES([ plugins/_core/additional/Makefile ])
AC_CONFIG_FILES([ plugins/_core/icq5/Makefile ])
AC_CONFIG_FILES([ plugins/_core/icq5.1/Makefile ])
AC_CONFIG_FILES([ plugins/_core/icqlite/Makefile ])
AC_CONFIG_FILES([ plugins/_core/jisp/Makefile ])
AC_CONFIG_FILES([ plugins/_core/pict/Makefile ])
AC_CONFIG_FILES([ plugins/_core/smiles/Makefile ])
AC_CONFIG_FILES([ plugins/_core/styles/Makefile ])
AC_CONFIG_FILES([ plugins/about/Makefile ])
AC_CONFIG_FILES([ plugins/action/Makefile ])
AC_CONFIG_FILES([ plugins/autoaway/Makefile ])
AC_CONFIG_FILES([ plugins/background/Makefile ])
AC_CONFIG_FILES([ plugins/dock/Makefile ])
AC_CONFIG_FILES([ plugins/filter/Makefile ])
AC_CONFIG_FILES([ plugins/floaty/Makefile ])
AC_CONFIG_FILES([ plugins/forward/Makefile ])
AC_CONFIG_FILES([ plugins/gpg/Makefile ])
AC_CONFIG_FILES([ plugins/icons/Makefile ])
AC_CONFIG_FILES([ plugins/icq/Makefile ])
AC_CONFIG_FILES([ plugins/icq/sounds/Makefile ])
AC_CONFIG_FILES([ plugins/jabber/Makefile ])
AC_CONFIG_FILES([ plugins/jabber/sounds/Makefile ])
AC_CONFIG_FILES([ plugins/livejournal/Makefile ])
AC_CONFIG_FILES([ plugins/logger/Makefile ])
AC_CONFIG_FILES([ plugins/msn/Makefile ])
AC_CONFIG_FILES([ plugins/navigate/Makefile ])
AC_CONFIG_FILES([ plugins/netmonitor/Makefile ])
AC_CONFIG_FILES([ plugins/ontop/Makefile ])
AC_CONFIG_FILES([ plugins/osd/Makefile ])
AC_CONFIG_FILES([ plugins/proxy/Makefile ])
AC_CONFIG_FILES([ plugins/remote/Makefile ])
AC_CONFIG_FILES([ plugins/replace/Makefile ])
AC_CONFIG_FILES([ plugins/shortcuts/Makefile ])
AC_CONFIG_FILES([ plugins/sms/Makefile ])
AC_CONFIG_FILES([ plugins/sms/sounds/Makefile ])
AC_CONFIG_FILES([ plugins/sound/Makefile ])
AC_CONFIG_FILES([ plugins/sound/sounds/Makefile ])
AC_CONFIG_FILES([ plugins/spell/Makefile ])
AC_CONFIG_FILES([ plugins/splash/Makefile ])
AC_CONFIG_FILES([ plugins/styles/Makefile ])
AC_CONFIG_FILES([ plugins/styles/metal/Makefile ])
AC_CONFIG_FILES([ plugins/styles/wood/Makefile ])
AC_CONFIG_FILES([ plugins/transparent/Makefile ])
AC_CONFIG_FILES([ plugins/update/Makefile ])
AC_CONFIG_FILES([ plugins/weather/Makefile ])
AC_CONFIG_FILES([ plugins/weather/jisp/Makefile ])
AC_CONFIG_FILES([ plugins/windock/Makefile ])
AC_CONFIG_FILES([ plugins/yahoo/Makefile ])
AC_CONFIG_FILES([ plugins/zodiak/Makefile ])
AC_OUTPUT
# Check if KDE_SET_PREFIX was called, and --prefix was passed to configure
if test -n "$kde_libs_prefix" -a -n "$given_prefix"; then
  # And if so, warn when they don't match
  if test "$kde_libs_prefix" != "$given_prefix"; then
    # And if kde doesn't know about the prefix yet
    echo ":"`kde-config --path exe`":" | grep ":$given_prefix/bin/:" 2>&1 >/dev/null
    if test $? -ne 0; then
      echo ""
      echo "Warning: you chose to install this package in $given_prefix,"
      echo "but KDE was found in $kde_libs_prefix."
      echo "For this to work, you will need to tell KDE about the new prefix, by ensuring"
      echo "that KDEDIRS contains it, e.g. export KDEDIRS=$given_prefix:$kde_libs_prefix"
      echo "Then restart KDE."
      echo ""
    fi
  fi
fi

if test x$GXX = "xyes" -a x$kde_have_gcc_visibility = "xyes" -a x$kde_cv_val_qt_gcc_visibility_patched = "xno"; then
  echo ""
  echo "Your GCC supports symbol visibility, but the patch for Qt supporting visibility"
  echo "was not included. Therefore, GCC symbol visibility support remains disabled."
  echo ""
  echo "For better performance, consider including the Qt visibility supporting patch"
  echo "located at:"
  echo ""
  echo "http://bugs.kde.org/show_bug.cgi?id=109386"
  echo ""
  echo "and recompile all of Qt and KDE. Note, this is entirely optional and"
  echo "everything will continue to work just fine without it."
  echo ""
fi

if test "$all_tests" = "bad"; then
  if test ! "$cache_file" = "/dev/null"; then
    echo ""
    echo "Please remove the file $cache_file after changing your setup"
    echo "so that configure will find the changes next time."
    echo ""
  fi
else
  echo ""
  echo "Good - your configure finished. Start make now"
  echo ""
  echo "Note for non-GNU systems users: in order to compile SIM, you need to use GNU make (gmake)"
  echo ""
fi
