dnl# -*- sh -*-
dnl# Process this file with autoconf to produce a configure script.
dnl#
dnl#Copyright (c) 1998 Michal Vitecek <fuf@fuf.sh.cvut.cz>
dnl#Copyright (c) 1998 Sasha Vasko <sasha at aftercode.net>
dnl#Copyright (c) 1998 Juergen Sawinski <Juergen.Sawinski@urz.uni-heidelberg.de>
dnl#Copyright (c) 1997 1998 Guylhem AZNAR <guylhem@oeil.qc.ca>

dnl#AC_INIT(afterstep/autoexec.in)
AC_INIT(AfterStep,2.00.00,as-bugs@afterstep.org,AfterStep.tar)
AC_CONFIG_AUX_DIR(autoconf)
AC_CONFIG_HEADER(config.h:autoconf/config.h.in)

version=$PACKAGE_VERSION
app_version=$PACKAGE_VERSION
libafterstep_version="1.00"
libafterstep_version_major="0"
libafterstep_name="LIBAFTERSTEP"
libafterstep_file_name="libAfterStep"
libafterconf_version="1.00"
libafterconf_version_major="0"
libafterconf_name="LIBAFTERCONF"
libafterconf_file_name="libAfterConf"

dnl# Setup command-line options

dnl# we need the standard prefixes defined early
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix="$prefix"
eval "bindir=$bindir"
eval "datadir=$datadir"
eval "mandir=$mandir"
eval "libdir=$libdir"
eval "includedir=$includedir"

dnl# directories
dnl# AC_ARG_WITH(gnustep_dir,	[  --with-gnustep-dir=DIR  GNUstep directory [[~/GNUstep]] ],with_gnustep_dir=$withval, with_gnustep_dir="~/GNUstep")
dnl# AC_ARG_WITH(gnustep_lib,	[  --with-gnustep-lib=DIR  GNUstep/Library directory [[Library]] ],with_gnustep_lib=$withval, with_gnustep_lib="Library")
AC_ARG_WITH(afterdir,		[  --with-afterdir=DIR     user AfterStep dir [[~/.afterstep]] ],with_afterdir=$withval, with_afterdir="~/.afterstep")

dnl# helper apps
AC_ARG_WITH(imageloader,	[  --with-imageloader=APP  used to display images in unsupported format  [[xli -onroot -quiet]] ],with_imageloader=$withval, with_imageloader="xli -onroot -quiet -colors 20")
AC_ARG_WITH(helpcommand,	[  --with-helpcommand=APP  display manpage for window [[xiterm -e man]] ],with_helpcommand=$withval, with_helpcommand="xiterm -e man")
AC_ARG_WITH(soundplayer,	[  --with-soundplayer=APP  used to play sounds from Audio [[play]] (from SOX package)],with_soundplayer=$withval, with_soundplayer="play")

dnl# look defaults
AC_ARG_WITH(startsort,		[  --with-startsort=METHOD start menu sorting method [[SORTBYALPHA]] ],with_startsort=$withval, with_startsort="SORTBYALPHA")
AC_ARG_ENABLE(different_looknfeels, [  --enable-different-looknfeels
                          different look&feel for each desktop [[no]] ],enable_different_looknfeels=$enableval,enable_different_looknfeels="no")
AC_ARG_WITH(desktops,		[  --with-desktops=DESKS   default desktops in pager [[4]] ],with_desktops=$withval, with_desktops="4")
AC_ARG_WITH(deskgeometry,	[  --with-deskgeometry=GEOM desktop views as COLUMNSxROWS [[2x2]] ],with_deskgeometry=$withval, with_deskgeometry="2x2")
with_desktops_1=`expr ${with_desktops} - 1`

