dnl # // ##################################################################################################################
dnl # // ## Initialization
dnl # // ##################################################################################################################

AC_DEFUN([AC_SS_INIT_VARIABLES],
[
	SS_BUILD_FLAGS=""
	SS_BUILD_NUMBER=""

	dnl # // X Stuff

	SS_X_INCDIR=""
	SS_X_LIBDIR=""
	SS_X_LDFLAGS=""
	SS_X_CPPFLAGS=""

	dnl # // Qt Stuff

	SS_QT3_GENERAL_DIR=""
	SS_QT3_INCDIR=""
	SS_QT3_LIBDIR=""
	SS_QT3_MOC=""

	dnl # // KDE Stuff

	SS_KDE_REQUESTED="no"
	SS_KDE_GENERAL_DIR=""
	SS_KDE_INCDIR=""
	SS_KDE_LIBDIR=""
	SS_KDE_SERVICESDIR=""
	SS_KDE_ICONS32DIR=""

	dnl # // Perl stuff
	
	SS_PERL_ENABLE="no"
	SS_PERL_CCFLAGS=""
	SS_PERL_LDFLAGS=""
	SS_PERL_BINARY="true"
	

	dnl # // CXXFLAGS, will be set by AC_SS_CXXFLAGS

	dnl # CXXFLAGS=""

	dnl Build flags:
	dnl g     - Debug version
	dnl h     - Memory checks
	dnl m     - Memory profiling
	dnl s     - System memmove
	dnl S     - splash screen
	dnl o     = openssl support
	dnl b     - Big channels
	dnl x     - ix86 asm
	dnl T     - tips
	dnl c     - crypt
	dnl I     - IPC
	dnl G     - GSM codec
	dnl 8     - local 8 bit
	dnl A     - dcc sound audio support
	dnl a     - ignore sigalarm
	dnl i     - ipv6
	dnl B     - big endian
	dnl k     - KDE
	dnl p     - pseudo transparency
	dnl e	  - Esound daemon support
	dnl r     - Arts daemon support
	dnl f	  - Audiofile support
	dnl P     - profiling support
	dnl p     - perl scripting support
])

dnl # // ##################################################################################################################
dnl # // ## OUTPUT MACROS
dnl # // ##################################################################################################################
AC_DEFUN([AC_CROSS_COLOR],
[

	TPUT=0
	PRINTF=0
	COLOR=0
	IFS_OLD=$IFS
	IFS=":"

	for i in $PATH; do
		if test -x "$i/tput"; then
			TPUT=1
		fi
	done

	type printf >/dev/null 2>&1 && PRINTF=1

	for i in $PATH; do
		if test -x "$i/printf"; then
			PRINTF=1
		fi
	done

	if test "$TPUT" = "1" -o "$PRINTF" = "1"; then
		COLOR=1
	fi

	if test "$COLOR" = 1; then
		if test "$TPUT" = "1"; then
			if test "$1" = "1"; then
				tput bold
			else
				tput sgr0
			fi
			if test "$2" != ""; then
				tput setaf $2
			fi
		elif test "$PRINTF" = "1"; then
			if test "$2" != ""; then
				printf "\033\1330$1;3$2m"
			fi
		fi
	fi

	IFS=$IFS_OLD
])

AC_DEFUN([AC_SS_HEADER],
[
	AC_CROSS_COLOR([1],[2])
	echo "################################################################################"
	echo "### $1"
	echo "################################################################################"
	AC_CROSS_COLOR([0],[9])
])

AC_DEFUN([AC_SS_SECTION],
[
	AC_CROSS_COLOR([1],[3])
	echo "### $1"
	AC_CROSS_COLOR([0],[9])
])

AC_DEFUN([AC_SS_SET_REDINK],
[
	AC_CROSS_COLOR([1],[1])
])

AC_DEFUN([AC_SS_SET_GREENINK],
[
	AC_CROSS_COLOR([1],[2])
])

AC_DEFUN([AC_SS_SET_NORMALINK],
[
	AC_CROSS_COLOR([0],[9])
])

dnl # // ##################################################################################################################
dnl # // ## FILE LOOKUP MACROS
dnl # // ##################################################################################################################

AC_DEFUN([AC_SS_FIND_FILE_PATH],
[
	$3="FAILED"
	for a_dir in $2; do
		for a_file in $1; do
			if test -r "$a_dir/$a_file"; then
				$3=$(echo "$a_dir" | sed -e 's/\/\.\//\//g' | sed -e 's/\/\//\//g' | sed -e 's/\/\.\//\//g' | sed -e 's/\/\//\//g')
				break 2
			fi
		done
	done	
])

AC_DEFUN([AC_SS_FIND_FILE_PATH_EXT],
[
	$4="FAILED"

	for a_dir in $2; do
		for a_semidir in $3; do
			for a_file in $1; do
				if test -r "$a_dir/$a_semidir/$a_file"; then
					$4=$(echo "$a_dir/$a_semidir" | sed -e 's/\/\.\//\//g' | sed -e 's/\/\//\//g' | sed -e 's/\/\.\//\//g' | sed -e 's/\/\//\//g')
					break 3
				fi
			done
		done
	done
])

dnl # // ##################################################################################################################
dnl # // ## BASIC COMPILER FLAGS
dnl # // ##################################################################################################################


AC_DEFUN([AC_SS_CXXFLAGS_DEBUG_SYMBOLS],
[
	dnl # // Checks if the --with-debug-symbols option has been passed to configure
	dnl # // adds -g to SS_CXXFLAGS
	dnl # // adds g to SS_BUILD_FLAGS

	AC_MSG_CHECKING([if you want the debug symbols])

	SS_LOCAL_ADD_DEBUG_SYMBOLS=""

	AC_ARG_ENABLE(debug,
		AC_HELP_STRING([--enable-debug],[Compile an executable suitable for debugging]),
		[SS_LOCAL_ADD_DEBUG_SYMBOLS="true"])

	if test -n "$SS_LOCAL_ADD_DEBUG_SYMBOLS"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -g"
		else
			SS_CXXFLAGS="-g"
		fi
		SS_BUILD_FLAGS="g$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT([no])
	fi	
])

AC_DEFUN([AC_SS_CXXFLAGS_PIPES],
[
	dnl # // Checks if the --with-pipes option has been passed to configure
	dnl # // adds -pipe to CXXFLAGS

	AC_MSG_CHECKING([if you want to use pipes for compilation])

	SS_LOCAL_USE_PIPES=""
	AC_ARG_ENABLE(pipes,
		AC_HELP_STRING([--enable-pipes],[Use pipes instead of files for the compilation]),
		[SS_LOCAL_USE_PIPES="true"])

	if test -n "$SS_LOCAL_USE_PIPES"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -pipe"
		else
			SS_CXXFLAGS="-pipe"
		fi
	else
		AC_MSG_RESULT([no])
	fi
])


AC_DEFUN([AC_SS_CXXFLAGS_PROFILING],
[
	AC_MSG_CHECKING([if you want the profiling information])

	SS_LOCAL_ADD_PROFILING=""

	AC_ARG_ENABLE(profiling,
		AC_HELP_STRING([--enable-profiling],[Compile an executable suitable for profiling]),
		[SS_LOCAL_ADD_PROFILING="true"])

	if test -n "$SS_LOCAL_ADD_PROFILING"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -pg"
		else
			SS_CXXFLAGS="-pg"
		fi
		if test -n "$SS_LDFLAGS"; then
			SS_LDFLAGS="$SS_LDFLAGS -pg"
		else
			SS_LDFLAGS="-pg"
		fi
		SS_BUILD_FLAGS="P$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT([no])
	fi	
])

AC_DEFUN([AC_SS_CXXFLAGS_FNORTTI],
[
	AC_MSG_CHECKING([if you want to use -fno-rtti])

	SS_LOCAL_FNORTTI=""
	AC_ARG_ENABLE(fno-rtti,
		AC_HELP_STRING([--enable-fno-rtti],[Disable runtime type information (dangerous)]),
		SS_LOCAL_FNORTTI="true")

	if test -n "$SS_LOCAL_FNORTTI"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -fno-rtti"
		else
			SS_CXXFLAGS="-fno-rtti"
		fi
	else
		AC_MSG_RESULT([no])
	fi
])

AC_DEFUN([AC_SS_CXXFLAGS_ANSI],
[
	SS_ANSI_COMPILATION=""
	AC_MSG_CHECKING([if you want a strict ansi compilation])
	AC_ARG_ENABLE(ansi,
		AC_HELP_STRING([--enable-ansi],[Strict ansi compilation (might not compile)]),
		SS_ANSI_COMPILATION="true")

	if test -n "$SS_ANSI_COMPILATION"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -ansi"
		else
			SS_CXXFLAGS="-ansi"
		fi
	else
		AC_MSG_RESULT([no])
	fi
])


AC_DEFUN([AC_SS_CXXFLAGS_WALL],
[
	SS_WALL_COMPILATION=""
	AC_MSG_CHECKING([if you want gcc to be paranoic])
	AC_ARG_ENABLE(wall,
		AC_HELP_STRING([--enable-wall],[Make gcc be paranoic (might not compile)]),
		SS_WALL_COMPILATION="true")

	if test -n "$SS_WALL_COMPILATION"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -Wall"
		else
			SS_CXXFLAGS="-Wall"
		fi
	else
		AC_MSG_RESULT([no])
	fi
])


AC_DEFUN([AC_SS_CXXFLAGS_PEDANTIC],
[
	SS_PEDANTIC_COMPILATION=""
	AC_MSG_CHECKING([if you want a strict ansi compilation])

	AC_ARG_ENABLE(pedantic,
		AC_HELP_STRING([--enable-pedantic],[Pedantic compilation (might not compile)]),
		SS_PEDANTIC_COMPILATION="true")

	if test -n "$SS_PEDANTIC_COMPILATION"; then
		AC_MSG_RESULT([yes])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -pedantic"
		else
			SS_CXXFLAGS="-pedantic"
		fi
	else
		AC_MSG_RESULT([no])
	fi
])

AC_DEFUN([AC_SS_CXXFLAGS_OPTIMISATION],
[
	AC_MSG_CHECKING([for the optimisation level])

	SS_LOCAL_OPTIMISATION=""
	AC_ARG_ENABLE(optimisation,
		AC_HELP_STRING([--enable-optimisation=N],[Use optimisation level N when compiling]),
			SS_LOCAL_OPTIMISATION="$enableval")

	if test -n "$SS_LOCAL_OPTIMISATION"; then
		AC_MSG_RESULT([using -O$SS_LOCAL_OPTIMISATION])
		if test -n "$SS_CXXFLAGS"; then
			SS_CXXFLAGS="$SS_CXXFLAGS -O$SS_LOCAL_OPTIMISATION"
		else
			SS_CXXFLAGS="-O$SS_LOCAL_OPTIMISATION"
		fi
		SS_BUILD_FLAGS="$SS_LOCAL_OPTIMISATION$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT([using no optimisation flag])
	fi
])



AC_DEFUN([AC_SS_CXXFLAGS],
[
	SS_CXXFLAGS=""

	AC_SS_CXXFLAGS_DEBUG_SYMBOLS
	AC_SS_CXXFLAGS_PROFILING
	AC_SS_CXXFLAGS_PIPES
	AC_SS_CXXFLAGS_OPTIMISATION
	AC_SS_CXXFLAGS_FNORTTI
	AC_SS_CXXFLAGS_ANSI
	AC_SS_CXXFLAGS_PEDANTIC
	AC_SS_CXXFLAGS_WALL

	if test -n "$SS_CXXFLAGS"; then
		if test -n "$CXXFLAGS"; then
			CXXFLAGS="$CXXFLAGS $SS_CXXFLAGS"
		else
			CXXFLAGS="$SS_CXXFLAGS"
		fi
	fi
])


dnl ###################################################################################################################
dnl ### HEADERS AND FUNCTIONS
dnl ###################################################################################################################

AC_DEFUN([AC_SS_HEADER_CHECKS],
[
	SS_HAS_OSS_SUPPORT="false"
	AC_CHECK_HEADER(strings.h)
	AC_CHECK_HEADERS(linux/soundcard.h sys/soundcard.h soundcard.h,SS_HAS_OSS_SUPPORT="true")

	if test "$SS_HAS_OSS_SUPPORT" = "true"; then
		AC_DEFINE([COMPILE_OSS_SUPPORT], 1, [define if you want to enable OSS sound support])
	fi

])

AC_DEFUN([AC_SS_FUNCTION_CHECKS],
[
	SS_HAVE_IPV6_FUNCTIONS="true"

	AC_CHECK_FUNCS(getenv strerror)
	AC_CHECK_FUNCS(inet_ntoa inet_aton)
	AC_CHECK_FUNCS(setenv unsetenv putenv)
	AC_CHECK_FUNCS(gmtime_r localtime_r)

	AC_CHECK_FUNC(inet_ntop,SS_HAVE_IPV6_FUNCTIONS="true",SS_HAVE_IPV6_FUNCTIONS="false")
	AC_CHECK_FUNC(inet_pton,SS_HAVE_IPV6_FUNCTIONS="true",SS_HAVE_IPV6_FUNCTIONS="false")
	AC_CHECK_FUNC(getaddrinfo,SS_HAVE_IPV6_FUNCTIONS="true",SS_HAVE_IPV6_FUNCTIONS="false")

	AC_CHECK_FUNCS(getnameinfo)
])



dnl ###################################################################################################################
dnl ### MISC OPTIONS
dnl ###################################################################################################################


