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., 51 Franklin Street, Fifth Floor,
dnl    Boston, MA 02110-1301, 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(knetworkmanager, 0.2.2) dnl searches for some needed programs

KDE_SET_PREFIX

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)
KDE_PROG_LIBTOOL

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS

KDE_USE_QT(3.2)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================

#MIN_CONFIG(3.2)
CXXFLAGS="$CXXFLAGS $KDE_DEFAULT_CXXFLAGS"

if test "$build_arts" = "yes"; then
    AC_DEFINE(USE_ARTS, 1, [If we use arts volume])
    LIB_ARTS="-lartskde"
    AC_SUBST(LIB_ARTS)
fi

KDE_INIT_DOXYGEN([KEG Network API Reference], [Version $VERSION])

dnl =======================================================
dnl FILE: ./knetworkmanager/configure.in.in
dnl =======================================================

dnl dnl PACKAGE set before

AC_C_BIGENDIAN
AC_CHECK_KDEMAXPATHLEN

KNETWORKMANAGER_VERSION="0.2.2"
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_VERSION_STRING, "$KNETWORKMANAGER_VERSION", [KNetworkManager Version String])

# test if variables are already set
test "x$prefix" = xNONE && prefix=$ac_default_prefix

# check for dbus, hal, libnm-util and libnl
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.33], [], [ 
	AC_MSG_RESULT([no])
	AC_MSG_WARN([You need D-Bus, knetworkmanager will not be compiled])
	DO_NOT_COMPILE="$DO_NOT_COMPILE knetworkmanager" 
	MISSING_DEPS="$MISSING_DEPS dbus-1"
])
PKG_CHECK_MODULES(HAL, [hal], [], [ 
	AC_MSG_RESULT([no])
	AC_MSG_WARN([You need Hal, knetworkmanager will not be compiled])
	DO_NOT_COMPILE="$DO_NOT_COMPILE knetworkmanager" 
	MISSING_DEPS="$MISSING_DEPS hal"
])
PKG_CHECK_MODULES(LIBNMUTIL, [libnm-util], [], [ 
	AC_MSG_RESULT([no])
	AC_MSG_WARN([You need libnm-util, knetworkmanager will not be compiled])
	DO_NOT_COMPILE="$DO_NOT_COMPILE knetworkmanager" 
	MISSING_DEPS="$MISSING_DEPS libnm-util"
])
PKG_CHECK_MODULES(LIBNL, [libnl-1 >= 1.1], [], [
	AC_MSG_RESULT([no])
	AC_MSG_WARN([You need libnl, knetworkmanager will not be compiled])
	DO_NOT_COMPILE="$DO_NOT_COMPILE knetworkmanager" 
	MISSING_DEPS="$MISSING_DEPS libnl-1"
])

PACKAGE_CFLAGS="$DBUS_CFLAGS $HAL_CFLAGS $LIBNMUITL_CFLAGS $LIBNL_CFLAGS"
PACKAGE_LIBS="$DBUS_LIBS $HAL_LIBS $LIBNMUTIL_LIBS $LIBNL_LIBS"

AC_ARG_WITH(dbus-sys, AC_HELP_STRING([--with-dbus-sys=DIR], [D-BUS system.d directory]))
if ! test -z "$with_dbus_sys" ; then
	DBUS_SYS_DIR="$with_dbus_sys"
else
	DBUS_SYS_DIR="${sysconfdir}/dbus-1/system.d"
fi
AC_SUBST(DBUS_SYS_DIR)
AC_DEFINE_UNQUOTED(DBUS_SYSTEMD_DIR, "$DBUS_SYS_DIR", [D-BUS system.d directory])

AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
AC_SUBST(LIB_DL)

# Check for D-Bus Qt3 bindings

safe_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $PACKAGE_CFLAGS $all_includes"
safe_LIBS=$LIBS
LIBS="$PACKAGE_LIBS"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS

AC_CHECK_HEADER([dbus/connection.h],,[
	AC_MSG_WARN([You need D-Bus/Qt3 bindings])
	DO_NOT_COMPILE="$DO_NOT_COMPILE knetworkmanager"
])