dnl# The following is passed directly to libAfterImage configure :
AC_ARG_WITH(xpm,	    [  --with-xpm               support XPM image format [[yes]]])
AC_ARG_WITH(builtin_xpm,    [  --with-builtin-xpm       use builtin XPM parsing/handling instead of libXpm [[yes]]])
AC_ARG_WITH(xpm_includes,   [  --with-xpm-includes=DIR  use libXpm includes in DIR( when builtin XPM handling is disabled )], xpm_includes="$withval", xpm_includes=NO)
AC_ARG_WITH(jpeg,		    [  --with-jpeg              support JPEG image format [[yes]]])
AC_ARG_WITH(jpeg_includes,  [  --with-jpeg-includes=DIR use JPEG includes in DIR], jpeg_includes="$withval", jpeg_includes=NO)
AC_ARG_WITH(png,		    [  --with-png               support PNG image format [[yes]]])
AC_ARG_WITH(png_includes,   [  --with-png-includes=DIR  use PNG includes in DIR], png_includes="$withval", png_includes=NO)
AC_ARG_WITH(ungif,		[  --with-ungif            compile support for gif image format using libungif [[no]] ],with_ungif=$withval,with_ungif="no")
AC_ARG_WITH(gif,		[  --with-gif              compile support for gif image format using libgif [[no]] ],with_gif=$withval,with_gif="no")
AC_ARG_WITH(gif_includes,   [  --with-gif-includes=DIR  use GIF includes in DIR], gif_includes="$withval", gif_includes=NO)
AC_ARG_WITH(tiff,		    [  --with-tiff              support TIFF image format [[yes]]])
AC_ARG_WITH(tiff_includes,  [  --with-tiff-includes=DIR use TIFF includes in DIR], tiff_includes="$withval", tiff_includes=NO)

AC_ARG_WITH(tff,		    [  --with-ttf               support True Type Fonts via FreeType library [[yes]]])
AC_ARG_WITH(tff_includes,   [  --with-ttf-includes=DIR  use FreeType includes in DIR], ttf_includes="$withval", ttf_includes=NO)

dnl# compile-time switches
AC_ARG_ENABLE(i18n,		[  --enable-i18n           support I18N [[no]] ],enable_i18n=$enableval,enable_i18n="no")
AC_ARG_ENABLE(xlocale,		[  --enable-xlocale        using X_LOCALE [[no]] ],enable_xlocale=$enableval,enable_xlocale="no")
AC_ARG_ENABLE(savewindows,	[  --enable-savewindows    save windows and re-open next session [[yes]] ],enable_savewindows=$enableval,enable_savewindows="yes")
AC_ARG_ENABLE(virtual,		[  --enable-virtual        support virtual desktops [[yes]] ],enable_virtual=$enableval,enable_virtual="yes")
AC_ARG_ENABLE(windowlist,	[  --enable-windowlist     compile built-in window-list [[yes]] ],enable_windowlist=$enableval,enable_windowlist="yes")
AC_ARG_ENABLE(availability,	[  --enable-availability   check for unavailable binaries [[yes]] ],enable_availability=$enableval,enable_availability="yes")
AC_ARG_ENABLE(fixeditems,	[  --enable-fixeditems     enable fixed menu entries [[no]] ], enable_fixeditems=$enableval,enable_fixeditems="no")
AC_ARG_ENABLE(ascp,     	[  --enable-ascp           build AfterStep Control Panel [[yes]] ], enable_ascp=$enableval,enable_ascp="yes")

AC_ARG_WITH(locale,		[  --with-locale=LOCALE    locale name you want to use ],with_locale=$withval,with_locale="")
AC_ARG_ENABLE(shaping,		[  --enable-shaping        support shaped windows [[yes]] ],enable_shaping=$enableval,enable_shaping="yes")
AC_ARG_ENABLE(shmimage,		[  --enable-shmimage       support shared memory images [[yes]] ],enable_shmimage=$enableval,enable_shmimage="yes")
AC_ARG_ENABLE(xinerama,		[  --enable-xinerama       support Xinerama Multihead extentions [[yes]] ],enable_xinerama=$enableval,enable_xinerama="yes")
AC_ARG_ENABLE(staticlibs,       [  --enable-staticlibs     enable linking to libafterstep statically [[yes]] ],enable_staticlibs=$enableval,enable_staticlibs="yes")