AC_DEFUN([AC_SS_MISC_OPTIONS],
[
	AC_MSG_CHECKING([if you want the memory profiling])
	AC_ARG_WITH(memory-profile, [  --with-memory-profile   Compile the memory profile],SS_COMPILE_MEMORY_PROFILE="true")
	if test "$SS_COMPILE_MEMORY_PROFILE" = "true"; then
		AC_MSG_RESULT(yes)
		AC_DEFINE([COMPILE_MEMORY_PROFILE], 1, [define if you want the gcc memory profile])
		SS_BUILD_FLAGS="m$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([how to waste your time])
	AC_MSG_RESULT(by performing senseless checks)

	AC_MSG_CHECKING([if you want memory checking in malloc])
	AC_ARG_WITH(memory-checks, [  --with-memory-checks    Enable malloc memory checks],SS_COMPILE_MEMORY_CHECKS="true")
	if test "$SS_COMPILE_MEMORY_CHECKS" = "true"; then
		AC_MSG_RESULT(yes)
		AC_DEFINE([COMPILE_MEMORY_CHECKS], 1, [define if you want the memory checks])
		SS_BUILD_FLAGS="h$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT(no)
	fi


	AC_MSG_CHECKING([if you want to use system memmove])
	AC_ARG_WITH(system-memmove, [  --without-system-memmove   Do not use system memmove and memcpy],SS_DO_NOT_USE_SYSTEM_MEMMOVE="true")
	if test "$SS_DO_NOT_USE_SYSTEM_MEMMOVE" = "true"; then
		AC_MSG_RESULT(no)
	else
		AC_DEFINE([COMPILE_WITH_SYSTEM_MEMMOVE], 1, [define if you trust your memmove() function])
		AC_MSG_RESULT(yes)
		SS_BUILD_FLAGS="s$SS_BUILD_FLAGS"
	fi

	AC_MSG_CHECKING([if you want to optimize for big channels])
	AC_ARG_WITH(big-channels, [  --with-big-channels     Optimize for big irc channels],SS_OPTIMIZE_BIG_CHANNELS="true")
	if test "$SS_OPTIMIZE_BIG_CHANNELS" = "true"; then
		AC_MSG_RESULT(yes: using 349 as dict size)
		AC_DEFINE_UNQUOTED([AVERAGE_CHANNEL_USERS],349, [define this to the number of average channel users])
		SS_BUILD_FLAGS="b$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT(no: using 101 as dict size)
		AC_DEFINE_UNQUOTED([AVERAGE_CHANNEL_USERS],101, [define this to the number of average channel users])
	fi

	AC_MSG_CHECKING([if you want ix86 assembly optimisations])
	AC_ARG_WITH(ix86-asm, [  --with-ix86-asm         Compile ix86 assembly optimisations],SS_COMPILE_ix86_ASM="true")
	if test "$SS_COMPILE_ix86_ASM" = "true"; then
		AC_MSG_RESULT(yes)
		AC_MSG_CHECKING(target system CPU)
		if test "$target_cpu" = "i386"; then
			AC_MSG_RESULT(i386 : compiling asm code)
		else
			if test "$target_cpu" = "i486"; then
				AC_MSG_RESULT(i486 : compiling asm code)
			else
				if test "$target_cpu" = "i586"; then
					AC_MSG_RESULT(i586 : compiling asm code)
				else
					if test "$target_cpu" = "i686"; then
						AC_MSG_RESULT(i686 : compiling asm code)
					else
						AC_MSG_RESULT($target_cpu , no i386 optimisations)
						unset SS_COMPILE_ix86_ASM
					fi
				fi
			fi
		fi

		if test "$SS_COMPILE_ix86_ASM" = "true"; then
			AC_DEFINE([COMPILE_ix86_ASM], 1, [define if you want the i386 asm code])
			SS_BUILD_FLAGS="x$SS_BUILD_FLAGS"
		fi
	else
		AC_MSG_RESULT(no)
	fi

	AC_PATH_PROG(SS_MSGFMT,msgfmt,":",$PATH:/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/lib/qt/bin:/usr/local/qt/bin:/usr/X11R6/qt/bin:/usr/qt/bin:/usr/build/qt/bin)
	if test -z "SS_MSGFMT"; then
		SS_MSGFMT=":"
	fi
	AC_SUBST(SS_MSGFMT)

	AC_MSG_CHECKING([if you want the DCC VOICE sound support])
	AC_ARG_WITH(dcc-sound,[  --without-dcc-sound     Do not compile the DCC VOICE sound support],SS_NO_SOUND="true")
	if test "$SS_NO_SOUND" = "true"; then
		AC_MSG_RESULT(no)
		AC_DEFINE([COMPILE_DISABLE_DCC_VOICE], 1, [define if you want to disable DCC VOICE sound support])
	else
		AC_MSG_RESULT(yes)
		SS_BUILD_FLAGS="A$SS_BUILD_FLAGS"
	fi

	SS_BUILD_FLAGS="T$SS_BUILD_FLAGS"
	AC_DEFINE([COMPILE_INFO_TIPS], 1, [define if you want the info tips to be compiled in])

	AC_MSG_CHECKING([if you want to disable the ipV6 support])
	AC_ARG_WITH(ipv6-support,[  --without-ipv6-support  Do not compile the IpV6 support],SS_NOIPV6_SUPPORT="true")
	if test "$SS_NOIPV6_SUPPORT" = "true"; then
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to disable the cryptography support])
	AC_ARG_WITH(crypt-support,[  --without-crypt-support Do not compile the cryptography support],SS_NOCRYPT_SUPPORT="true")
	if test "$SS_NOCRYPT_SUPPORT" = "true"; then
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
		AC_DEFINE([COMPILE_CRYPT_SUPPORT], 1, [define if you want to compile the crypt support])
		SS_BUILD_FLAGS="c$SS_BUILD_FLAGS"
	fi

	AC_MSG_CHECKING([if you want to disable the X bell support])
	AC_ARG_WITH(x-bell,[  --without-x-bell        Disable the X bell support],SS_NO_X_BELL="true")
	if test "$SS_NO_X_BELL" = "true"; then
		AC_MSG_RESULT(yes)
		AC_DEFINE([COMPILE_NO_X_BELL], 1, [define if you want to disable the X bell support])
	else
		AC_MSG_RESULT(no)
	fi

	AC_DEFINE([COMPILE_NEW_KVS], 1, [define if you want to enable the new KVS parser])
	AC_DEFINE([COMPILE_ONLY_NEW_KVS], 1, [define if you want to use only the new KVS parser])

	AC_MSG_CHECKING([if you want to link to the embedded version of qt])
	AC_ARG_WITH(qt-embedded,[  --with-qt-embedded      Link to qt-embedded (see INSTALL)],SS_QT3_EMBEDDED="true")
	if test "$SS_QT3_EMBEDDED" = "true"; then
		AC_MSG_RESULT(yes)
		SS_BUILD_FLAGS="E$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT(no)
	fi


	AC_MSG_CHECKING([if you want to disable inter-process communication])
	AC_ARG_WITH(ipc,[  --without-ipc           Disable inter-process communication support],SS_NO_IPC="true")
	if test "$SS_NO_IPC" = "true"; then
		AC_MSG_RESULT(yes)
		SS_BUILD_FLAGS="I$SS_BUILD_FLAGS"
		AC_DEFINE([COMPILE_NO_IPC], 1, [define this if you want to disable the inter-process communication support])
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to explicitly disable the gsm codec support])
	AC_ARG_WITH(gsm,[  --without-gsm           Disable gsm codec support],SS_NO_GSM="true")
	if test "$SS_NO_GSM" = "true"; then
		AC_MSG_RESULT(yes)
	else
		AC_DEFINE([COMPILE_USE_GSM], 1, [define if you have libgsm and want the GSM code to be compiled])
		SS_BUILD_FLAGS="G$SS_BUILD_FLAGS"
		AC_MSG_RESULT(no)
	fi


	AC_MSG_CHECKING([if you want to ignore SIGALARM])
	AC_ARG_WITH(ignore-sigalarm, [  --with-ignore-sigalarm  Ignore SIGALARM in all threads],SS_IGNORE_SIGALARM="true")
	if test "$SS_IGNORE_SIGALARM" = "true"; then
		AC_MSG_RESULT(yes)
		AC_DEFINE([COMPILE_IGNORE_SIGALARM], 1, [define this if you want to ignore the SIGALARM signal])
		SS_BUILD_FLAGS="a$SS_BUILD_FLAGS"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want the pseudo-transparency support])
	AC_ARG_WITH(transparency,  [  --without-transparency  Do NOT compile the pseudo-transparency support],SS_NO_PSEUDO_TRANSPARENCY="true")
	if test "$SS_NO_PSEUDO_TRANSPARENCY" = "true"; then
		AC_MSG_RESULT(no)
	else
		AC_MSG_RESULT(yes)
		AC_DEFINE([COMPILE_PSEUDO_TRANSPARENCY], 1, [define if you have the KDE support and want the pseudo transparency])
		SS_BUILD_FLAGS="p$SS_BUILD_FLAGS"
	fi

	AC_ARG_WITH(pizza,[  --with-pizza            Use this when hungry],SS_PIZZA="true")

])


dnl ###################################################################################################################
dnl ### DYNAMIC LABELS
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_DYNAMIC_LABELS],
[
	AC_MSG_CHECKING([if the compiler supports dynamic labels])
	AC_ARG_WITH(dyn-labels, [  --without-dyn-labels    Disable usage of the dynamic label jumps],SS_DISABLE_DYNAMIC_LABELS="true")
	if test "$SS_DISABLE_DYNAMIC_LABELS" = "true"; then
		AC_MSG_RESULT("no: trusting you")
	else
		AC_TRY_RUN([
				int main(int argc,char ** argv)
				{
					int retVal = 10;
					void * label = &&action4;
					goto action2;
					action1:
						retVal -= 4;
						label = &&endofcode;
						goto *label;
					action2:
						retVal -= 5;
						goto *label;
					action3:
						retVal += 40;
					action4:
						retVal -= 1;
						label = &&action1;
						goto *label;
					endofcode:
						return retVal;
				}
			],SS_DISABLE_DYNAMIC_LABELS="false",SS_DISABLE_DYNAMIC_LABELS="true",SS_DISABLE_DYNAMIC_LABELS="true")

		if test "$SS_DISABLE_DYNAMIC_LABELS" = "true"; then
			AC_MSG_RESULT("no")
		else
			AC_MSG_RESULT("yes")
			AC_DEFINE([COMPILE_USE_DYNAMIC_LABELS], 1, [define if your compiler supports gotos do dynamic labels])
		fi
	fi
])

dnl ###################################################################################################################
dnl ### BIG_ENDIAN
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_BIG_ENDIAN],
[
	AC_MSG_CHECKING([if this system is big endian])
	AC_TRY_RUN([
			int main(int argc,char ** argv)
			{
				int nl;
				unsigned char * nlc;
				nl = 0x12CAFE34;
				nlc = (unsigned char *)(&nl);
				if((nlc[0] == 0x12) && (nlc[1] == 0xCA) && (nlc[2] == 0xFE) && (nlc[3] == 0x34))return 0;
				return 1;
			}
		],SS_BIG_ENDIAN_MACHINE="true",SS_BIG_ENDIAN_MACHINE="false",SS_BIG_ENDIAN_MACHINE="false")

	dnl # This will fail if we're cross compiling...

	if test "$SS_BIG_ENDIAN_MACHINE" = "true"; then
		AC_MSG_RESULT([yes])
		SS_BUILD_FLAGS="B$SS_BUILD_FLAGS"
		AC_DEFINE([BIG_ENDIAN_MACHINE_BYTE_ORDER], 1, [define this if you are on a big endian machine])
	else
		AC_MSG_RESULT([no])
	fi
])

dnl ###################################################################################################################
dnl ### DLOPEN
dnl ###################################################################################################################


AC_DEFUN([AC_SS_CHECK_DL],
[
	AC_MSG_CHECKING([for dlopen capabilities])

	SS_LINK_TO_LIBDL="no"

	SS_SAVE_LIBS="$LIBS"
	LIBS="-rdynamic"
	AC_TRY_LINK([
			#include <dlfcn.h>
		],[
			/* sparc-unknown-openbsd3.0 hack */
			#ifndef RTLD_NOW
				#define RTLD_NOW RTLD_LAZY
			#endif
			dlopen("/lib/libc.so.6",RTLD_NOW);
		],
			eval "SS_DLOPEN_OK=yes"
		,
			eval "SS_DLOPEN_OK=no"
		)
	LIBS="$SS_SAVE_LIBS"

	if test "$SS_DLOPEN_OK" = "yes"; then
		AC_MSG_RESULT([builtin in libc])
	else

		SS_SAVE_LIBS="$LIBS"
		LIBS="-rdynamic -ldl"
		AC_TRY_LINK([
				#include <dlfcn.h>
			],[
				/* sparc-unknown-openbsd3.0 hack */
				#ifndef RTLD_NOW
					#define RTLD_NOW RTLD_LAZY
				#endif
				dlopen("/usr/lib/libdl.so",RTLD_NOW);
			],
				eval "SS_DLOPEN_OK=yes",
				eval "SS_DLOPEN_OK=no"
			)
		LIBS="$SS_SAVE_LIBS"

		if test "$SS_DLOPEN_OK" = "yes"; then
			SS_LINK_TO_LIBDL="yes"
			AC_MSG_RESULT([external in libdl])
		else
			AC_MSG_RESULT([FAILED])
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "###  No dlopen capabilities found."
			echo "###  It looks that your system has no interface to the dynamic linker ?"
			echo "###  If you're on linux, you either miss libdl , or the linker is not"
			echo "###  able to find it. Make sure that libdl is in /lib or /usr/lib."
			echo "###  If you're sure you have libdl, make sure you have also g++ installed."
			echo "###  If you're not on linux, please drop a mail to pragma at kvirc dot net"
			echo "###  describing your system and I'll try to fix it."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR(["This was fatal...aborting"])
		fi
	fi
])


dnl ###################################################################################################################
dnl ### PERL
dnl ###################################################################################################################