AC_MSG_CHECKING([for phase2 authentication support in NetworkManager])
AC_TRY_COMPILE([#include <NetworkManager/NetworkManager.h>]
, [#ifdef NM_PHASE2_AUTH_NONE
   int ok;
   #else
   choke me
   #endif]
, [AC_MSG_RESULT([yes])
   AC_DEFINE([HAVE_PHASE2_AUTH], [], [Enable phase2 authentication])
]
, [AC_MSG_RESULT([no])])


AC_CHECK_FUNC([nmu_security_serialize_leap_with_cipher], [AC_DEFINE([HAVE_LEAP], [], [Enable Leap support])])

CPPFLAGS=$safe_CPPFLAGS
LIBS=$safe_LIBS
AC_LANG_RESTORE

AC_ARG_WITH(distro, AC_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: suse, gentoo, fedora]))
if test "x$with_distro" = "x"; then
	AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
	AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
	AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora")
	if test "x$with_distro" = "x"; then
		with_distro=`lsb_release -is`
	fi
fi

with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `

# Compile dialup support

AC_ARG_WITH(dialup, AC_HELP_STRING([--with-dialup], [Build KNetworkManager with Dialup support (default)]))
if test "x$with_dialup" != "xno"; then
	if test "x$with_distro" = "x"; then
		echo "Linux distribution autodetection failed, you must specify the distribution to target using --with-distro=DISTRO"
	else
		case $with_distro in
			suse)
				AC_DEFINE_UNQUOTED(KNETWORKMANAGER_DIALUP_CONFIG,
					"kdesu --nonewdcop /sbin/yast2 modem",
					[Command to launch dial up configuration tool])
				;;
			gentoo)
				AC_DEFINE_UNQUOTED(KNETWORKMANAGER_DIALUP_CONFIG,
					"kdesu --nonewdcop ${KDEDIR}/bin/kppp",
					[Command to launch dial up configuration tool])
				;;
			fedora)
				AC_DEFINE_UNQUOTED(KNETWORKMANAGER_DIALUP_CONFIG,
					"kdesu --nonewdcop /usr/bin/kppp",
					[Command to launch dial up configuration tool])
				;; 
			*)
				echo "Your distribution (${with_distro}) is not yet supported (e.g. you will not be able to launch a tool to configure dial-up connections.)"
				;;
		esac
	fi
fi

# openvpn support

AC_ARG_WITH(openvpn, AC_HELP_STRING([--with-openvpn], [Build KNetworkManager with openvpn plugin]))
if test "x$with_openvpn" = "x"; then
	AC_CHECK_FILE(/etc/NetworkManager/VPN/nm-openvpn-service.name,with_openvpn="yes" )
fi
AM_CONDITIONAL(WITH_OPENVPN, test x"$with_openvpn" = "xyes")

# vpnc support

AC_ARG_WITH(vpnc, AC_HELP_STRING([--with-vpnc], [Build KNetworkManager with vpnc plugin]))
if test "x$with_vpnc" = "x"; then
	AC_CHECK_FILE(/etc/NetworkManager/VPN/nm-vpnc-service.name,with_vpnc="yes" )
fi
AM_CONDITIONAL(WITH_VPNC, test x"$with_vpnc" = "xyes")

# pptp support

AC_ARG_WITH(pptp, AC_HELP_STRING([--with-pptp], [Build KNetworkManager with pptp plugin]))
if test "x$with_pptp" = "x"; then
	AC_CHECK_FILE(/etc/NetworkManager/VPN/nm-pptp-service.name,with_pptp="yes" )
fi
AM_CONDITIONAL(WITH_PPTP, test x"$with_pptp" = "xyes")

# set include path for knetworkmanager-plugin.h and knetworkmanager-vpnplugin.h when vpn plugins are built together with knetworkmanager

KNETWORKMANAGER_CFLAGS="-I\$(top_srcdir)/knetworkmanager/src"
AC_SUBST(KNETWORKMANAGER_CFLAGS)
dnl =======================================================
dnl FILE: ./knetworkmanager/vpn-plugins/openvpn/configure.in.in
dnl =======================================================

KNETWORKMANAGER_OPENVPN_VERSION=0.1
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_OPENVPN_VERSION, $KNETWORKMANAGER_OPENVPN_VERSION, [KNetworkManager OpenVPN Plugin  Version])
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_OPENVPN_VERSION_STRING, "$KNETWORKMANAGER_OPENVPN_VERSION", [KNetworkManager OpenVPN Plugin Version String])


dnl =======================================================
dnl FILE: ./knetworkmanager/vpn-plugins/pptp/configure.in.in
dnl =======================================================

KNETWORKMANAGER_PPTP_VERSION=0.1
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_PPTP_VERSION, $KNETWORKMANAGER_PPTP_VERSION, [KNetworkManager PPTP Plugin Version])
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_PPTP_VERSION_STRING, "$KNETWORKMANAGER_PPTP_VERSION", [KNetworkManager PPTP Plugin Version String])


dnl =======================================================
dnl FILE: ./knetworkmanager/vpn-plugins/vpnc/configure.in.in
dnl =======================================================

KNETWORKMANAGER_VPNC_VERSION=0.1
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_VPNC_VERSION, $KNETWORKMANAGER_VPNC_VERSION, [KNetworkManager VPNC Plugin Version])
AC_DEFINE_UNQUOTED(KNETWORKMANAGER_VPNC_VERSION_STRING, "$KNETWORKMANAGER_VPNC_VERSION", [KNetworkManager VPNC Plugin Version String])


KDE_CREATE_SUBDIRSLIST
AM_CONDITIONAL(knetworkmanager_SUBDIR_included, test "x$knetworkmanager_SUBDIR_included" = xyes)
AM_CONDITIONAL(po_SUBDIR_included, test "x$po_SUBDIR_included" = xyes)
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ knetworkmanager/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/pics/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/src/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/openvpn/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/openvpn/src/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/pptp/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/pptp/src/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/vpnc/Makefile ])
AC_CONFIG_FILES([ knetworkmanager/vpn-plugins/vpnc/src/Makefile ])
AC_CONFIG_FILES([ po/Makefile ])
AC_CONFIG_FILES([ po/ar/Makefile ])
AC_CONFIG_FILES([ po/bg/Makefile ])
AC_CONFIG_FILES([ po/br/Makefile ])
AC_CONFIG_FILES([ po/ca/Makefile ])
AC_CONFIG_FILES([ po/cs/Makefile ])
AC_CONFIG_FILES([ po/da/Makefile ])
AC_CONFIG_FILES([ po/de/Makefile ])
AC_CONFIG_FILES([ po/el/Makefile ])
AC_CONFIG_FILES([ po/es/Makefile ])
AC_CONFIG_FILES([ po/et/Makefile ])
AC_CONFIG_FILES([ po/fi/Makefile ])
AC_CONFIG_FILES([ po/fr/Makefile ])
AC_CONFIG_FILES([ po/ga/Makefile ])
AC_CONFIG_FILES([ po/gl/Makefile ])
AC_CONFIG_FILES([ po/hu/Makefile ])
AC_CONFIG_FILES([ po/it/Makefile ])
AC_CONFIG_FILES([ po/ja/Makefile ])
AC_CONFIG_FILES([ po/ka/Makefile ])
AC_CONFIG_FILES([ po/km/Makefile ])
AC_CONFIG_FILES([ po/ms/Makefile ])
AC_CONFIG_FILES([ po/nl/Makefile ])
AC_CONFIG_FILES([ po/pa/Makefile ])
AC_CONFIG_FILES([ po/pl/Makefile ])
AC_CONFIG_FILES([ po/pt/Makefile ])
AC_CONFIG_FILES([ po/ru/Makefile ])
AC_CONFIG_FILES([ po/sk/Makefile ])
AC_CONFIG_FILES([ po/sl/Makefile ])
AC_CONFIG_FILES([ po/sr/Makefile ])
AC_CONFIG_FILES([ po/sr@Latn/Makefile ])
AC_CONFIG_FILES([ po/sv/Makefile ])
AC_CONFIG_FILES([ po/tr/Makefile ])
AC_CONFIG_FILES([ po/uk/Makefile ])
AC_CONFIG_FILES([ po/zh_CN/Makefile ])
AC_CONFIG_FILES([ po/zh_TW/Makefile ])
AC_OUTPUT
if test -n "$MISSING_DEPS"; then

	echo "**************************************************"
	echo "*"
	echo "* KNetworkManager will not be built due to missing dependencies!"
	echo "* Missing: $MISSING_DEPS"
	echo "*"
	echo "**************************************************"

fi
# 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 ""
fi