AC_ARG_WITH(libefence,		[  --with-libefence        compile with libefence to debug buffer overruns [[no]] ],with_libefence=$withval,with_libefence="")
AC_ARG_ENABLE(gdb,		[  --enable-gdb            add gdb symbols (-g) (for debugging) [[no]] ],enable_gdb=$enableval,enable_gdb="no")
AC_ARG_ENABLE(sigsegv,		[  --enable-sigsegv        enable internal handler of Segmentation Fault (for self-diagnostics) [[yes]] ],enable_sigsegv=$enableval,enable_sigsegv="yes")
AC_ARG_ENABLE(warn,		[  --enable-warn           turn on more compiler warnings (for debugging) [[no]] ],enable_warn=$enableval,enable_warn="no")
AC_ARG_ENABLE(gprof,		[  --enable-gprof          add gprof symbols (-pg) (for debugging) [[no]] ],enable_gprof=$enableval,enable_gprof="no")
AC_ARG_ENABLE(audit,		[  --enable-audit          memory usage audit (for debugging) [[no]] ],enable_audit=$enableval,enable_audit="no")
AC_ARG_ENABLE(trace,		[  --enable-trace          some function calls tracing (see include/trace.h) (for debugging) [[no]] ],enable_trace=$enableval,enable_trace="no")
AC_ARG_ENABLE(trace-x,		[  --enable-trace-x        trace X calls (runtime option) (for debugging) [[no]] ],enable_trace_x=$enableval,enable_trace_x="no")
AC_ARG_ENABLE(mmx_optimization,	[  --enable-mmx-optimization  enable utilization of MMX instruction set to speed up imaging operations [[yes]] ],enable_mmx_optimization=$enableval,enable_mmx_optimization="yes")
AC_ARG_ENABLE(send-postcard-to-developer, [  --enable-send-postcard-to-developer will enable AfterSTep to send single e-mail to developers with your installation specifics.[[yes]] ],send_postcard_to_developer=$enableval,send_postcard_to_developer="yes")