AC_DEFUN([AC_SS_CHECK_PERL],
[
	SS_PERL_ENABLE="yes"
	SS_PERL_CCFLAGS=""
	SS_PERL_LDFLAGS=""
	SS_PERL_BINARY="true"
	SS_PERL_RESULT_MESSAGE=""

	AC_ARG_ENABLE(perl,AC_HELP_STRING([--enable-perl],[Enable perl scripting support (default=detect)]),eval "SS_PERL_ENABLE=$enableval")

	if test "$SS_PERL_ENABLE" = "yes"; then
		AC_PATH_PROG(SS_PERL_BINARY,perl,":",$PATH:/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/lib/qt/bin:/usr/local/qt/bin:/usr/X11R6/qt/bin:/usr/qt/bin:/usr/build/qt/bin)
		if test -z "SS_PERL_BINARY"; then
			SS_PERL_RESULT_MESSAGE="disabled: can't find the perl binary"
			SS_PERL_ENABLE="no"
			SS_PERL_BINARY="true"
		fi
	else
		SS_PERL_RESULT_MESSAGE="disabled by user"
	fi
	
	if test "$SS_PERL_ENABLE" = "yes"; then
		AC_MSG_CHECKING([if perl il compiled with MULTIPLICITY option])
		SS_PERL_TEMP=$($SS_PERL_BINARY -V | grep MULTIPLICITY)
		if test -z "$SS_PERL_TEMP"; then
			AC_MSG_RESULT([no])
			SS_PERL_ENABLE="no"
			SS_PERL_BINARY="true"
			SS_PERL_RESULT_MESSAGE="disabled: MULTIPLICITY not defined"
		fi
	fi

	if test "$SS_PERL_ENABLE" = "yes"; then
		AC_MSG_CHECKING([for the system perl directory])
		SS_PERL_DIR=$($SS_PERL_BINARY -MConfig -e 'print $Config{archlib}')
		SS_PERL_DIR="$SS_PERL_DIR/CORE"
		AC_MSG_RESULT([got $SS_PERL_DIR])
		AC_MSG_CHECKING([for the perl ccflags])
		SS_PERL_CCFLAGS=$($SS_PERL_BINARY -MConfig -e 'print $Config{ccflags}')
		AC_MSG_RESULT([got $SS_PERL_CCFLAGS])
		AC_MSG_CHECKING([for the perl ldflags])
		SS_PERL_LDFLAGS=$($SS_PERL_BINARY -MExtUtils::Embed -e ldopts)
		AC_MSG_RESULT([got $SS_PERL_LDFLAGS])

		AC_MSG_CHECKING([if we can compile a perl application])
		SS_SAVED_LIBS="$LIBS"
		SS_SAVED_CFLAGS="$CFLAGS"
		SS_SAVED_CCFLAGS="$CCFLAGS"
		SS_SAVED_LDFLAGS="$LDFLAGS"
		SS_SAVED_CXXFLAGS="$CXXFLAGS"
		SS_SAVED_CPPFLAGS="$CPPFLAGS"

		LIBS="$SS_PERL_LDFLAGS"
		LDFLAGS="$LIBS"
		CFLAGS="$SS_PERL_CCFLAGS -I$SS_PERL_DIR"
		CCFLAGS="$CFLAGS"
		CXXFLAGS="$CFLAGS"
		CPPFLAGS="$CFLAGS"

		AC_TRY_LINK([
					#include <EXTERN.h>
					#include <perl.h>
					#include <XSUB.h>

					extern "C" void boot_DynaLoader(pTHX_ CV* cv);

					extern "C" void xs_init(pTHX)
					{
						char * file = __FILE__;
						newXS("DynaLoader::boot_DynaLoader",boot_DynaLoader,file);
					}
					
			],[
					PerlInterpreter *my_perl;
					my_perl = perl_alloc();
					perl_construct(my_perl);
					perl_parse(my_perl,xs_init, 0, 0, (char **)NULL);
					perl_run(my_perl);
					perl_destruct(my_perl);
					perl_free(my_perl);
			],
				eval "SS_PERL_ENABLE=yes",
				eval "SS_PERL_ENABLE=no"
			)

		SS_PERL_LDFLAGS="$LDFLAGS"
		SS_PERL_CCFLAGS="$CCFLAGS"

		LIBS="$SS_SAVED_LIBS"
		CFLAGS="$SS_SAVED_CFLAGS"
		LDFLAGS="$SS_SAVED_LDFLAGS"
		CXXFLAGS="$SS_SAVED_CXXFLAGS"
		CPPFLAGS="$SS_SAVED_CPPFLAGS"
		CCFLAGS="$SS_SAVED_CCFLAGS"

		if test "$SS_PERL_ENABLE" = "yes"; then
			AC_MSG_RESULT([seems ok])
			AC_DEFINE([COMPILE_PERL_SUPPORT], 1, [define if you have perl and want the perl scripting support in kvirc])
			SS_BUILD_FLAGS="p$SS_BUILD_FLAGS"
			SS_PERL_RESULT_MESSAGE="enabled"
		else
			AC_MSG_RESULT([seems broken])
			SS_PERL_RESULT_MESSAGE="disabled: failed to compile the test program"
			SS_PERL_LDFLAGS=""
			SS_PERL_CCFLAGS=""
		fi
	fi

	AC_SUBST(SS_PERL_CCFLAGS)
	AC_SUBST(SS_PERL_LDFLAGS)
	AC_SUBST(SS_PERL_BINARY)

	AC_MSG_CHECKING([for perl scripting support])
	AC_MSG_RESULT([$SS_PERL_RESULT_MESSAGE])
])

dnl ###################################################################################################################
dnl ### OPENSSL
dnl ###################################################################################################################


AC_DEFUN([AC_SS_CHECK_OPENSSL],
[
	SS_LINK_TO_LIBSSL="false"
	SS_SSL_RESULT_MESSAGE=""
	SS_ENABLE_SSL_SUPPORT="yes"

	AC_ARG_ENABLE(ssl,AC_HELP_STRING([--disable-ssl],[Disable OpenSSL support]),eval "SS_ENABLE_SSL_SUPPORT=$enableval")

	if test "$SS_ENABLE_SSL_SUPPORT" = "yes"; then
		AC_MSG_CHECKING([If we can compile and link a small SSL test application])
		SS_SAVED_LIBS="$LIBS"
		LIBS="-lcrypto -lssl"
		AC_TRY_LINK([
				#include <openssl/ssl.h>
			],[
				SSL_new(0);
			],
				eval "SS_ENABLE_SSL_SUPPORT=yes",
				eval "SS_ENABLE_SSL_SUPPORT=no"
			)
		LIBS="$SS_SAVED_LIBS"
		if test "$SS_ENABLE_SSL_SUPPORT" = "yes"; then
			AC_MSG_RESULT([yes])

			AC_CHECK_HEADER(openssl/ssl.h,SS_DUMMY="yes",SS_ENABLE_SSL_SUPPORT="no")
			AC_CHECK_HEADER(openssl/err.h,SS_DUMMY="yes",SS_ENABLE_SSL_SUPPORT="no")
			AC_CHECK_HEADER(openssl/asn1.h,SS_DUMMY="yes",SS_ENABLE_SSL_SUPPORT="no")
			AC_CHECK_HEADER(openssl/evp.h,SS_DUMMY="yes",SS_ENABLE_SSL_SUPPORT="no")

			if test "$SS_ENABLE_SSL_SUPPORT" = "yes"; then
				AC_DEFINE([COMPILE_SSL_SUPPORT], 1, [define if you have openssl and want the ssl support in kvirc])
				SS_LINK_TO_LIBSSL="true"
				SS_BUILD_FLAGS="o$SS_BUILD_FLAGS"
				SS_SSL_RESULT_MESSAGE="enabled"
			else
				SS_SSL_RESULT_MESSAGE="disabled: missing header files"
			fi
		else
			AC_MSG_RESULT([no])
			SS_SSL_RESULT_MESSAGE="disabled: failed to compile the test program"
		fi
	else
		SS_SSL_RESULT_MESSAGE="disabled by user"
	fi

	AC_MSG_CHECKING([for secure connections support])
	AC_MSG_RESULT([$SS_SSL_RESULT_MESSAGE])
])


dnl ###################################################################################################################
dnl ### ESD
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_ESD],
[
	SS_LINK_TO_LIBESD="false"
	SS_DISABLE_ESD_SUPPORT="true"
	SS_SAVED_LIBS=$LIBS
	LIBS="$LIBS -lesd"
	AC_CHECK_LIB(esd,esd_play_file,SS_DISABLE_ESD_SUPPORT="false")
	LIBS="$SS_SAVED_LIBS"

	if test "$SS_DISABLE_ESD_SUPPORT" = "false"; then
		SS_DISABLE_ESD_SUPPORT="true"
		AC_CHECK_HEADER(esd.h,SS_DISABLE_ESD_SUPPORT="false")
	fi

	AC_MSG_CHECKING([for Esound daemon support])
	AC_ARG_WITH(esd-support, [  --without-esd-support   Disable Esound daemon support],SS_DISABLE_ESD_SUPPORT="true")

	if test "$SS_DISABLE_ESD_SUPPORT" = "true"; then
		AC_MSG_RESULT(disabled by user)
	else
		AC_MSG_RESULT(yes: have libs and headers)
		AC_DEFINE([COMPILE_ESD_SUPPORT], 1, [define if you want to enable the Esound daemon support])
		SS_LINK_TO_LIBESD="true"
		SS_BUILD_FLAGS="e$SS_BUILD_FLAGS"
	fi

])

dnl ###################################################################################################################
dnl ### ZLIB
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_ZLIB],
[
	SS_LINK_TO_LIBZLIB="no"
	SS_DISABLE_ZLIB_SUPPORT="true"
	SS_SAVED_LIBS=$LIBS
	LIBS="$LIBS -lz"
	AC_CHECK_LIB(z,gzopen,SS_DISABLE_ZLIB_SUPPORT="false")
	LIBS="$SS_SAVED_LIBS"

	if test "$SS_DISABLE_ZLIB_SUPPORT" = "false"; then
		SS_DISABLE_ZLIB_SUPPORT="true"
		AC_CHECK_HEADER(zlib.h,SS_DISABLE_ZLIB_SUPPORT="false")
	fi

	AC_MSG_CHECKING([for GZip support])
	AC_ARG_WITH(zlib-support, [  --without-zlib-support   Disable ZLIB support],SS_DISABLE_ZLIB_SUPPORT="true")

	if test "$SS_DISABLE_ZLIB_SUPPORT" = "true"; then
		AC_MSG_RESULT(disabled by user)
	else
		AC_MSG_RESULT(yes: have libs and headers)
		AC_DEFINE([COMPILE_ZLIB_SUPPORT], 1, [define if you want to enable the ZLib library support])
		SS_LINK_TO_LIBZ="yes"
		SS_BUILD_FLAGS="Z$SS_BUILD_FLAGS"
	fi
])

dnl ###################################################################################################################
dnl ### XSS
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_XSS],
[
	SS_LINK_TO_XSS="no"
	SS_COMPILE_XSS_SUPPORT="false"
	SS_SAVED_LIBS=$LIBS
	LIBS="$LIBS -lXss"
	AC_CHECK_LIB(Xss,XScreenSaverAllocInfo,SS_COMPILE_XSS_SUPPORT="true")
	LIBS="$SS_SAVED_LIBS"

	AC_MSG_CHECKING([for Xss support])

	if test "$SS_COMPILE_XSS_SUPPORT" = "false"; then
		AC_MSG_RESULT(disabled)
	else
		AC_MSG_RESULT(yes: lib is ok)
		AC_DEFINE([COMPILE_XSS_SUPPORT], 1, [define if you want to enable the ZLib library support])
		SS_LINK_TO_XSS="yes"
		SS_BUILD_FLAGS="$SS_BUILD_FLAGS"
	fi
])

dnl ###################################################################################################################
dnl ### Audiofile library
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_AUDIOFILE],
[
	SS_LINK_TO_LIBAUDIOFILE="false"
	SS_DISABLE_AUDIOFILE_SUPPORT="true"
	SS_SAVED_LIBS=$LIBS
	LIBS="$LIBS -laudiofile"
	AC_CHECK_LIB(audiofile,afOpenFile,SS_DISABLE_AUDIOFILE_SUPPORT="false")

	if test "$SS_DISABLE_AUDIOFILE_SUPPORT" = "false"; then
		SS_DISABLE_AUDIOFILE_SUPPORT="true"
		AC_CHECK_LIB(audiofile,afGetVirtualFrameSize,SS_DISABLE_AUDIOFILE_SUPPORT="false")
	fi

	LIBS="$SS_SAVED_LIBS"

	if test "$SS_DISABLE_AUDIOFILE_SUPPORT" = "false"; then
		SS_DISABLE_AUDIOFILE_SUPPORT="true"
		AC_CHECK_HEADER(audiofile.h,SS_DISABLE_AUDIOFILE_SUPPORT="false")
	fi

	AC_MSG_CHECKING([for audiofile support])

	if test "$SS_DISABLE_AUDIOFILE_SUPPORT" = "true"; then
		AC_MSG_RESULT(missing header or libs or wrong version)
	else

		if test "$SS_HAS_OSS_SUPPORT" = "false"; then
			SS_DISABLE_AUDIOFILE_SUPPORT="true"
			AC_MSG_RESULT(no oss support at all)
		else
			AC_ARG_WITH(af-support, [  --without-af-support    Disable Audiofile library for playing files to OSS support], SS_DISABLE_AUDIOFILE_SUPPORT="true")

			if test "$SS_DISABLE_AUDIOFILE_SUPPORT" = "true"; then
				AC_MSG_RESULT(disabled by user)
			else
				AC_MSG_RESULT(yes: have libs and headers)
				AC_DEFINE([COMPILE_AUDIOFILE_SUPPORT], 1, [define if you want to enable the Audiofile library support])
				SS_LINK_TO_LIBAUDIOFILE="true"
				SS_BUILD_FLAGS="f$SS_BUILD_FLAGS"
			fi
		fi
	fi
])

dnl ###################################################################################################################
dnl ### ARTS
dnl ###################################################################################################################


AC_DEFUN([AC_SS_CHECK_ARTS],
[
	SS_LINK_TO_LIBARTS="false"
	SS_DISABLE_ARTS_SUPPORT="false"

	AC_MSG_CHECKING([if Arts support is requested])
	AC_ARG_WITH(arts-support, [  --without-arts-support   Disable Arts daemon support],SS_DISABLE_ARTS_SUPPORT="true")

	if test "$SS_KDE_REQUESTED" = "yes"; then
		if test "$SS_DISABLE_ARTS_SUPPORT" = "true"; then
			AC_MSG_RESULT(disabled by user)
		else
			AC_MSG_RESULT([yes])
			AC_MSG_CHECKING(if we can compile a simple Arts application)
			AC_LANG_CPLUSPLUS
			ss_save_CPPFLAGS="$CPPFLAGS"
			ss_save_CXXFLAGS="$CXXFLAGS"
			ss_save_LDFLAGS="$LDFLAGS"
			ss_save_LIBS="$LIBS"
			CPPFLAGS="-I$SS_X_INCDIR -I$SS_QT3_INCDIR -I$SS_KDE_INCDIR $CPPFLAGS $X_CFLAGS"
			CXXFLAGS="-O2 -Wall $CXXFLAGS"
			LIBS="-L$SS_KDE_LIBDIR -L$SS_X_LIBDIR $SS_X_LDFLAGS $SS_X_LIBLINK -L$SS_QT3_LIBDIR $LIBS -lsoundserver_idl -ltdecore -lmcop -l$SS_QTLIB_NAME -Wl,-rpath $SS_KDE_LIBDIR"
			if test "$SS_LINK_TO_LIBDL" = "yes"; then
				LIBS="$LIBS -ldl";
			fi
			LDFLAGS="-s $LDFLAGS"
			AC_TRY_LINK([
				#include <arts/soundserver.h>
			],[
				Arts::Dispatcher * d = new Arts::Dispatcher();
				Arts::SimpleSoundServer *server = new Arts::SimpleSoundServer(Arts::Reference("global:Arts_SimpleSoundServer"));
			],
			SS_ARTS_LINKED_OK="TRUE",
			SS_ARTS_LINKED_OK="FALSE"
			)
			if test "$SS_ARTS_LINKED_OK" = "FALSE"; then
				AC_MSG_RESULT(failed)
			else
				AC_MSG_RESULT(success)
				AC_DEFINE([COMPILE_ARTS_SUPPORT], 1, [define if you want to enable the Arts daemon support])
				SS_LINK_TO_LIBARTS="true"
				SS_BUILD_FLAGS="r$SS_BUILD_FLAGS"
			fi
			LIBS="$ss_save_LIBS"
			LDFLAGS="$ss_save_LDFLAGS"
			CXXFLAGS="$ss_save_CXXFLAGS"
			CPPFLAGS="$ss_save_CPPFLAGS"
		fi
	else
		SS_DISABLE_ARTS_SUPPORT="true"
		AC_MSG_RESULT([no KDE so no Arts])
	fi
])
		

dnl ###################################################################################################################
dnl ### INTERFACE ADDRESS STUFF
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_IFADDR_STUFF],
[
	AC_MSG_CHECKING([if we can get interface addresses])

	AC_TRY_LINK([
			#include <stdio.h>
			#include <sys/ioctl.h>
			#include <net/if.h>
			#include <netinet/in.h>
			#include <arpa/inet.h>
			#include <string.h>
		],[
			struct ifreq ifr;
			int ret;
			struct sockaddr * sa;
			ret = IFNAMSIZ;
			ret = ioctl(ret,SIOCGIFADDR,&ifr);
			if(ifr.ifr_name != 0)sa = (struct sockaddr *)&(ifr.ifr_addr);
		],
			eval "SS_DISABLE_IFADDR=false"
		,
			eval "SS_DISABLE_IFADDR=true"
	)

	if test "$SS_DISABLE_IFADDR" = "true"; then
		AC_MSG_RESULT("no")
	else
		AC_MSG_RESULT("yes")
		AC_DEFINE([COMPILE_GET_INTERFACE_ADDRESS], 1, [define if you have the SIOCGIFADDR ioctl and the related headers])
	fi
])

dnl ###################################################################################################################
dnl ### PTHREAD
dnl ###################################################################################################################

AC_DEFUN([AC_SS_CHECK_THREAD_STUFF],
[
	SS_THREAD_LIBLINK=""

	AC_MSG_CHECKING([if you want to use the solaris lthread])
	SS_DO_IT="false"
	AC_ARG_WITH(solaris-lthread,      [  --with-solaris-lthread  Use the Solaris native libthread],SS_DO_IT="true")
	if test "$SS_DO_IT" = "true"; then
		AC_MSG_RESULT(yes)
		SS_THREAD_LIBLINK="-lthread"
		AC_DEFINE([COMPILE_THREADS_USE_SOLARIS_LIBTHREAD], 1, [define if you want to use the solaris libthread])
	else
		AC_MSG_RESULT(no)

		AC_MSG_CHECKING([if you want to use freebsd native pthread support])
		SS_DO_IT="false"

		AC_ARG_WITH(freebsd-pthread,      [  --with-freebsd-pthread  Use the FreeBSD native libc_r for threading],SS_DO_IT="true")
		if test "$SS_DO_IT" = "true"; then
			AC_MSG_RESULT(yes)
			SS_THREAD_LIBLINK="-pthread"
			AC_DEFINE([COMPILE_THREADS_USE_POSIX], 1, [define if you want to use the pthreads library])
		else
			AC_MSG_RESULT(no..using lpthread)
			SS_THREAD_LIBLINK="-lpthread"
			AC_DEFINE([COMPILE_THREADS_USE_POSIX], 1, [define if you want to use the pthreads library])
		fi

		AC_MSG_CHECKING([if your pthread implementation works])
		SS_DO_IT="false"
		AC_ARG_WITH(no-pthread-check,      [  --with-no-pthread-check Do not check if pthreads stuff compiles],SS_DO_IT="true")

		if test "$SS_DO_IT" = "true"; then
			AC_MSG_RESULT(yes, trusting you)
		else
			SS_SAVE_LIBS="$LIBS"
			LIBS="$SS_THREAD_LIBLINK"
			AC_TRY_LINK([
					#include <pthread.h>
				],[
					pthread_mutex_lock(0);
				],
					eval "SS_PTHREAD_OK=yes"
				,
					eval "SS_PTHREAD_OK=no"
				)
			LIBS="$SS_SAVE_LIBS"
	
			if test "$SS_PTHREAD_OK" = "yes"; then
				AC_MSG_RESULT(yes, it seems to)
			else
				AC_MSG_RESULT(["FAILED"])
				AC_SS_SET_REDINK
				if test "$SS_THREAD_LIBLINK" = "-pthread"; then
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "###  Failed to compile the pthread test program."
					echo "###  You have specified to use the native FreeBSD libc_r for threading"
					echo "###  but it looks that this does not work."
					echo "###  Make sure that you have libc_r floating around your system"
					echo "###  and that the -pthread special gcc flag works."
					echo "###  (You need to use the native FreeBSD gcc compiler for this to work)"
					echo "################################################################################"
				else
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "###  Failed to compile the pthread test program."
					echo "###  It looks that you either don't have libpthread installed or"
					echo "###  it is not reachable by the linker."
					echo "###  Make sure that libpthread is in /lib or /usr/lib."
					echo "###  If you're on solaris you might try the --with-solaris-lthread"
					echo "###  configure option. If you're on FreeBSD you should use"
					echo "###  --with-freebsd-pthread."
					echo "###  Good luck :)"
					echo "################################################################################"
				fi
				AC_SS_SET_NORMALINK
				AC_MSG_ERROR(["This was fatal...aborting"])
			fi
		fi
	fi
])

dnl ###################################################################################################################
dnl ### X
dnl ###################################################################################################################


AC_DEFUN([AC_SS_FIND_X],
[
	SS_DISABLE_X_SUPPORT="false"

	AC_MSG_CHECKING([if you want to ignore X at all])
	AC_ARG_ENABLE(x-support, [  --disable-x-support   Ignore X Windows completely],SS_DISABLE_X_SUPPORT="true")

	if test $SS_DISABLE_X_SUPPORT = "true"; then
		AC_DEFINE([COMPILE_NO_X], 1, [define if you want to ignore X Windows completely])
 		SS_X_INCDIR="/usr/include"
		SS_X_LIBDIR="/usr/lib"
		SS_X_LDFLAGS=""
		SS_X_CPPFLAGS=""
		SS_X_LIBLINK=""
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no, proceeding with checks)
		AC_PATH_XTRA
	
		if test -n "$no_x"; then
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Can not find the X libraries."
			echo "### Make sure that X is installed on your system and try to run configure again,"
			echo "### this time passing the --x-includes and --x-libraries options."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which checks have failed and maybe more about the"
			echo "### reason of the failure."
			echo "###"
			echo "### If you use an environment that does not require X support such as Qt-Mac"
			echo "### you may try to rerun configure with --disable-x-support"
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			# Set the X include and lib dir
	 		SS_X_INCDIR="$x_includes"
			SS_X_LIBDIR="$x_libraries"
			SS_X_LIBLINK="-lX11 -lXext"
	
			if test -z "$SS_X_INCDIR"; then
				# Ops... X headers not found ?
				AC_TRY_COMPILE([
						#include <X11/Xlib.h>
					],[
						Display * d = XOpenDisplay(0);
						XCloseDisplay(d);
					],
						eval "ss_x_incdir_found=yes"
					,
						eval "ss_x_incdir_found=no"
					)
	
				if test "$ss_x_incdir_found" = "no"; then
					AC_SS_SET_REDINK
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "### Can not find the X headers."
					echo "### Possible reasons:"
					echo "###   1) You miss the X server development files (Xlib.h for example)"
					echo "###"
					echo "###   2) Autoconf/Automake wasn't able to find the headers"
					echo "###      for some ugly reason."
					echo "###"
					echo "### You might try looking for a file named Xlib.h in your hard-drive"
					echo "### and try passing the --x-includes option to ./configure"
					echo "### Remember that if you find Xlib.h in /somepath/include/X11/Xlib.h"
					echo "### Then you must pass --x-includes=/somepath/include to ./configure"
					echo "### For example, my Xlib.h is in /usr/X11R6/include/X11/Xlib.h"
					echo "### then i would try: ./configure --x-includes=/usr/X11R6/include"
					echo "### If you can't find Xlib.h on your hard drive then install the X-devel"
					echo "### package from your distribution."
					echo "### If Xlib.h is there and --x-includes doesn't help, well , there is something"
					echo "### wrong with X , autoconf or automake."
					echo "### You may also take a look at the config.log file in this directory,"
					echo "### that will tell you which checks have failed and maybe more about the"
					echo "### reason of the failure."
					echo "###"
					echo "### If you use an environment that does not require X support such as Qt-Mac"
					echo "### you may try to rerun configure with --disable-x-support"
					echo "################################################################################"
					AC_SS_SET_NORMALINK
					AC_MSG_ERROR([This was a fatal one...aborting])
				else
					# We can compile X programs without any additional path... use a dummy include path then
					# Should we print a warning ?
					SS_X_INCDIR="/usr/include"
				fi
			fi
	
	
			if test -z "$SS_X_LIBDIR"; then
				# Ops... X libs not found ?
				SS_SAVE_LIBS="$LIBS"
				SS_SAVE_CFLAGS="$CFLAGS"
				SS_SAVE_CPPFLAGS="$CPPFLAGS"
				SS_SAVE_CXXFLAGS="$CXXFLAGS"
	
				CFLAGS="-I$SS_X_INCDIR"
				CPPFLAGS="$CFLAGS"
				CXXFLAGS="$CFLAGS"
				LIBS="$SS_X_LIBLINK"
				AC_TRY_LINK([
						#include <X11/Xlib.h>
					],[
						Display * d = XOpenDisplay(0);
						XCloseDisplay(d);
					],
						eval "ss_x_libdir_found=yes"
					,
						eval "ss_x_libdir_found=no"
					)
				LIBS="$SS_SAVE_LIBS"
				CFLAGS="$SS_SAVE_CFLAGS"
				CPPFLAGS="$SS_SAVE_CPPFLAGS"
				CXXFLAGS="$SS_SAVE_CXXFLAGS"
	
				if test "$ss_x_libdir_found" = "no"; then
					AC_SS_SET_REDINK
					echo "################################################################################"
					echo "### CONFIGURE ERROR:"
					echo "### Can not find the X libraries."
					echo "### Possible reasons:"
					echo "###   1) You have no X server : KVIrc can't run on this system"
					echo "###"
					echo "###   2) Autoconf/Automake wasn't able to find the libraries"
					echo "###      for some ugly reason."
					echo "###"
					echo "### You might try looking for a file named libX11.so in your hard-drive"
					echo "### and try passing the --x-libraries option to ./configure"
					echo "### Remember that if you find libX11.so in /somepath/lib/libX11.so"
					echo "### Then you must pass --x-libraries=/somepath/lib to ./configure"
					echo "### For example, my libX11.so is in /usr/X11R6/lib/libX11.so"
					echo "### then i would try: ./configure --x-libraries=/usr/X11R6/lib"
					echo "### If you can't find libX11.so on your hard drive then install the X server"
					echo "### package from your distribution."
					echo "### If libX11.so is there and --x-libraries doesn't help, well , there is something"
					echo "### wrong with X , autoconf or automake."
					echo "### You may also take a look at the config.log file in this directory,"
					echo "### that will tell you which checks have failed and maybe more about the"
					echo "### reason of the failure."
					echo "###"
					echo "### If you use an environment that does not require X support such as Qt-Mac"
					echo "### you may try to rerun configure with --disable-x-support"
					echo "################################################################################"
					AC_SS_SET_NORMALINK
					AC_MSG_ERROR([This was a fatal one...aborting])
				else
					# We can link X programs without any additional path... use a dummy lib path then
					# Should we print a warning ?
					SS_X_LIBDIR="/usr/lib"
				fi
			fi

			# Add any extra libs needed
			SS_X_LDFLAGS=""

			if test -n "$X_PRE_LIBS"; then
				SS_X_LDFLAGS="$X_PRE_LIBS $SS_X_LDFLAGS"
			fi

			if test -n "$X_EXTRA_LIBS"; then
				SS_X_LDFLAGS="$SS_X_LDFLAGS $X_EXTRA_LIBS"
			fi

			if test -n "$X_LIBS"; then
				SS_X_LDFLAGS="$SS_X_LDFLAGS $X_LIBS"
			fi
	
			# Add any extra gcc flags
			SS_X_CPPFLAGS=$X_CFLAGS
		fi
	fi
])

dnl ###################################################################################################################
dnl ### QT
dnl ###################################################################################################################

AC_DEFUN([AC_SS_FIND_QT],
[
	AC_ARG_ENABLE(qt-check,
			AC_HELP_STRING([--disable-qt-check],[Do not check if Qt and X compile]),
			SS_CHECK_QTX_COMPILE="$withval",SS_CHECK_QTX_COMPILE="NOTGIVEN")

	AC_ARG_ENABLE(qt4,
			AC_HELP_STRING([--enable-qt4],[Enable WORK IN PROGRESS Qt4 support]),
			SS_USE_QT4="$withval",SS_USE_QT4="no")
	
	if test "$SS_USE_QT4" = "no"; then

		AC_SS_FIND_QT3_NAME
		AC_SS_FIND_QT3_GENERAL_DIR
		AC_SS_FIND_QT3_LIBRARY_DIR
		AC_SS_FIND_QT3_INCLUDE_DIR
		AC_SS_FIND_QT3_MOC
		AC_SS_FIND_QT3_MT

	 	if test "$SS_CHECK_QTX_COMPILE" = "NOTGIVEN"; then
			AC_SS_ENSURE_CAN_COMPILE_X_AND_QT3
		fi
	else
		
		AC_SS_FIND_QT4_GENERAL_DIR
		AC_SS_FIND_QT4_LIBRARY_DIR
		AC_SS_FIND_QT4_INCLUDE_DIR
		AC_SS_FIND_QT4_MOC


	 	if test "$SS_CHECK_QTX_COMPILE" = "NOTGIVEN"; then
			AC_SS_ENSURE_CAN_COMPILE_X_AND_QT4
		fi

	fi
])