AC_ARG_ENABLE(script,		[  --enable-script         compile Script module [[yes]] ], enable_script=$enableval,enable_script="yes")
AC_ARG_ENABLE(reuse-font,	[  --enable-reuse-font     enables reuse of loaded font resource by modules (don't use with TrueType fonts !)[[no]] ],[if test x$enableval == "xyes"; then AC_DEFINE(MODULE_REUSE_LOADED_FONT,1,Enables reuse of loaded font resource by modules) fi])

dnl# For FreeBSD, add -I/usr/local/include

FBSD="no"
if test `uname` = "FreeBSD"; then
        FBSD="yes"
        CPPFLAGS="-I/usr/local/include"
fi

echo "checking whether we are compiling in FreeBSD environment... $FBSD"

dnl# Comman stuff : compiler tools, proggies, etc.
AC_PROG_CC
AC_PROG_CXX

export CC
export GCC

export prefix
export exec_prefix

dnl# now we need to play abot with CFLAGS :

dnl# Add -Wall
if test "x$GCC" = "xyes"; then
  if test -z "`echo $CFLAGS | grep '\-Wall' 2> /dev/null`" ; then
    CFLAGS="$CFLAGS -Wall"
  fi
fi

dnl# Add -fPIC for IA64 compilation
AC_CYGWIN
if test "x$CYGWIN" != "xyes" -a "x$GCC" = "xyes" ; then
  if test -z "`echo $CFLAGS | grep '\-fPIC' 2> /dev/null`" ; then
    CFLAGS="$CFLAGS -fPIC"
  fi
  LDFLAGS="$LDFLAGS -rdynamic"
fi

dnl# Add -g
STRIP_BINARIES=
if test "x$enable_gdb" = "xyes"; then
  if ! test -n "`echo $CFLAGS' ' | grep '\-g ' 2> /dev/null`" ; then
	CFLAGS="$CFLAGS -g"
  fi
  if ! test -n "`echo $LDFLAGS' ' | grep '\-g ' 2> /dev/null`" ; then
	LDFLAGS="$LDFLAGS -g"
  fi
else
  STRIP_BINARIES="-s"
  DIRTY_CFLAGS="$CFLAGS"
  CFLAGS="-DNO_DEBUG_OUTPUT"
  for f in $DIRTY_CFLAGS; do 
        if test "x$f" != "x-g"; then
	   CFLAGS="$CFLAGS $f"
	fi	 
  done
fi

dnl# Add -pg
if test "x$enable_gprof" = "xyes"; then
  CFLAGS="$CFLAGS -pg"
  LDFLAGS="$LDFLAGS -pg"
fi

dnl# Add lots more warnings
if test "x$enable_warn" = "xyes"; then
  CFLAGS="$CFLAGS -Wuninitialized -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wconversion -Wcomment -Wcast-align -Winline -Wshadow -Wredundant-decls -Wid-clash-31"
fi

dnl# done with flags - lets export those for our children to use :
export CFLAGS
export LDFLAGS

dnl# install checks :
AC_PROG_INSTALL
dnl# if the path to the install program is relative, make it absolute
currdir=`pwd`
INSTALL=`echo $INSTALL|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
INSTALL_PROGRAM=`echo $INSTALL_PROGRAM|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
INSTALL_DATA=`echo $INSTALL_DATA|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`
INSTALL_LIB=`echo $INSTALL_LIB|sed -e "s@\^\.\.@${currdir}@" -e "s@^autoconf@${currdir}/autoconf@"`

export INSTALL
export INSTALL_PROGRAM
export INSTALL_DATA
export INSTALL_LIB

AC_PROG_RANLIB
export RANLIB

AC_PATH_PROG(RM, rm, rm)
export RM
AC_PATH_PROG(MV, mv, mv)
export MV
AC_PATH_PROG(CP, cp, cp)
export CP
AC_PATH_PROG(MKDIR, mkdir, mkdir)
export MKDIR
AC_PATH_PROG(PERL, perl, perl)
export PERL
AC_PATH_PROG(FIND, find, find)
export FIND
AC_PATH_PROG(XARGS, xargs, xargs)
export XARGS
AC_PATH_PROG(LDCONFIG, ldconfig, ldconfig, $PATH:/sbin:/usr/local/sbin)
export LDCONFIG

dnl# Checks for optional programs
AC_PROG_LEX
export LEX
export LEXLIB
AC_PROG_YACC
export YACC
AC_CHECK_PROG(sgmltools, sgmltools, HAVE_SGMLTOOLS, NO_SGMLTOOLS)
export sgmltools


dnl# Check for X :
AC_PATH_XTRA

user_ldflags=$LDFLAGS

x_libs="$X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS"
if test "x$user_ldflags" = "x"; then
	full_x_libs=$x_libs
else
	full_x_libs="$user_ldflags $x_libs"
fi

AC_CHECK_LIB(X11, XOpenDisplay, [x_libs="-lX11 $x_libs"],,$full_x_libs)
if test "x$enable_xlocale" = "xyes"; then
  AC_CHECK_LIB(X11, _Xsetlocale, AC_DEFINE(X_LOCALE,1,"X Locale support enabled"),, $full_x_libs)
fi



dnl# have to update full_x_libs again as x_libs may have changed above
if test "x$user_ldflags" = "x"; then
	full_x_libs=$x_libs
else
	full_x_libs="$user_ldflags $x_libs"
fi

have_shmimage=no

if test "x$CYGWIN" == "xyes"; then
	enable_shmimage=no
fi

if test "x$enable_shmimage" = "xyes"; then
	AC_CHECK_LIB(Xext, XShmCreateImage, [have_shmimage=yes],,$full_x_libs)
	if test "x$have_shmimage" = "xyes"; then
		AC_CHECK_HEADER(sys/ipc.h,,[have_shmimage=no])
	fi
	if test "x$have_shmimage" = "xyes"; then
		AC_CHECK_HEADER(sys/shm.h,,[have_shmimage=no])
	fi
	if test "x$have_shmimage" = "xyes"; then
		add_lib_xext=yes
		AC_DEFINE(XSHMIMAGE,1,Support for Shared memory images - unsafe in *bsd due to limited number of segments)
	fi
fi

dnl# Check for X shaped window extension
HAVESHAPE="NOSHAPE"
if test "x$enable_shaping" = "xyes"; then
  	AC_CHECK_LIB(Xext, XShapeCombineMask, [have_shaping=yes add_lib_xext=yes AC_DEFINE(SHAPE,1,Support for shaped windows)],,$full_x_libs)
fi



PATH_XTRA_CHECKED=yes
export PATH_XTRA_CHECKED
export x_includes
export x_libraries
AC_SUBST(x_libraries)
export X_CFLAGS
export X_LIBS
export X_EXTRA_LIBS
export X_PRE_LIBS
export CPP
export have_x
export have_shmimage
export have_shaping

dnl# DONE WITH COMMON STUFF
dnl# #############################################################
dnl# first configuringlibraries :

FROM_AFTERSTEP_CONFIGURE=yes
export FROM_AFTERSTEP_CONFIGURE

_def_lib_conf_opts=" \
	--prefix=${prefix} \
	--exec-prefix=${exec_prefix} \
	--bindir=${bindir} \
	--sbindir=${sbindir} \
	--libexecdir=${libexecdir} \
	--datadir=${datadir} \
	--sysconfdir=${sysconfdir} \
	--sharedstatedir=${sharedstatedir} \
	--localstatedir=${localstatedir} \
	--libdir=${libdir} \
	--includedir=${includedir} \
	--oldincludedir=${oldincludedir} \
	--infodir=${infodir} \
	--mandir=${mandir} \
	--with-x-includes=${x_includes} \
	--with-x=${with_x} \
	--enable-audit=${enable_audit} \
	--enable-trace=${enable_trace} \
	--enable-shmimage=${enable_shmimage} \
"

AC_CHECKING(libAfterBase)
cd libAfterBase; \
./configure $_def_lib_conf_opts \
   --enable-trace-x=$enable_trace_x; \
cd ../
afterbase_lib=

AC_CHECKING(libAfterImage)
cd libAfterImage; \
./configure $_def_lib_conf_opts \
   --enable-i18n=$enable_i18n --enable-xlocale=$enable_xlocale --with-locale=$with_locale \
   --with-xpm=$with_xpm   --with-builtin-xpm=$with_builtin_xpm  --with-xpm-includes=$xpm_includes \
   --with-jpeg=$with_jpeg --with-jpeg-includes=$jpeg_includes \
   --with-png=$with_png   --with-png-includes=$png_includes \
   --with-gif=$with_gif   --with-ungif=$with_ungif  --with-gif-includes=$gif_includes \
   --with-tiff=$with_tiff --with-tiff-includes=$tiff_includes \
   --with-ttf=$with_ttf   --with-ttf-includes=$ttf_includes \
   --enable-mmx-optimization=$enable_mmx_optimization \
   --with-ungif=$with_ungif --with-gif=$with_gif; \
cd ../
afterimage_lib=

dnl# let's check for endiannes of our box
AC_C_BIGENDIAN
AC_C_INLINE

dnl# Check for headers
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h malloc.h stdlib.h)

AC_CHECK_HEADERS(sys/wait.h,,AC_FUNC_WAIT3)

dnl# Check for librplay for Audio

AUDIO_LIBS=
AUDIO_PLAY_CMD=builtin-cat
dnl# AC_CHECK_LIB(rplay,rplay,[AC_CHECK_HEADER(rplay.h,AC_DEFINE(HAVE_RPLAY))])
AC_CHECK_LIB(rplay,rplay,[AC_CHECK_HEADERS(rplay.h,[AUDIO_LIBS=-lrplay; AUDIO_PLAY_CMD=builtin-rplay])])

AC_SUBST(AUDIO_LIBS)
AC_SUBST(AUDIO_PLAY_CMD)

if test "x$add_lib_xext" = "xyes"; then
	x_libs="$x_libs -lXext"
	full_x_libs="$x_libs -lXext"
fi

dnl# Check for Xinerama extension

HAVEXINE="NOXINE"
if test "x$enable_xinerama" = "xyes"; then
  AC_CHECK_LIB(Xinerama, XineramaQueryScreens, [x_libs="-lXinerama $x_libs";AC_DEFINE(HAVE_XINERAMA,1,Support for Xinerama multiscreen)],,$full_x_libs)
fi

if test "x$enable_sigsegv" = "xyes"; then
  AC_DEFINE(HAVE_SIGSEGV_HANDLING,1,self diagnostic SIGSEGV handling (as opposed to dumping core))
fi

if test "x$enable_staticlibs" = "xyes"; then
   AFTERBASE_LIB="../../libAfterBase/libAfterBase.a"
   AFTERIMAGE_LIB="../../libAfterImage/libAfterImage.a"
   AFTERSTEP_LIB="../../libAfterStep/libAfterStep.a"
   AFTERCONF_LIB="../../libAfterConf/libAfterConf.a"
   WIDGETS_LIB="../Script/Widgets/libWidgets.a"
   LIBPROG='$(LIB_STATIC)'
   LIBINSTALL="install.static"
else
   AFTERBASE_LIB="../../libAfterBase/libAfterBase.so"
   AFTERIMAGE_LIB="../../libAfterImage/libAfterImage.so"
   AFTERSTEP_LIB="../../libAfterStep/libAfterStep.so"
   AFTERCONF_LIB="../../libAfterConf/libAfterConf.so"
   WIDGETS_LIB="../Script/Widgets/libWidgets.so"
   LIBPROG='$(LIB_SHARED)'
   LIBINSTALL="install.dyn"
fi

AC_MSG_CHECKING(libAfterImage external libraries)
AFTERIMAGE_LIBS=`libAfterImage/afterimage-libs --external-only`
AC_MSG_RESULT($AFTERIMAGE_LIBS)
AC_MSG_CHECKING(preferred image format)
image_format=`libAfterImage/afterimage-libs --preferred-image-format`
AC_MSG_RESULT($image_format)

dnl# if ascp requested - check for fltk libraries

LIBS=$saved_LIBS

ASCP_FLTK_LIBS=
ASCP_FLTK_INCLUDES=
ASCP_FLTK=
ASCP_GTK_LIBS=
ASCP_GTK_INCLUDES=
ASCP_GTK=

if test "x$enable_ascp" = "xyes"; then
    AC_MSG_CHECKING(libraries required by FLTK version of ascp)
	enable_ascp=no ;

    if fltk-config --libs >/dev/null  ;then
		present_libs="$LDFLAGS $LIBS $x_libs $AFTERIMAGE_LIBS";
		for l in `fltk-config --ldstaticflags`; do
	  	  lib_found=no
	  	  for p in `echo "$present_libs"` ; do
			  if test "x$l" = "x$p" ; then
    		    lib_found=yes;
		  	  fi;
	  	  done;
	  	  if test "x$lib_found" != "xyes" ; then
		  	ASCP_FLTK_LIBS="$ASCP_FLTK_LIBS $l" ;
	  	  fi;
		done;
		AC_MSG_RESULT($ASCP_FLTK_LIBS)
	    AC_MSG_CHECKING(headers required by ascp-fltk)
	
  		if fltk-config --cflags >/dev/null  ;then
			present_incs="$CCFLAGS $x_includes";
			for l in `fltk-config --cflags` ;	do
	  			inc_found=no
		  		for p in `echo "$present_incs"` ; do
					if test "x$l" = "x$p" ; then
    		  			inc_found=yes;
					fi;
					if test "x$l" = "x-I$p" ; then
    		  			inc_found=yes;
					fi;
	  			done;
	  			if test "x$inc_found" != "xyes" ; then
					ASCP_FLTK_INCLUDES="$ASCP_FLTK_INCLUDES $l" ;
	  			fi;
			done;
			AC_MSG_RESULT($ASCP_FLTK_INCLUDES)
			enable_ascp=yes ;
	  		ASCP_FLTK=ascp-fltk ;
  		fi;
	fi;
    AC_MSG_CHECKING(libraries required by GTK version of ascp)
    if gtk-config --libs >/dev/null  ;then
		present_libs="$LDFLAGS $LIBS $x_libs $AFTERIMAGE_LIBS";
		for l in `gtk-config --libs`; do
	  	  lib_found=no
	  	  for p in `echo "$present_libs"` ; do
			  if test "x$l" = "x$p" ; then
    		    lib_found=yes;
		  	  fi;
	  	  done;
	  	  if test "x$lib_found" != "xyes" ; then
		  	ASCP_GTK_LIBS="$ASCP_GTK_LIBS $l" ;
	  	  fi;
		done;
		AC_MSG_RESULT($ASCP_GTK_LIBS)
	    AC_MSG_CHECKING(headers required by ascp-gtk)
	
  		if gtk-config --cflags >/dev/null  ;then
			present_incs="$CCFLAGS $x_includes";
			for l in `gtk-config --cflags` ;	do
	  			inc_found=no
		  		for p in `echo "$present_incs"` ; do
					if test "x$l" = "x$p" ; then
    		  			inc_found=yes;
					fi;
					if test "x$l" = "x-I$p" ; then
    		  			inc_found=yes;
					fi;
	  			done;
	  			if test "x$inc_found" != "xyes" ; then
					ASCP_GTK_INCLUDES="$ASCP_GTK_INCLUDES $l" ;
	  			fi;
			done;
			AC_MSG_RESULT($ASCP_GTK_INCLUDES)
			enable_ascp=yes ;
	  		ASCP_GTK=ascp-gtk ;
  		fi;
	fi;
	if test "x$enable_ascp" = "xno"; then
		AC_MSG_RESULT(neither fltk nor GTK found, ascp disabled)
		echo "You have to install FLTK or GTK libaries in order to be able to compile ascp."
    fi;
fi;

dnl# Electric Fence goes at the end
if test "x$with_libefence" = "xyes"; then
  AC_CHECK_LIB(efence,malloc,x_libs="$x_libs -lefence")
fi

dnl# Translate enable_* from "yes/no" to "1/0" (for configure.h)

if test "x$enable_different_looknfeels" = "xyes"; then AC_DEFINE(DIFFERENTLOOKNFEELFOREACHDESKTOP,1,Each desktop may have its own look/feel) fi
if test "x$enable_i18n" = "xyes"; then AC_DEFINE(I18N,1,Internationalized text support) fi
if test "x$enable_savewindows" = "xno"; then AC_DEFINE(NO_SAVEWINDOWS,1,Save windows and re-open next session) fi
if test "x$enable_virtual" = "xno"; then AC_DEFINE(NO_VIRTUAL,1,virtual screen support - several pages poer desktop) fi
if test "x$enable_windowlist" = "xno"; then AC_DEFINE(NO_WINDOWLIST,1,Support for window list) fi
if test "x$enable_availability" = "xno"; then AC_DEFINE(NO_AVAILABILITYCHECK,1,Check availability of menu items at startup) fi
if test "x$enable_fixeditems" = "xyes"; then AC_DEFINE(FIXED_DIR, "fixed", enable fixed menu entries) fi
if test "x$enable_audit" = "xyes"; then AC_DEFINE(DEBUG_ALLOCS,1,Trace memory allocations and check for errors) fi
if test "x$enable_trace" = "xyes"; then AC_DEFINE(DEBUG_TRACE,1,Trace some functions) fi
if test "x$enable_trace_x" = "xyes"; then AC_DEFINE(DEBUG_TRACE_X,1,Trace different X calls) fi
if test "x$enable_script" = "xyes"; then enable_script="1"; else enable_script="0"; fi

dnl# Variable strings declaration

dnl# don't process Script and its subdirs if it wasn't asked
SCRIPT_DIR=""
if test "x$enable_script" = "x1"; then
    SCRIPT_DIR="src/Script/Widgets src/Script"
fi

if test "x$send_postcard_to_developer" = "xyes"; then
	AC_CHECK_FUNCS(popen)
	AC_DEFINE(DO_SEND_POSTCARD,1,E-mail installation notification to AfterStep developers)
fi

AC_CANONICAL_TARGET
AC_SUBST(build)
AC_SUBST(build_os)
AC_SUBST(build_cpu)
AC_SUBST(build_vendor)

AC_SUBST(STRIP_BINARIES)
AC_SUBST(version)
AC_SUBST(app_version)
AC_SUBST(libafterstep_version)
AC_SUBST(libafterstep_version_major)
AC_SUBST(libafterstep_name)
AC_SUBST(libafterstep_file_name)
AC_SUBST(libafterwidget_version)
AC_SUBST(libafterwidget_version_major)
AC_SUBST(libafterwidget_name)
AC_SUBST(libafterwidget_file_name)
AC_SUBST(libafterconf_version)
AC_SUBST(libafterconf_version_major)
AC_SUBST(libafterconf_name)
AC_SUBST(libafterconf_file_name)
AC_SUBST(with_locale)
AC_SUBST(image_format)
AC_SUBST(ASCP_FLTK)
AC_SUBST(ASCP_FLTK_LIBS)
AC_SUBST(ASCP_FLTK_INCLUDES)
AC_SUBST(ASCP_GTK)
AC_SUBST(ASCP_GTK_LIBS)
AC_SUBST(ASCP_GTK_INCLUDES)
AC_SUBST(user_ldflags)
AC_SUBST(x_libs)
AC_SUBST(x_includes)
AC_SUBST(XEXT_LIB)
AC_SUBST(AFTERBASE_LIB)
AC_SUBST(AFTERIMAGE_LIB)
AC_SUBST(AFTERIMAGE_LIBS)
AC_SUBST(AFTERSTEP_LIB)
AC_SUBST(AFTERCONF_LIB)
AC_SUBST(WIDGETS_LIB)
AC_SUBST(LIBPROG)
AC_SUBST(LIBINSTALL)
AC_SUBST(sgmltools)
AC_SUBST(with_afterdir)
AC_SUBST(with_imageloader)
AC_SUBST(with_soundplayer)
AC_SUBST(with_helpcommand)
AC_SUBST(with_startsort)
AC_SUBST(with_desktops)
AC_SUBST(with_desktops_1)
AC_SUBST(with_deskgeometry)
dnl# old stuff :
AC_SUBST(enable_different_looknfeels)
AC_SUBST(enable_pagerbackground)
AC_SUBST(enable_i18n)
AC_SUBST(enable_menuwarp)
AC_SUBST(enable_savewindows)
AC_SUBST(enable_texture)
AC_SUBST(enable_shade)
AC_SUBST(enable_virtual)
AC_SUBST(enable_saveunders)
AC_SUBST(enable_windowlist)
AC_SUBST(enable_availability)
AC_SUBST(enable_fixeditems)

AC_SUBST(SCRIPT_DIR)
AC_SUBST(PERL)

dnl# Write results

dnl# AC_CONFIG_HEADER(include/config.h)

dnl# Common parts of the Makefile
MAKEFILEDEFINES=./autoconf/Makefile.defines
MAKEFILECOMMON=./autoconf/Makefile.common
MAKEFILECOMMONLIB=./autoconf/Makefile.common.lib
LIBAFTERBASEFILES=./libAfterBase/.shared
LIBAFTERIMAGEFILES=./libAfterImage/.shared
LIBAFTERSTEPFILES=./libAfterStep/.shared
LIBAFTERCONFFILES=./libAfterConf/.shared

AC_SUBST_FILE(LIBAFTERBASEFILES)
AC_SUBST_FILE(LIBAFTERIMAGEFILES)
AC_SUBST_FILE(LIBAFTERSTEPFILES)
AC_SUBST_FILE(LIBAFTERCONFFILES)

AC_SUBST_FILE(MAKEFILEDEFINES)
AC_SUBST_FILE(MAKEFILECOMMON)
AC_SUBST_FILE(MAKEFILECOMMONLIB)

AC_OUTPUT(\
autoconf/Makefile.defines \
autoconf/Makefile.common \
autoconf/Makefile.common.lib \
configure.h \
Makefile \
AfterStep.spec \
AfterStep.desktop \
\
afterstep/Makefile \
\
doc/Makefile \
doc/afterstepdoc \
\
libAfterStep/afterstep-config \
libAfterStep/Makefile \
libAfterConf/Makefile \
\
src/afterstep/Makefile \
src/ascp/Makefile \
src/ascp/fltk/Makefile \
src/ascp/gtk/Makefile \
src/asetroot/Makefile \
src/Animate/Makefile \
src/Audio/Makefile \
src/ASDocGen/Makefile \
src/Banner/Banner.sh \
src/Banner/Makefile \
src/Cascade/Makefile \
src/Clean/Makefile \
src/Form/Makefile \
src/Gnome/Makefile \
src/Ident/Makefile \
src/Pager/Makefile \
src/Save/Makefile \
src/Script/Widgets/Makefile \
src/Script/Makefile \
src/Scroll/Makefile \
src/Sound/Makefile \
src/Tile/Makefile \
src/Wharf/Makefile \
src/WinList2/Makefile \
src/WinTabs/Makefile \
src/Gadget/Makefile \
src/test/Makefile \
\
tools/Makefile \
tools/installastheme.pl \
tools/makeastheme.pl \
\
afterstep/base \
afterstep/audio \
afterstep/autoexec \
afterstep/pager \
afterstep/start/.include \
afterstep/start/1_Desktop/Feel/.include \
afterstep/start/1_Desktop/Color_Scheme/.include \
afterstep/start/1_Desktop/Look/.include \
afterstep/start/1_Desktop/Theme/.include \
afterstep/start/1_Desktop/Pictures/.include \
)

echo "
PRIVACY NOTICE

AS required by goverment regulations we now disclose all the illigal snooping 
activities, that AfterStep Window Manager will be performing on your 
computer(s).

Being Big Brother AfterStep will keep an eye on any suspicious window movements
on your screen, different clicking sounds made by your keyboard, detect slightest
vibrations of your mouse/trackball, and most importantly  - it will keep track 
of what images your are displaying in the root window of your desktop.

Being Good hearted Big Brother, though AfterStep will keep all this information 
in secret, and most likely will forget about it immidiately. Nothing will be 
logged, mailed, broadcast or otherwise disclosed to unauthorized parties. So 
your secrets are safe with it.

The only exception is when you compile it with --enable-gdb option or 
--enable-audit. In this case sagnificant amounts of activity will be logged - 
printed into console output. Make sure you keep it safe from all the malicious 
persons out there (and from overflowing your disk)! It is your responsibility 
now.

And finally we are coming to the fun part. AS it is the only compensation that
developers of this lousy software get - AfterStep will automagically e-mail a 
single message anytime ~/.afterstep directory needs to be rebuilt. This message 
will contain such a vital information as date, time, your X server color depth, 
number of X screens, number of xinerama screens, compiler version, kernel 
version, and list of linked to libraries.

If you object to this e-mailing activity - please make sure and use the 
following ./configure option : --disable-send-postcard-to-developer

That is all! We will go back to your regular programming now.

Oh, almost forgot -


AfterStep $version IS NOW HOPEFULLY CONFIGURED:

Just run : make ; make install

and enjoy your eyecandy :)
"