AC_DEFUN([AC_SS_FIND_QT3_NAME],
[
	AC_MSG_CHECKING([for the Qt library name])
	AC_ARG_WITH(qt-name,[  --with-qt-name=NAME     Use NAME instead of \"qt\" as Qt library name],SS_QTLIB_NAME="$withval",SS_QTLIB_NAME="qt")
	AC_MSG_RESULT("$SS_QTLIB_NAME")
])

AC_DEFUN([AC_SS_FIND_QT3_GENERAL_DIR],
[
	AC_MSG_CHECKING([for the general Qt3.x directory])

	ss_qt_general_test_dirs="/usr/local /usr /usr/X11R6 /usr/lib /opt /opt/kde /kde /usr/kde /usr/build /usr/src /usr/local/lib /"
	ss_qt_general_test_dirs="$ss_qt_general_test_dirs /usr/local/kde /usr/opt/kde"

	if test -n "$HOME"; then
		ss_qt_general_test_dirs="$ss_qt_general_test_dirs $HOME $HOME/lib"
	fi

	if test -n "$QTDIR"; then
		ss_qt_general_test_dirs="$QTDIR $ss_qt_general_test_dirs"
	fi

	ss_qt_general_test_path_suffix="qt$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT3_MAJOR_VERSION_REQUIRED$SS_QT3_MINOR_VERSION_REQUIRED$SS_QT3_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT3_MAJOR_VERSION_REQUIRED$SS_QT3_MINOR_VERSION_REQUIRED$SS_QT3_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT3_MAJOR_VERSION_REQUIRED$SS_QT3_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT3_MAJOR_VERSION_REQUIRED$SS_QT3_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt$SS_QT3_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT3_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT3_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix lib"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt ."

	AC_SS_FIND_FILE_PATH_EXT($SS_TQT3_GENERAL_FILE_TO_SEARCH,$ss_qt_general_test_dirs,$ss_qt_general_test_path_suffix,SS_QT3_GENERAL_DIR)
	if test "$SS_QT3_GENERAL_DIR" = "FAILED"; then
		AC_SS_FIND_FILE_PATH_EXT($SS_QT3_GENERAL_FILE_TO_SEARCH,$ss_qt_general_test_dirs,$ss_qt_general_test_path_suffix,SS_QT3_GENERAL_DIR)
		if test "$SS_QT3_GENERAL_DIR" = "FAILED"; then
			AC_MSG_RESULT([failed...continuing with normal checks])
			unset SS_QT3_GENERAL_DIR
		else
			AC_MSG_RESULT([Seems to be $SS_QT3_GENERAL_DIR])
		fi
	else
		AC_MSG_RESULT([Seems to be $SS_QT3_GENERAL_DIR])
	fi
])

AC_DEFUN([AC_SS_FIND_QT4_GENERAL_DIR],
[
	AC_MSG_CHECKING([for the general Qt4.x directory])

	ss_qt_general_test_dirs="/usr/local /usr /usr/X11R6 /usr/lib /opt /opt/kde /kde /usr/kde /usr/build /usr/src /usr/local/lib /"
	ss_qt_general_test_dirs="$ss_qt_general_test_dirs /usr/local/kde /usr/opt/kde /usr/lib/qt4 /usr/local/lib/qt4"

	if test -n "$HOME"; then
		ss_qt_general_test_dirs="$ss_qt_general_test_dirs $HOME $HOME/lib"
	fi

	if test -n "$QTDIR"; then
		ss_qt_general_test_dirs="$QTDIR $ss_qt_general_test_dirs"
	fi

	ss_qt_general_test_path_suffix="qt$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.$SS_QT4_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.$SS_QT4_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT4_MAJOR_VERSION_REQUIRED$SS_QT4_MINOR_VERSION_REQUIRED$SS_QT4_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.$SS_QT4_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT4_MAJOR_VERSION_REQUIRED$SS_QT4_MINOR_VERSION_REQUIRED$SS_QT4_PATCH_LEVEL_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT4_MAJOR_VERSION_REQUIRED$SS_QT4_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT4_MAJOR_VERSION_REQUIRED$SS_QT4_MINOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt$SS_QT4_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt.$SS_QT4_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt-$SS_QT4_MAJOR_VERSION_REQUIRED"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix lib"
	ss_qt_general_test_path_suffix="$ss_qt_general_test_path_suffix qt ."

	AC_SS_FIND_FILE_PATH_EXT($SS_QT4_GENERAL_FILE_TO_SEARCH,$ss_qt_general_test_dirs,$ss_qt_general_test_path_suffix,SS_QT4_GENERAL_DIR)
	if test "$SS_QT4_GENERAL_DIR" = "FAILED"; then
		AC_MSG_RESULT([failed...continuing with normal checks])
		unset SS_QT4_GENERAL_DIR
	else
		AC_MSG_RESULT([Seems to be $SS_QT4_GENERAL_DIR])
	fi
])


AC_DEFUN([AC_SS_FIND_QT3_INCLUDE_DIR],
[
	AC_ARG_WITH(qt-include-dir,[  --with-qt-include-dir   path to the Qt 3.x headers ],SS_QT3_INCDIR="$withval",SS_QT3_INCDIR="NOTGIVEN")
	if test "$SS_QT3_INCDIR" = "NOTGIVEN"; then

		AC_MSG_CHECKING([for the Qt 3.x header files])

		ss_qt_include_test_dirs="$SS_QT3_GENERAL_DIR/include /include /usr/include /usr/local/include /usr/qt/include /usr/local/qt/include /usr/X11R6/include /usr/lib/qt/include /usr/lib/qt /usr/include/X11"
		test -n "$QTDIR" && ss_qt_include_test_dirs="$QTDIR/include $QTDIR $ss_qt_include_test_dirs"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt /usr/include/tqt3 /usr/include/qt3 /usr/local/include/qt /include/qt /usr/X11R6/include/qt /usr/build/qt/include"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/tqt$SS_QT3_MAJOR_VERSION_REQUIRED /usr/include/qt$SS_QT3_MAJOR_VERSION_REQUIRED /usr/include/qt-$SS_QT3_MAJOR_VERSION_REQUIRED /usr/local/include/qt$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /include/tqt$SS_QT3_MAJOR_VERSION_REQUIRED /include/qt$SS_QT3_MAJOR_VERSION_REQUIRED /usr/X11R6/include/qt$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/X11/qt$SS_QT3_MAJOR_VERSION_REQUIRED /opt/qt /opt/kde/qt"

		AC_SS_FIND_FILE_PATH($SS_TQT3_INCLUDE_FILE_TO_SEARCH,$ss_qt_include_test_dirs,SS_QT3_INCDIR)

		if test "$SS_QT3_INCDIR" = "FAILED"; then
			AC_SS_FIND_FILE_PATH($SS_QT3_INCLUDE_FILE_TO_SEARCH,$ss_qt_include_test_dirs,SS_QT3_INCDIR)
		fi

		if test "$SS_QT3_INCDIR" = "FAILED"; then

			dnl HACK HACK HACK

			ss_qt_include_test_dirs="$SS_QT4_GENERAL_DIR/include /include /usr/include /usr/local/include /usr/qt/include /usr/include/qt4 /usr/qt4/include /usr/local/qt/include /usr/X11R6/include /usr/lib/qt/include /usr/lib/qt /usr/include/X11"
			test -n "$QTDIR" && ss_qt_include_test_dirs="$QTDIR/include $QTDIR $ss_qt_include_test_dirs"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt /usr/include/qt4 /usr/local/include/qt /include/qt /usr/X11R6/include/qt /usr/build/qt/include"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED /usr/include/qt-$SS_QT4_MAJOR_VERSION_REQUIRED /usr/local/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /include/qt$SS_QT4_MAJOR_VERSION_REQUIRED /usr/X11R6/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED"
			ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/X11/qt$SS_QT4_MAJOR_VERSION_REQUIRED /opt/qt /opt/kde/qt"

			AC_SS_FIND_FILE_PATH($SS_QT4_INCLUDE_FILE_TO_SEARCH,$ss_qt_include_test_dirs,SS_QT4_INCDIR)

			SS_QT3_INCDIR="$SS_QT4_INCDIR -I/usr/include/tqt -include tqt.h"
			AC_MSG_RESULT([TQt4 detected--Qt4 found in $SS_QT3_INCDIR])

dnl			AC_MSG_RESULT([FAILED])
dnl			AC_SS_SET_REDINK
dnl			echo "################################################################################"
dnl			echo "### CONFIGURE ERROR:"
dnl			echo "### Can not find the qt 3.x header files."
dnl			echo "### Make sure that qt is correctly installed on your system,"
dnl			echo "### and the qt version is the one requested by this version of kvirc."
dnl			echo "### Try to run configure again, this time passing the --with-qt-include-dir"
dnl			echo "### option (see ./configure --help)."
dnl			echo "### You may also take a look at the config.log file in this directory,"
dnl			echo "### that will tell you which check has failed and maybe more about the reason"
dnl			echo "### of the failure."
dnl			echo "### If you're feeling that this may be a bug in this configure script"
dnl			echo "### and want to report this to me , please include your configure script,"
dnl			echo "### the config.log file as well as the complete configure output."
dnl			echo "################################################################################"
dnl			AC_SS_SET_NORMALINK
dnl			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			SS_QT3_INCDIR="$SS_QT3_INCDIR -I/usr/include/tqt -include tqt.h"

			AC_MSG_RESULT([found in $SS_QT3_INCDIR])
		fi

	else
		AC_MSG_RESULT([using user supplied path for the Qt 3.x include files $SS_QT3_INCDIR])
		SS_QT3_INCDIR="$SS_QT3_INCDIR -I/usr/include/tqt -include tqt.h"
	fi
])


AC_DEFUN([AC_SS_FIND_QT4_INCLUDE_DIR],
[
	AC_ARG_WITH(qt4-include-dir,[  --with-qt4-include-dir   path to the Qt 4.x headers ],SS_QT4_INCDIR="$withval",SS_QT4_INCDIR="NOTGIVEN")
	if test "$SS_QT4_INCDIR" = "NOTGIVEN"; then

		AC_MSG_CHECKING([for the Qt 4.x header files])

		ss_qt_include_test_dirs="$SS_QT4_GENERAL_DIR/include /include /usr/include /usr/local/include /usr/qt/include /usr/include/qt4 /usr/qt4/include /usr/local/qt/include /usr/X11R6/include /usr/lib/qt/include /usr/lib/qt /usr/include/X11"
		test -n "$QTDIR" && ss_qt_include_test_dirs="$QTDIR/include $QTDIR $ss_qt_include_test_dirs"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt /usr/include/qt4 /usr/local/include/qt /include/qt /usr/X11R6/include/qt /usr/build/qt/include"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED /usr/include/qt-$SS_QT4_MAJOR_VERSION_REQUIRED /usr/local/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /include/qt$SS_QT4_MAJOR_VERSION_REQUIRED /usr/X11R6/include/qt$SS_QT4_MAJOR_VERSION_REQUIRED"
		ss_qt_include_test_dirs="$ss_qt_include_test_dirs /usr/include/X11/qt$SS_QT4_MAJOR_VERSION_REQUIRED /opt/qt /opt/kde/qt"

		AC_SS_FIND_FILE_PATH($SS_QT4_INCLUDE_FILE_TO_SEARCH,$ss_qt_include_test_dirs,SS_QT4_INCDIR)

		if test "$SS_QT4_INCDIR" = "FAILED"; then
			AC_MSG_RESULT([FAILED])
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Can not find the qt 4.x header files."
			echo "### Make sure that qt is correctly installed on your system,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### Try to run configure again, this time passing the --with-qt4-include-dir"
			echo "### option (see ./configure --help)."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			AC_MSG_RESULT([found in $SS_QT4_INCDIR])
		fi

	else
		AC_MSG_RESULT([using user supplied path for the Qt 4.x include files $SS_QT4_INCDIR])
	fi
	
	SS_QT4_INCDIRECTORIES="-I$SS_QT4_INCDIR -I$SS_QT4_INCDIR/Qt/ -I$SS_QT4_INCDIR/QtCore/ -I$SS_QT4_INCDIR/QtGui/";
])


AC_DEFUN([AC_SS_FIND_QT3_LIBRARY_DIR],
[
	AC_ARG_WITH(qt-library-dir,[  --with-qt-library-dir   path to the Qt 3.x library ],SS_QT3_LIBDIR="$withval",SS_QT3_LIBDIR="NOTGIVEN")
	if test "$SS_QT3_LIBDIR" = "NOTGIVEN"; then
		AC_MSG_CHECKING([for the Qt library])

		ss_qt_library_test_dirs="$SS_QT3_GENERAL_DIR/lib /lib /usr/lib /usr/local/lib /usr/qt/lib /usr/local/qt/lib /usr/X11R6/lib /usr/lib/qt/lib /usr/lib/qt /usr/local/lib/qt/lib"
		test -n "$QTDIR" && ss_qt_library_test_dirs="$QTDIR/lib $QTDIR $ss_qt_library_test_dirs"
		ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/local/lib/qt /usr/X11R6/lib/qt /usr/build/qt/lib /opt/lib /opt/qt/lib"

		# NATIVE TQT3
		ss_qt_libs_to_find="libt$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME-mt.a"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libt$SS_QTLIB_NAME.a"

		AC_SS_FIND_FILE_PATH($ss_qt_libs_to_find,$ss_qt_library_test_dirs,SS_TQT3_LIBDIR)

		if test "$SS_TQT3_LIBDIR" != "FAILED"; then
			AC_MSG_RESULT([Native TQt3 detected])
			SS_QTLIB_NAME="tqt"
		fi

		ss_qt_libs_to_find="lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.so.$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.$SS_QT3_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.a"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME.a"

		AC_SS_FIND_FILE_PATH($ss_qt_libs_to_find,$ss_qt_library_test_dirs,SS_QT3_LIBDIR)

		if test "$SS_QT3_LIBDIR" = "FAILED"; then

			dnl HACK HACK HACK

			AC_MSG_CHECKING([for the Qt 4.x libraries])

			ss_qt_library_test_dirs="$SS_QT4_GENERAL_DIR/lib /lib /usr/lib /usr/local/lib /usr/qt/lib /usr/local/qt/lib /usr/X11R6/lib /usr/lib/qt/lib /usr/lib/qt /usr/local/lib/qt/lib"
			test -n "$QTDIR" && ss_qt_library_test_dirs="$QTDIR/lib $QTDIR $ss_qt_library_test_dirs"
			ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/local/lib/qt /usr/X11R6/lib/qt /usr/build/qt/lib /opt/lib /opt/qt/lib"
			ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/lib/qt4 /usr/local/lib/qt4 /usr/X11R6/lib/qt4"
			ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/build/qt4/lib /opt/qt4/lib"

			ss_qt_libs_to_find="libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.$SS_QT4_PATCH_LEVEL_REQUIRED"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.dylib"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.dylib"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.dylib"
			ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.a"

			AC_SS_FIND_FILE_PATH($ss_qt_libs_to_find,$ss_qt_library_test_dirs,SS_QT4_LIBDIR)

			SS_QT3_LIBDIR="$SS_QT4_LIBDIR"
			SS_QTLIB_NAME="tqt"
			AC_MSG_RESULT([TQt4 detected--Qt4 found in $SS_QT3_LIBDIR])

dnl			AC_MSG_RESULT([FAILED])
dnl			AC_SS_SET_REDINK
dnl			echo "################################################################################"
dnl			echo "### CONFIGURE ERROR:"
dnl			echo "### Can not find the qt 3.x library file."
dnl			echo "### Make sure that qt is correctly installed on your system,"
dnl			echo "### and the qt version is the one requested by this version of kvirc."
dnl			echo "### (Usually a greater version is OK too)"
dnl			echo "### Try to run configure again, this time passing the --with-qt-library-dir"
dnl			echo "### option (see ./configure --help)."
dnl			echo "### You may also take a look at the config.log file in this directory,"
dnl			echo "### that will tell you which check has failed and maybe more about the reason"
dnl			echo "### of the failure."
dnl			echo "### If you're feeling that this may be a bug in this configure script"
dnl			echo "### and want to report this to me , please include your configure script,"
dnl			echo "### the config.log file as well as the complete configure output."
dnl			echo "################################################################################"
dnl			AC_SS_SET_NORMALINK
dnl			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			AC_MSG_RESULT([TQt3 found in $SS_QT3_LIBDIR])
		fi
	else
		AC_MSG_RESULT([using user supplied path for the Qt library $SS_QT3_LIBDIR])
	fi
])


AC_DEFUN([AC_SS_FIND_QT4_LIBRARY_DIR],
[
	AC_ARG_WITH(qt4-library-dir,[  --with-qt4-library-dir  path to the Qt 4.x library ],SS_QT4_LIBDIR="$withval",SS_QT4_LIBDIR="NOTGIVEN")
	if test "$SS_QT4_LIBDIR" = "NOTGIVEN"; then
		AC_MSG_CHECKING([for the Qt 4.x libraries])

		ss_qt_library_test_dirs="$SS_QT4_GENERAL_DIR/lib /lib /usr/lib /usr/local/lib /usr/qt/lib /usr/local/qt/lib /usr/X11R6/lib /usr/lib/qt/lib /usr/lib/qt /usr/local/lib/qt/lib"
		test -n "$QTDIR" && ss_qt_library_test_dirs="$QTDIR/lib $QTDIR $ss_qt_library_test_dirs"
		ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/local/lib/qt /usr/X11R6/lib/qt /usr/build/qt/lib /opt/lib /opt/qt/lib"
		ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/lib/qt4 /usr/local/lib/qt4 /usr/X11R6/lib/qt4"
		ss_qt_library_test_dirs="$ss_qt_library_test_dirs /usr/build/qt4/lib /opt/qt4/lib"

		ss_qt_libs_to_find="libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.$SS_QT4_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.$SS_QT4_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.$SS_QT4_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find libQtCore.so.a"

		AC_SS_FIND_FILE_PATH($ss_qt_libs_to_find,$ss_qt_library_test_dirs,SS_QT4_LIBDIR)

		if test "$SS_QT4_LIBDIR" = "FAILED"; then
			AC_MSG_RESULT([FAILED])
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Can not find the qt 4.x library files."
			echo "### Make sure that qt is correctly installed on your system,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### (Usually a greater version is OK too)"
			echo "### Try to run configure again, this time passing the --with-qt4-library-dir"
			echo "### option (see ./configure --help)."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			AC_MSG_RESULT([found in $SS_QT4_LIBDIR])
		fi
	else
		AC_MSG_RESULT([using user supplied path for the Qt 4.x library $SS_QT4_LIBDIR])
	fi
])


AC_DEFUN([AC_SS_FIND_QT3_MOC],
[	
	AC_ARG_WITH(qt-moc,[  --with-qt-moc           filename of the Qt 3.x meta object compiler ],SS_QT3_MOC="$withval",SS_QT3_MOC="NOTGIVEN")

 	if test "$SS_QT3_MOC" = "NOTGIVEN"; then
		AC_MSG_CHECKING([for the Qt 3.x tmoc])

 		unset SS_QT3_MOC
		ss_moc_test_dirs="$QTDIR/bin $PATH /usr/bin /bin /usr/local/bin /usr/X11R6/bin /usr/lib/qt/bin /usr/local/qt/bin /usr/X11R6/qt/bin /usr/qt/bin /usr/build/qt/bin"
		if test -n "$SS_QT3_GENERAL_DIR"; then
			ss_moc_test_dirs="$SS_QT3_GENERAL_DIR/bin $ss_moc_test_dirs"
		fi

		AC_SS_FIND_FILE_PATH(tmoc,$ss_moc_test_dirs,SS_QT3_MOC)

		if test "$SS_QT3_MOC" = "FAILED"; then
			AC_MSG_RESULT([FAILED])
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### The Qt meta object compiler can not be found."
			echo "### Make sure that qt is correctly installed on your system, it is on your path,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### Try to run configure again, this time passing the --with-qt-moc"
			echo "### option (see ./configure --help)."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			SS_QT3_MOC="$SS_QT3_MOC/tmoc"
			AC_MSG_RESULT([found as $SS_QT3_MOC])
		fi
	else
		AC_MSG_RESULT([trusting you: using $SS_QT3_MOC])
 	fi
])


AC_DEFUN([AC_SS_FIND_QT4_MOC],
[	
	AC_ARG_WITH(qt4-moc,[  --with-qt4-moc          filename of the Qt 4.x meta object compiler ],SS_QT4_MOC="$withval",SS_QT4_MOC="NOTGIVEN")

 	if test "$SS_QT4_MOC" = "NOTGIVEN"; then
		AC_MSG_CHECKING([for the Qt 4.x moc])

 		unset SS_QT4_MOC
		ss_moc_test_dirs="$QTDIR/bin $PATH /usr/bin /bin /usr/local/bin /usr/X11R6/bin /usr/lib/qt/bin /usr/local/qt/bin /usr/X11R6/qt/bin /usr/qt/bin /usr/build/qt/bin"
		if test -n "$SS_QT4_GENERAL_DIR"; then
			ss_moc_test_dirs="$SS_QT4_GENERAL_DIR/bin $ss_moc_test_dirs"
		fi

		AC_SS_FIND_FILE_PATH(moc,$ss_moc_test_dirs,SS_QT4_MOC)

		if test "$SS_QT4_MOC" = "FAILED"; then
			AC_MSG_RESULT([FAILED])
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### The Qt 4.x meta object compiler can not be found."
			echo "### Make sure that qt is correctly installed on your system, it is on your path,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### In particular you should make sure that the moc compiler is NOT the one"
			echo "### shipped with Qt 3.x."
			echo "### Try to run configure again, this time passing the --with-qt4-moc"
			echo "### option (see ./configure --help)."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		else
			SS_QT4_MOC="$SS_QT4_MOC/moc"
			AC_MSG_RESULT([found as $SS_QT4_MOC])
		fi
	else
		AC_MSG_RESULT([trusting you: using $SS_QT4_MOC])
 	fi
])


AC_DEFUN([AC_SS_FIND_QT3_MT],
[
	AC_ARG_ENABLE(qt-mt,[  --disable-qt-mt         ignore the threaded version of Qt],SS_QT3_NOMT="$withval",SS_QT3_NOMT="NOTGIVEN")

	AC_MSG_CHECKING([for the multithreaded version of Qt])

	if test "$SS_QT3_NOMT" = "NOTGIVEN"; then
		ss_qt_libs_to_find="lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so.$SS_QT3_MAJOR_VERSION_REQUIRED"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.so"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.$SS_QT3_PATCH_LEVEL_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.$SS_QT3_MINOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.$SS_QT3_MAJOR_VERSION_REQUIRED.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.dylib"
		ss_qt_libs_to_find="$ss_qt_libs_to_find lib$SS_QTLIB_NAME-mt.a"

		AC_SS_FIND_FILE_PATH($ss_qt_libs_to_find,$SS_QT3_LIBDIR,SS_QTMTLIBDIR)
		if test "$SS_QTMTLIBDIR" = "FAILED"; then
			AC_MSG_RESULT([not found])
		else
			AC_MSG_RESULT([seems to be available])
			SS_QTLIB_NAME="$SS_QTLIB_NAME-mt"
		fi
	else
		AC_MSG_RESULT([disabled by user])
	fi
])

AC_DEFUN([AC_SS_ENSURE_CAN_COMPILE_X_AND_QT3],
[
	
		AC_MSG_CHECKING([if we can compile an X-Qt 3.x application])
		AC_LANG_CPLUSPLUS
		ss_save_CPPFLAGS="$CPPFLAGS"
		ss_save_CXXFLAGS="$CXXFLAGS"
		ss_save_LDFLAGS="$LDFLAGS"
		ss_save_LIBS="$LIBS"
		if test -n "$SS_X_INCDIR"; then
			CPPFLAGS="-I$SS_X_INCDIR"
		else
			CPPFLAGS=""
		fi
		CPPFLAGS="$CPPFLAGS -I$SS_QT3_INCDIR"
		CXXFLAGS="-O2 -Wall -I/usr/include/tqt -include tqt.h $CXXFLAGS"
		if test -n "$SS_X_LIBDIR"; then
			LIBS="-L$SS_X_LIBDIR"
		else
			LIBS=""
		fi
		LIBS="$LIBS -L$SS_QT3_LIBDIR -l$SS_QTLIB_NAME"
		if test -n "$SS_X_LDFLAGS"; then
			LIBS="$LIBS $SS_X_LDFLAGS"
		fi
		if test -n "$SS_X_LIBLINK"; then
			LIBS="$LIBS $SS_X_LIBLINK"
		fi
		LDFLAGS="-s $LDFLAGS"
		AC_TRY_LINK([
			#include <tqglobal.h>
			],[return 0; ],SS_QTX_LINKED_OK="TRUE",SS_QTX_LINKED_OK="FALSE")
		if test "$SS_QTX_LINKED_OK" = "FALSE"; then
			AC_MSG_RESULT([FAILED]);
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Failed to compile the Qt library test program."
			echo "### This may be a bad sign :)"
			echo "### First of all, make sure that qt is correctly installed on your system,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### Ensure that you have only one copy of qt visible at a time."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### The CPPFLAGS used were:"
			for a_flag in $CPPFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### The CXXFLAGS used were:"
			for a_flag in $CXXFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### The LIBS used were:"
			for a_flag in $LIBS ; do
				echo "###   $a_flag"
			done
			echo "### The LDFLAGS used were:"
			for a_flag in $LDFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### If you're sure that qt is correctly installed , you may force configure"
			echo "### to skip this check and try to compile kvirc anyway."
			echo "### Try using the --without-qt-check option."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		fi
		LIBS="$ss_save_LIBS"
		LDFLAGS="$ss_save_LDFLAGS"
		CXXFLAGS="$ss_save_CXXFLAGS"
		CPPFLAGS="$ss_save_CPPFLAGS"
		AC_MSG_RESULT([success])
])


AC_DEFUN([AC_SS_ENSURE_CAN_COMPILE_X_AND_QT4],
[
	
		AC_MSG_CHECKING([if we can compile an X-Qt 4.x application])
		AC_LANG_CPLUSPLUS
		ss_save_CPPFLAGS="$CPPFLAGS"
		ss_save_CXXFLAGS="$CXXFLAGS"
		ss_save_LDFLAGS="$LDFLAGS"
		ss_save_LIBS="$LIBS"
		if test -n "$SS_X_INCDIR"; then
			CPPFLAGS="-I$SS_X_INCDIR"
		else
			CPPFLAGS=""
		fi
		CPPFLAGS="$CPPFLAGS $SS_QT4_INCDIRECTORIES"
		CXXFLAGS="-O2 -Wall $CXXFLAGS"
		if test -n "$SS_X_LIBDIR"; then
			LIBS="-L$SS_X_LIBDIR"
		else
			LIBS=""
		fi
		LIBS="$LIBS -L$SS_QT4_LIBDIR -lQtCore"
		if test -n "$SS_X_LDFLAGS"; then
			LIBS="$LIBS $SS_X_LDFLAGS"
		fi
		if test -n "$SS_X_LIBLINK"; then
			LIBS="$LIBS $SS_X_LIBLINK"
		fi
		LDFLAGS="-s $LDFLAGS"
		AC_TRY_LINK([
			#include <qglobal.h>
			#if (TQT_VERSION < 0x040000)
				#error "Bad qt version: too old"
			#endif
			],[return 0; ],SS_QTX_LINKED_OK="TRUE",SS_QTX_LINKED_OK="FALSE")
		if test "$SS_QTX_LINKED_OK" = "FALSE"; then
			AC_MSG_RESULT([FAILED]);
			AC_SS_SET_REDINK
			echo "################################################################################"
			echo "### CONFIGURE ERROR:"
			echo "### Failed to compile the Qt 4.x library test program."
			echo "### This may be a bad sign :)"
			echo "### First of all, make sure that qt is correctly installed on your system,"
			echo "### and the qt version is the one requested by this version of kvirc."
			echo "### Ensure that you have only one copy of qt visible at a time."
			echo "### You may also take a look at the config.log file in this directory,"
			echo "### that will tell you which check has failed and maybe more about the reason"
			echo "### of the failure."
			echo "### The CPPFLAGS used were:"
			for a_flag in $CPPFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### The CXXFLAGS used were:"
			for a_flag in $CXXFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### The LIBS used were:"
			for a_flag in $LIBS ; do
				echo "###   $a_flag"
			done
			echo "### The LDFLAGS used were:"
			for a_flag in $LDFLAGS ; do
				echo "###   $a_flag"
			done
			echo "### If you're sure that qt is correctly installed , you may force configure"
			echo "### to skip this check and try to compile kvirc anyway."
			echo "### Try using the --without-qt-check option."
			echo "### If you're feeling that this may be a bug in this configure script"
			echo "### and want to report this to me , please include your configure script,"
			echo "### the config.log file as well as the complete configure output."
			echo "################################################################################"
			AC_SS_SET_NORMALINK
			AC_MSG_ERROR([This was a fatal one...aborting])
		fi
		LIBS="$ss_save_LIBS"
		LDFLAGS="$ss_save_LDFLAGS"
		CXXFLAGS="$ss_save_CXXFLAGS"
		CPPFLAGS="$ss_save_CPPFLAGS"
		AC_MSG_RESULT([success])
])


dnl ###################################################################################################################
dnl ### KDE
dnl ###################################################################################################################

AC_DEFUN([AC_SS_FIND_KDE],
[
	AC_SS_CHECK_IF_KDE_IS_REQUESTED
	if test "$SS_KDE_REQUESTED" = "yes"; then
		AC_SS_FIND_KDE_GENERAL_DIR
		if test "$SS_KDE_REQUESTED" = "yes"; then
			AC_SS_FIND_KDE_SERVICES_DIR
			AC_SS_FIND_KDE_LIBRARY_DIR
			if test "$SS_KDE_REQUESTED" = "yes"; then
				AC_SS_FIND_KDE_INCLUDE_DIR
				if test "$SS_KDE_REQUESTED" = "yes"; then
					AC_SS_ENSURE_CAN_COMPILE_X_QT3_AND_KDE
				fi
			fi
		fi
	fi
])

AC_DEFUN([AC_SS_CHECK_IF_KDE_IS_REQUESTED],
[
 	AC_MSG_CHECKING([if KDE support is requested])
	if test "$SS_USE_QT4" = "no"; then
		SS_KDE_REQUESTED="yes"
		AC_ARG_WITH(kde-support,[  --without-kde-support      Disable the KDE support even if it is detected ],SS_KDE_REQUESTED="$withval")
		if test "$SS_KDE_REQUESTED" = "yes"; then
			AC_MSG_RESULT([yes])
		else
			AC_MSG_RESULT([no])
		fi
	else
		SS_KDE_REQUESTED="no"
		AC_MSG_RESULT([unsupported with qt 4.x])
	fi
])

AC_DEFUN([AC_SS_FIND_KDE_GENERAL_DIR],
[
	AC_MSG_CHECKING([for the general KDE directory])
	ss_kde_general_test_dirs="/usr /usr/local /usr /usr/local /usr/build /usr/X11R6 /opt /usr/opt /usr/lib /usr/lib /usr/src /usr/lib /usr/local/lib"
	if test -n "$HOME"; then
		ss_kde_general_test_dirs="$ss_kde_general_test_dirs $HOME $HOME/lib"
	fi
	if test -n "$TDEDIR"; then
		ss_kde_general_test_dirs="$TDEDIR $ss_kde_general_test_dirs"
	fi
	ss_kde_general_test_path_suffix="trinity tde TDE kde kde3.0 kde3 KDE Kde KDE3 kde3 ."

	AC_SS_FIND_FILE_PATH_EXT($SS_KDE_GENERAL_FILE_TO_SEARCH,$ss_kde_general_test_dirs,$ss_kde_general_test_path_suffix,SS_KDE_GENERAL_DIR)

	if test "$SS_KDE_GENERAL_DIR" = "FAILED"; then
		AC_MSG_RESULT([failed...continuing with normal checks])
		unset SS_KDE_GENERAL_DIR
	else
		AC_MSG_RESULT([Seems to be $SS_KDE_GENERAL_DIR])
	fi
])


AC_DEFUN([AC_SS_FIND_KDE_SERVICES_DIR],
[
	AC_ARG_WITH(kde-services-dir,[  --with-kde-services-dir path to the KDE protocol services dir ],SS_KDE_SERVICESDIR="$withval",SS_KDE_SERVICESDIR="NOTGIVEN")
	if test "$SS_KDE_SERVICESDIR" = "NOTGIVEN"; then

		AC_MSG_CHECKING([for KDE services directory])

		ss_kde_services_test_dirs="/usr/share/services /usr/local/share/services /usr/kde/share/services /usr/local/kde/share/services /usr/X11R6/share/services /opt/kde/share/services /usr/lib/kde/share/services"
		test -n "$TDEDIR" && ss_kde_services_test_dirs="$TDEDIR/share/services $ss_kde_services_test_dirs"
		ss_kde_services_test_dirs="$ss_kde_services_test_dirs /usr/share/kde/services"
		test -n "$SS_KDE_GENERAL_DIR" && ss_kde_services_test_dirs="$SS_KDE_GENERAL_DIR/share/services $ss_kde_services_test_dirs"

		AC_SS_FIND_FILE_PATH("http.protocol",$ss_kde_services_test_dirs,SS_KDE_SERVICESDIR)

		if test "$SS_KDE_SERVICESDIR" = "FAILED"; then
			SS_KDE_SERVICESDIR=""
			AC_MSG_RESULT([unknown])
		else
			AC_MSG_RESULT([found in $SS_KDE_SERVICESDIR])
		fi

	else
		AC_MSG_RESULT([using user supplied path for the KDE services dir $SS_KDE_SERVICESDIR])
	fi
])


AC_DEFUN([AC_SS_FIND_KDE_INCLUDE_DIR],
[
	AC_ARG_WITH(kde-include-dir,[  --with-kde-include-dir  path to the KDE headers ],SS_KDE_INCDIR="$withval",SS_KDE_INCDIR="NOTGIVEN")
	if test "$SS_KDE_INCDIR" = "NOTGIVEN"; then

		AC_MSG_CHECKING([for KDE header files])

		ss_kde_include_test_dirs="/include /usr/include /usr/local/include /usr/kde/include /usr/local/kde/include /usr/X11R6/include /opt/kde/include /usr/lib/kde/include /usr/lib/kde /usr/include/X11"
		test -n "$TDEDIR" && ss_kde_include_test_dirs="$TDEDIR/include $TDEDIR $ss_kde_include_test_dirs"
		ss_kde_include_test_dirs="$ss_kde_include_test_dirs /usr/include/tde /usr/local/include/tde /include/tde /usr/X11R6/include/tde /usr/build/kde/include"
		ss_kde_include_test_dirs="$ss_kde_include_test_dirs /usr/include/tde2 /usr/local/include/tde2 /include/tde2 /usr/X11R6/include/tde2 /usr/include/X11/kde2"
		test -n "$SS_KDE_GENERAL_DIR" && ss_kde_include_test_dirs="$SS_KDE_GENERAL_DIR/include $ss_kde_include_test_dirs"
		test -n "$SS_KDE_GENERAL_DIR" && ss_kde_include_test_dirs="`$SS_KDE_GENERAL_DIR/bin/tde-config --expandvars --install include` $ss_kde_include_test_dirs"

		AC_SS_FIND_FILE_PATH($SS_KDE_INCLUDE_FILE_TO_SEARCH,$ss_kde_include_test_dirs,SS_KDE_INCDIR)

		if test "$SS_KDE_INCDIR" = "FAILED"; then
			AC_MSG_RESULT("FAILED")
			SS_KDE_REQUESTED="no"
			SS_KDE_INCDIR=""
		else
			AC_MSG_RESULT([found in $SS_KDE_INCDIR])
		fi

	else
		AC_MSG_RESULT([using user supplied path for the KDE include files $SS_KDE_INCDIR])
	fi

	if test -z "$SS_KDE_GENERAL_DIR"; then
		# Set it.... we need it :)...
		SS_KDE_GENERAL_DIR=`echo $SS_KDE_INCDIR | sed -e 's/\/include\$//'`
	fi
])

AC_DEFUN([AC_SS_FIND_KDE_LIBRARY_DIR],
[
	AC_ARG_WITH(kde-library-dir,[  --with-kde-library-dir  path to the KDE libraries ],SS_KDE_LIBDIR="$withval",SS_KDE_LIBDIR="NOTGIVEN")
	if test "$SS_KDE_LIBDIR" = "NOTGIVEN"; then
		AC_MSG_CHECKING([for the KDE libraries])

		ss_kde_library_test_dirs="/lib /usr/lib /usr/local/lib /usr/kde/lib /opt/kde/lib /opt/lib /usr/opt/kde/lib /usr/local/kde/lib /usr/X11R6/lib /usr/lib/kde/lib /usr/lib/kde /usr/local/lib/kde/lib"
		test -n "$TDEDIR" && ss_kde_library_test_dirs="$TDEDIR/lib $TDEDIR $ss_kde_library_test_dirs"
		ss_kde_library_test_dirs="$ss_kde_library_test_dirs /usr/local/lib/kde /usr/X11R6/lib/kde /usr/build/kde/lib"
		if test -n "$SS_KDE_GENERAL_DIR"; then
			ss_kde_library_test_dirs="$SS_KDE_GENERAL_DIR/lib $ss_kde_library_test_dirs"
		fi


		AC_SS_FIND_FILE_PATH(libtdecore.so.6 libtdecore.so.5 libtdecore.so.4 libtdecore.so.3 libtdecore.so,$ss_kde_library_test_dirs,SS_KDE_LIBDIR)
		if test "$SS_KDE_LIBDIR" = "FAILED"; then
			AC_SS_FIND_FILE_PATH(libtdecore.so.8 libtdecore.so.7 libtdecore.so.4.0.0 libtdecore.so.4.1.0 libtdecore.so.4.2.0 ,$ss_kde_library_test_dirs,SS_KDE_LIBDIR)
			if test "$SS_KDE_LIBDIR" = "FAILED"; then
				# Try the senseless too
				AC_SS_FIND_FILE_PATH(libtdecore.so.4.0.0 libtdecore.so.4.1.0 libtdecore.so.4.2.0 libtdecore.so.4.3.0,$ss_kde_library_test_dirs,SS_KDE_LIBDIR)
				if test "$SS_KDE_LIBDIR" = "FAILED"; then
					AC_SS_FIND_FILE_PATH(libtdecore.so.4.4.0 libtdecore.so.4.5.0 libtdecore.so.4.6.0 libtdecore.so.4.7.0 libtdecore.a,$ss_kde_library_test_dirs,SS_KDE_LIBDIR)
				fi
			fi
		fi

		if test "$SS_KDE_LIBDIR" = "FAILED"; then
			AC_MSG_RESULT("FAILED")
			SS_KDE_REQUESTED="no"
			SS_KDE_LIBDIR=""
		else
			AC_MSG_RESULT([found in $SS_KDE_LIBDIR])
		fi
	else
		AC_MSG_RESULT([using user supplied path for the KDE libraries $SS_KDE_LIBDIR])
	fi

	if test -z "$SS_KDE_GENERAL_DIR"; then
		# Set it.... we need it :)...
		SS_KDE_GENERAL_DIR=`echo $SS_KDE_LIBDIR | sed -e 's/\/lib\$//'`
	fi
])

AC_DEFUN([AC_SS_ENSURE_CAN_COMPILE_X_QT3_AND_KDE],
[
	AC_ARG_WITH(kde-check,[  --without-kde-check     Do not check if Qt,KDE and X compile ],SS_CHECK_QTX_COMPILE="$withval",SS_CHECK_KQTX_COMPILE="yes")
  	if test "$SS_CHECK_KQTX_COMPILE" = "yes"; then
		AC_MSG_CHECKING(if we can compile an X-Qt-KDE application)
		AC_LANG_CPLUSPLUS
		ss_save_CPPFLAGS="$CPPFLAGS"
		ss_save_CXXFLAGS="$CXXFLAGS"
		ss_save_LDFLAGS="$LDFLAGS"
		ss_save_LIBS="$LIBS"
		if test -n "$SS_X_INCDIR"; then
			CPPFLAGS="-I$SS_X_INCDIR"
		else
			CPPFLAGS=""
		fi
		CPPFLAGS="$CPPFLAGS -I$SS_X_INCDIR -I$SS_QT3_INCDIR -I$SS_KDE_INCDIR"
		CXXFLAGS="-O2 -Wall $CXXFLAGS"
		if test -n "$SS_X_LIBDIR"; then
			LIBS="-L$SS_X_LIBDIR"
		else
			LIBS=""
		fi
		if test -n "$SS_X_LDFLAGS"; then
			LIBS="$SS_X_LDFLAGS $LIBS"
		fi
		if test -n "$SS_X_LIBLINK"; then
			LIBS="$LIBS $SS_X_LIBLINK"
		fi
		LIBS="-L$SS_KDE_LIBDIR -L$SS_QT3_LIBDIR -ltdecore -l$SS_QTLIB_NAME $LIBS -Wl,-rpath $SS_KDE_LIBDIR"
		if test "$SS_LINK_TO_LIBDL" = "yes"; then
			LIBS="$LIBS -ldl";
		fi
		LDFLAGS="-s $LDFLAGS"
		AC_TRY_LINK([
				#include "kapp.h"
				#include "twin.h"
			],[
				int a = KWin::currentDesktop();
				TDEApplication app(a,0,TQCString("kvirc"));
			],
			SS_KQTX_LINKED_OK="TRUE",
			SS_KQTX_LINKED_OK="FALSE"
		)
		if test "$SS_KQTX_LINKED_OK" = "FALSE"; then
			AC_MSG_RESULT(failed)
			AC_MSG_ERROR([This was a fatal one...aborting])			
		else
			AC_MSG_RESULT(success)
		fi
		LIBS="$ss_save_LIBS"
		LDFLAGS="$ss_save_LDFLAGS"
		CXXFLAGS="$ss_save_CXXFLAGS"
		CPPFLAGS="$ss_save_CPPFLAGS"
	fi
])






AC_DEFUN([AC_SS_CHECK_OTHER_LIBS],
[
	SS_OTHER_LIBDIRS=""
	SS_OTHER_LIBLINK=""
	SS_OTHER_INCDIRS=""


	AC_MSG_CHECKING([if you want to link to libresolv])
	SS_DO_IT="false"
	AC_ARG_WITH(libresolv,      [  --with-libresolv        Link to libresolv],SS_DO_IT="true")
	if test "$SS_DO_IT" = "true"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_LIBLINK="$SS_OTHER_LIBLINK -lresolv"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to link to libsocket])
	SS_DO_IT="false"
	AC_ARG_WITH(libsocket,      [  --with-libsocket        Link to libsocket],SS_DO_IT="true")
	if test "$SS_DO_IT" = "true"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_LIBLINK="$SS_OTHER_LIBLINK -lsocket"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to link to libnsl])
	SS_DO_IT="false"
	AC_ARG_WITH(libnsl,         [  --with-libnsl           Link to libnsl],SS_DO_IT="true")
	if test "$SS_DO_IT" = "true"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_LIBLINK="$SS_OTHER_LIBLINK -lnsl"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to link to libcompat])
	SS_DO_IT="false"
	AC_ARG_WITH(libnsl,         [  --with-libcompat        Link to libcompat],SS_DO_IT="true")
	if test "$SS_DO_IT" = "true"; then
		AC_MSG_RESULT(yes)
		SS_OTHER_LIBLINK="$SS_OTHER_LIBLINK -lcompat"
	else
		AC_MSG_RESULT(no)
	fi

	AC_MSG_CHECKING([if you want to link to other libraries])
	SS_DO_IT="false"
	AC_ARG_WITH(other-libs,     [  --with-other-libs=...   Link to the specified libraries],SS_DO_IT="$withval")
	if test "$SS_DO_IT" != "false"; then
		AC_MSG_RESULT([yes])
		SS_OTHER_LIBLINK="$SS_OTHER_LIBLINK $SS_DO_IT"
	else
		AC_MSG_RESULT([no])
	fi

	AC_MSG_CHECKING([if you want to add other library search paths])
	SS_DO_IT="false"
	AC_ARG_WITH(other-ldirs,    [  --with-other-ldirs=...  Add the specified library paths],SS_DO_IT="$withval")
	if test "$SS_DO_IT" != "false"; then
		AC_MSG_RESULT([yes])
		SS_OTHER_LIBDIRS="$SS_OTHER_LIBDIRS $SS_DO_IT"
	else
		AC_MSG_RESULT([no])
	fi

	AC_MSG_CHECKING([if you want to add other include search paths])
	SS_DO_IT="false"
	AC_ARG_WITH(other-idirs,    [  --with-other-idirs=...  Add the specified include search paths],SS_DO_IT="$withval")
	if test "$SS_DO_IT" != "false"; then
		AC_MSG_RESULT([yes])
		SS_OTHER_INCDIRS="$SS_OTHER_INCDIRS $SS_DO_IT"
	else
		AC_MSG_RESULT([no])
	fi

])



AC_DEFUN([AC_SS_FINAL_CONFIG],
[
	AC_MSG_CHECKING([if we finally have to compile the IpV6 support])

	if test "$SS_NOIPV6_SUPPORT" = "true"; then
		AC_MSG_RESULT([no: disabled by user])
	else
		if test "$SS_HAVE_IPV6_FUNCTIONS" = "true"; then
			AC_MSG_RESULT([yes])
			AC_DEFINE([COMPILE_IPV6_SUPPORT], 1, [define if you want the IpV6 support])
			SS_BUILD_FLAGS="i$SS_BUILD_FLAGS"
		else
			AC_MSG_RESULT([no: the system lacks support])
		fi
	fi

	dnl # // Toplevel source directory

	SS_TOPSRCDIR=`pwd`

	AC_SUBST(SS_TOPSRCDIR)

	SS_CPPFLAGS="-D_REENTRANT -DREENTRANT"
	if test -n "$SS_X_CPPFLAGS"; then
		SS_CPPFLAGS="$SS_CPPFLAGS $SS_X_CPPFLAGS"
	fi

	if test "$SS_USE_QT4" = "no"; then
		SS_INCDIRS="-I$SS_QT3_INCDIR -I$SS_X_INCDIR"
	else
		AC_DEFINE([COMPILE_USE_QT4], 1, [define if you want to compile the Qt 4.x support])
		SS_INCDIRS="$SS_QT4_INCDIRECTORIES -I$SS_X_INCDIR"
		SS_CPPFLAGS="$SS_CPPFLAGS -DQT3_SUPPORT"
	fi

	if test -n "$SS_X_INCDIR"; then
		SS_INCDIRS="$SS_INCDIRS -I$SS_X_INCDIR"
	fi

	if test -n "$SS_X_LDFLAGS"; then
		SS_LDFLAGS="$SS_X_LDFLAGS"
	else
		SS_LDFLAGS=""
	fi

	if test "$SS_USE_QT4" = "no"; then
		SS_RPATH="-rpath $SS_QT3_LIBDIR -rpath $libdir"
	else
		SS_RPATH="-rpath $SS_QT4_LIBDIR -rpath $libdir"
	fi

	if test -n "$SS_X_LIBDIR"; then
		SS_RPATH="$SS_RPATH -rpath $SS_X_LIBDIR"
	fi

	if test "$SS_USE_QT4" = "no"; then
		SS_LIBDIRS="-L$SS_TOPSRCDIR/src/kvilib/build/ -L$SS_QT3_LIBDIR"
	else
		SS_LIBDIRS="-L$SS_TOPSRCDIR/src/kvilib/build/ -L$SS_QT4_LIBDIR"	
	fi

	if test -n "$SS_X_LIBDIR"; then
		SS_LIBDIRS="$SS_LIBDIRS -L$SS_X_LIBDIR"
	fi

	if test "$SS_USE_QT4" = "no"; then
		SS_LIBLINK="-l$SS_QTLIB_NAME"
	else
		#if test -n "SS_LOCAL_ADD_DEBUG_SYMBOLS"; then
		#	SS_LIBLINK="-lQtCore_debug -lQtGui_debug -lQt3Support_debug"
		#else
		
			SS_LIBLINK="-lQtCore -lQtGui -lQt3Support"
			
		#fi
	fi
	
	if test -n "$SS_X_LIBLINK"; then
		SS_LIBLINK="$SS_LIBLINK $SS_X_LIBLINK"
	fi
	SS_LIBLINK="$SS_LIBLINK $SS_THREAD_LIBLINK"
	if test "$SS_LINK_TO_LIBSSL" = "true"; then
		SS_LIBLINK="$SS_LIBLINK -lssl -lcrypto"
	fi
	if test "$SS_LINK_TO_LIBESD" = "true"; then
		SS_LIBLINK="$SS_LIBLINK -lesd"
	fi
	if test "$SS_LINK_TO_LIBARTS" = "true"; then
		SS_LIBLINK="$SS_LIBLINK -lsoundserver_idl"
	fi
	if test "$SS_LINK_TO_LIBAUDIOFILE" = "true"; then
		SS_LIBLINK="$SS_LIBLINK -laudiofile -lm"
	fi

	if test "$SS_LOCAL_8BIT" = "true"; then
		SS_CPPFLAGS="$SS_CPPFLAGS -DQT3_NO_ASCII_CAST -DQT3_NO_COMPAT"
	fi

	if test "$SS_QT3_EMBEDDED" = "true"; then
		SS_CPPFLAGS="$SS_CPPFLAGS -DQWS"
	fi

	if test "$SS_KDE_REQUESTED" = "yes"; then
		SS_INCDIRS="$SS_INCDIRS -I$SS_KDE_INCDIR"
		SS_RPATH="$SS_RPATH -rpath $SS_KDE_LIBDIR"
		SS_LIBDIRS="$SS_LIBDIRS -L$SS_KDE_LIBDIR"
		SS_LIBLINK="-ltdecore -ltdeui -ltdeparts -lDCOP -ltdefx -ltdeio $SS_LIBLINK"
		AC_DEFINE([COMPILE_TDE_SUPPORT], 1, [define if you want to compile the TDE support])
		AC_DEFINE_UNQUOTED([TDE_DIR], "$SS_KDE_GENERAL_DIR", [contain path to TDE if compiled with the TDE support])
		AC_DEFINE_UNQUOTED([TDE_LIBDIR], "$SS_KDE_LIBDIR", [contain path to TDE libs if compiled with the TDE support])
		SS_BUILD_FLAGS="k$SS_BUILD_FLAGS"
	else
		AC_DEFINE_UNQUOTED([TDE_DIR], "", [contain path to TDE if compiled with the TDE support])
		AC_DEFINE_UNQUOTED([TDE_LIBDIR], "", [contain path to TDE libs if compiled with the TDE support])
	fi

	if test -n "$SS_OTHER_LIBLINK"; then
		SS_LIBLINK="$SS_LIBLINK $SS_OTHER_LIBLINK"
	fi

	if test -n "$SS_OTHER_LIBDIRS"; then
		SS_LIBDIRS="$SS_LIBDIRS $SS_OTHER_LIBDIRS"
		SS_OTHER_LIBDIRS=`echo "$SS_OTHER_LIBDIRS" | sed -e s/-L//g`
		SS_RPATH="$SS_RPATH -rpath $SS_OTHER_LIBDIRS"
	fi

	if test -n "$SS_OTHER_INCDIRS"; then
		SS_INCDIRS="$SS_INCDIRS $SS_OTHER_INCDIRS"
	fi

	if test "$SS_LINK_TO_LIBDL" = "yes"; then
		SS_LIBLINK="$SS_LIBLINK -ldl"
	fi
	
	if test "$SS_LINK_TO_LIBZ" = "yes"; then
		SS_LIBLINK="$SS_LIBLINK -lz"
	fi
	if test "$SS_LINK_TO_XSS" = "yes"; then
		SS_LIBLINK="$SS_LIBLINK -lXss"
	fi

	AC_SUBST(SS_CPPFLAGS)
	AC_SUBST(SS_INCDIRS)
	AC_SUBST(SS_LDFLAGS)
	AC_SUBST(SS_RPATH)
	AC_SUBST(SS_LIBDIRS)
	AC_SUBST(SS_LIBLINK)
	
	if test "$SS_USE_QT4" = "no"; then
		SS_QT_MOC=$SS_QT3_MOC
		SS_QT_MOC_FLAGS=""
	else
		SS_QT_MOC=$SS_QT4_MOC
		SS_QT_MOC_FLAGS="-DCOMPILE_USE_QT4"
	fi
	
	AC_SUBST(SS_QT_MOC)
	AC_SUBST(SS_QT_MOC_FLAGS)

 	build_date=`date -u`

	if test -z "$build_date"; then
		build_date=`date`
	fi

	if test -z "$build_date"; then
		build_date="unknown"
	fi

	AC_DEFINE_UNQUOTED([BUILD_DATE],"$build_date", [this is the build date (configure date rather)])

	dnl # Let's sort the build flags

	SS_AUX_CHARS="a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"

	buid_flags=""

	for achar in $SS_AUX_CHARS; do
		tmp_val=`echo "$SS_BUILD_FLAGS" | grep $achar`
		if test "$tmp_val"; then
			build_flags="$build_flags$achar"
		fi
	done
	
	SS_DIRTAG=`echo $VERSION | cut -d . -f 1,2`
	
	AC_DEFINE_UNQUOTED([VERSION_BRANCH], "$SS_DIRTAG", [MAJOR.MINOR part of version])
	AC_DEFINE_UNQUOTED([BUILD_FLAGS],"$target_cpu-$build_flags", [these are the build flags])

	globalkvircdir="\${datadir}/kvirc/$SS_DIRTAG"
	AC_SUBST(globalkvircdir)

	configdir="\${globalkvircdir}/config"
	AC_SUBST(configdir)

	picsdir="\${globalkvircdir}/pics"
	AC_SUBST(picsdir)

	helpdir="\${globalkvircdir}/help/en"
	AC_SUBST(helpdir)

	pluglibdir="\${libdir}/kvirc/$SS_DIRTAG/modules"
	AC_SUBST(pluglibdir)

	modulelibdir="\${libdir}/kvirc/$SS_DIRTAG/modules"
	AC_SUBST(modulelibdir)

	defscriptdir="\${globalkvircdir}/defscript"
	AC_SUBST(defscriptdir)
	
	themedir="\${globalkvircdir}/themes"
	AC_SUBST(themedir)

	msgcolorsdir="\${globalkvircdir}/msgcolors"
	AC_SUBST(msgcolorsdir)

	if test -z "$mandir"; then
		mandir="\${exec_prefix}/man/man1"
	fi
	AC_SUBST(mandir)


	licensedir="\${globalkvircdir}/license"
	AC_SUBST(licensedir)

	if test -n "$SS_KDE_SERVICESDIR"; then
		kdeservicesdir="$SS_KDE_SERVICESDIR"
	else
		kdeservicesdir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/protocols"
	fi
	AC_SUBST(kdeservicesdir)

	if test "$SS_KDE_REQUESTED" = "yes"; then
		iconapps16datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/16x16/apps"
		iconapps32datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/32x32/apps"
		iconapps48datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/48x48/apps"
		iconapps64datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/64x64/apps"
		iconapps128datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/128x128/apps"
		iconappsscalabledatadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/scalable/apps"
		iconmime16datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/16x16/mimetypes"
		iconmime32datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/32x32/mimetypes"
		iconmime48datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/48x48/mimetypes"
		iconmime64datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/64x64/mimetypes"
		iconmime128datadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/128x128/mimetypes"
		iconmimescalabledatadir="$SS_KDE_GENERAL_DIR/share/icons/hicolor/scalable/mimetypes"
		applnkdir="$SS_KDE_GENERAL_DIR/share/applnk/Internet"
		mimelnkdir="$SS_KDE_GENERAL_DIR/share/mimelnk/text"
	else
		iconapps16datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/16x16"
		iconapps32datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/32x32"
		iconapps48datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/48x48"
		iconapps64datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/64x64"
		iconapps128datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/128x128"
		iconappsscalabledatadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/scalable"
		iconmime16datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/16x16"
		iconmime32datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/32x32"
		iconmime48datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/48x48"
		iconmime64datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/64x64"
		iconmime128datadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/128x128"
		iconmimescalabledatadir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/icons/scalable"
		applnkdir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/applnk"
		mimelnkdir="\${exec_prefix}/share/kvirc/$SS_DIRTAG/mimelnk"
	fi
	AC_SUBST(iconapps16datadir)
	AC_SUBST(iconapps32datadir)
	AC_SUBST(iconapps48datadir)
	AC_SUBST(iconapps64datadir)
	AC_SUBST(iconapps128datadir)
	AC_SUBST(iconappsscalabledatadir)
	AC_SUBST(iconmime16datadir)
	AC_SUBST(iconmime32datadir)
	AC_SUBST(iconmime48datadir)
	AC_SUBST(iconmime64datadir)
	AC_SUBST(iconmime128datadir)
	AC_SUBST(iconmimescalabledatadir)
	AC_SUBST(applnkdir)
	AC_SUBST(mimelnkdir)

	localedir="\${globalkvircdir}/locale"
	AC_SUBST(localedir)

	headersdir="\${exec_prefix}/include/kvirc/$VERSION"
	AC_SUBST(headersdir)


	configmodulesdir="\${globalkvircdir}/config/modules"
	AC_SUBST(configmodulesdir)


	topdir=`pwd`
	AC_SUBST(topdir)

	AC_SS_HEADER([Configuration status:])
	AC_SS_SET_GREENINK
	echo "### The kvirc binary will be installed in:"
	echo "###   $bindir"
	echo "### The libraries will be installed in:"
	echo "###   $libdir"
	echo "### Modules will be installed in:"
	echo "###   $pluglibdir"
	AC_SS_SET_NORMALINK
	AC_SS_HEADER([Take a look at the paths above just to be sure that they're correct])
])

dnl just a wrapper to clean up configure.in
AC_DEFUN([KVIRC_PROG_LIBTOOL],
[
	AM_PROG_LIBTOOL

	LIBTOOL_SHELL="/bin/sh ./libtool"
	#  LIBTOOL="$LIBTOOL --silent"

	AC_ARG_ENABLE(objprelink, [  --enable-objprelink     prelink apps (experimental, needs objprelink in path)],
	kvirc_use_objprelink=$enableval, kvirc_use_objprelink=no)
	if test "x$kvirc_use_objprelink" = "xyes"; then
		echo Patching libtool to run objprelink.
		mv libtool libtool.orig
		cat > libtool <<\EOF
#! /bin/sh

ALREADYPRELINKED=""

for n
do
	case $n in
		*.o) k=$n
			if test -r $k; then
				ISELF=`file $k | grep ELF`
				if test -n "$ISELF"; then
					ALREADY=`echo $ALREADYPRELINKED | grep "!!!$k"`
					if test -z "$ALREADY"; then
						echo objprelink $k
						objprelink $k
						ALREADYPRELINKED="$ALREADYPRELINKED !!!$k"
					fi
				fi
			fi
			;;
		*.lo) k=$n
			if test -r $k; then
				ISELF=`file $k | grep ELF`
				if test -n "$ISELF"; then
					ALREADY=`echo $ALREADYPRELINKED | grep "!!!$k"`
					if test -z "$ALREADY"; then
						echo objprelink $k
						objprelink $k
						ALREADYPRELINKED="$ALREADYPRELINKED !!!$k"
					fi
				fi
			fi
			ASHORTNAME=`echo $n | sed -e 's/\.lo$//'`
			k=".libs/$ASHORTNAME.o"
			if test -r $k; then
				ISELF=`file $k | grep ELF`
				if test -n "$ISELF"; then
					ALREADY=`echo $ALREADYPRELINKED | grep "!!!$k"`
					if test -z "$ALREADY"; then
						echo objprelink $k
						objprelink $k
						ALREADYPRELINKED="$ALREADYPRELINKED !!!$k"
					fi
				fi
			fi
			k=".libs/$ASHORTNAME.lo"
			if test -r $k; then
				ISELF=`file $k | grep ELF`
				if test -n "$ISELF"; then
					ALREADY=`echo $ALREADYPRELINKED | grep "!!!$k"`
					if test -z "$ALREADY"; then
						echo objprelink $k
						objprelink $k
						ALREADYPRELINKED="$ALREADYPRELINKED !!!$k"
					fi
				fi
			fi
			k="$ASHORTNAME.o"
			if test -r $k; then
				ISELF=`file $k | grep ELF`
				if test -n "$ISELF"; then
					ALREADY=`echo $ALREADYPRELINKED | grep "!!!$k"`
					if test -z "$ALREADY"; then
						echo objprelink $k
						objprelink $k
						ALREADYPRELINKED="$ALREADYPRELINKED !!!$k"
					fi
				fi
			fi
			;;
	esac
done

EOF
		cat >> libtool libtool.orig
		rm libtool.orig
		chmod a+x libtool
	fi
])
