dnl Configure a Makefile for pstoedit
dnl initial version by Scott Pakin <scott+ps2ed_AT_pakin.org>

dnl Adapting automake
dnl By Masatake YAMATO<jet _AT_ gyve.org>

dnl ------------------------------------------------------------------------
dnl NOTE: I have tested this only on Linux/g++, Solaris/g++, and Solaris/CC,
dnl       as those are all the systems I have access to.
dnl ------------------------------------------------------------------------

dnl Initialize Autoconf. 
AC_INIT([pstoedit],[4.3],[wglunz35_AT_pstoedit.net],[],[http://www.pstoedit.com])


AC_ARG_ENABLE([check_for_gs],
              [AS_HELP_STRING([--disable-check_for_gs],
			      [do not check for GhostScript during configure])],
              [CHECKGS=false],
              [CHECKGS=true])

if $CHECKGS ; then
dnl Check Ghostscript
AC_CHECK_PROGS([GS],[gs],[false])
AS_IF([test x"${GS}" = xfalse],[AC_MSG_ERROR([** Cannot find ghostscript.  If it is already installed, Check PATH.])])
dnl AC_PREFIX_PROGRAM(gs)
else
   AC_MSG_RESULT([checking for GhostScript was skipped - but you need this latest at runtime.])
fi

AC_LANG(C++)
dnl AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE([foreign subdir-objects info-in-builddir -Wall])
dnl AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR([src/pstoedit.h])
AC_CONFIG_MACRO_DIR([m4])

dnl We need only C++ and no other language
dnl seems to be broken : AC_LIBTOOL_TAGS([CXX])

dnl Check for various programs the Makefile needs.
AC_PROG_CC
AC_PROG_CXX

AC_MSG_CHECKING(for g++ std)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ constexpr int ce = 10; int * p = nullptr; ]])],
               [AC_MSG_RESULT(you seem to have suitable version of g++)],
               [AC_MSG_ERROR([your version of g++ seems to be too old.])])

AC_PROG_AWK
AC_PROG_YACC
AM_PROG_AR
AC_PROG_INSTALL
dnl there is no need to build the static libs if shared libs are available
LT_INIT([disable-static win32-dll dlopen])
LT_LANG([C++])
AC_SUBST([LIBTOOL_DEPS])

AC_PROG_MAKE_SET

AC_CONFIG_HEADERS([src/pstoedit_config.h])

dnl Check file command
dnl FILECMD=""
dnl AC_PATH_PROG(FILECMD,file)
dnl if test -z "${FILECMD}"; then
dnl    AC_MSG_ERROR([** Cannot find file command which is needed for libtool. Please install. ])
dnl    exit 1
dnl fi


PKG_PROG_PKG_CONFIG([1.8.0])

AC_C_BIGENDIAN([CPPFLAGS="$CPPFLAGS -D_BIG_ENDIAN"], [CPPFLAGS="$CPPFLAGS -D_LITTLE_ENDIAN"])

dnl check for directory handling
AC_HEADER_DIRENT

dnl check for the more secure versions of some functions
AC_CHECK_FUNCS([snprintf])


dnl 
dnl Look for various optional libraries.
dnl
dnl TODO: These should be replaced by ltdl.
HAVE_LD=no
LIBLD_LDFLAGS=
AC_CHECK_LIB(dl,main,[LIBLD_LDFLAGS=-ldl])
if test -n "${LIBLD_LDFLAGS}"; then
   HAVE_LD=yes
fi
AC_SUBST(LIBLD_LDFLAGS)

dnl - not longer needed AC_CHECK_LIB([gd],[gdImageCreateFromPng])

dnl some optional packages - default is to check automatically
dnl but the check can be disabled using --without-PACKAGE
dnl legal PACKAGE names are:
dnl emf, magick, libplot 

# When doc regeneration is enabled, these are needed:
AC_CHECK_PROGS([PDFLATEX],[pdflatex],[false])
# Note that this controls *generation* of documentation.  It is
# installed in any case, and included in the "make dist" distribution
# tarball.  As a consequence, at "make dist" time these files must
# exist, usually because they have just been generated by "make".  To
# generate them without compiling the pstoedit executable, you can use
# an existing executable, e.g., "make dist P=/usr/bin/pstoedit"
AC_MSG_CHECKING([enable_docs])
# Check the option
AC_ARG_ENABLE([docs],
       [AS_HELP_STRING([--enable-docs],[rebuild LaTeX-format documentation (default=yes iff pdflatex is found)])],,
       [enable_docs=yes])
# Disable the option if the necessary executables seem unavailable:
AS_IF([test "x${PDFLATEX}" = xfalse],[enable_docs=no])
AC_MSG_RESULT([$enable_docs])
# Tell automake whether to try to regenerate docs
AM_CONDITIONAL([DOCS], [test x${enable_docs} = xyes])

# These are used in doc/Makefile.am, but not by default.
AC_CHECK_PROGS([LATEX],[latex],[false])
AC_CHECK_PROGS([DVIPS],[dvips],[false])
AC_CHECK_PROGS([GROFF],[groff],[false])
AC_CHECK_PROGS([RMAN],[rman],[false])


AC_ARG_WITH([emf],
[AS_HELP_STRING([--with-emf],[enable/disable emf interface (default: enabled - use --without-emf to disable)])],
[with_emf=$withval],[with_emf=yes])
AC_ARG_WITH([magick],
[AS_HELP_STRING([--with-magick],[enable/disable magick++ interface (default: enabled - use --without-magick to disable)])],
[with_magick=$withval],[with_magick=yes])
AC_ARG_WITH([gui],
[AS_HELP_STRING([--with-gui],[enable/disable the QT GUI (default: enabled - use --without-gui to disable)])],
[with_gui=$withval],[with_gui=yes])
AC_ARG_WITH([libplot],
[AS_HELP_STRING([--with-libplot],[enable/disable libplot interface (default: enabled - use --without-libplot to disable)])],
[with_libplot=$withval],[with_libplot=yes])
AC_ARG_WITH([pptx],
[AS_HELP_STRING([--with-pptx],[enable/disable pptx interface (default: enabled - use --without-pptX to disable)])],
[with_pptx=$withval],[with_pptx=yes])


OLD_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="$CPPFLAGS -DX_DISPLAY_MISSING"

if test -f src/drvwwmf.cpp ; then
	HAVE_PLUGINSRC=true;
	AM_CONDITIONAL(HAVE_PLUGINSRC, true)
else
	HAVE_PLUGINSRC=false;
	AM_CONDITIONAL(HAVE_PLUGINSRC, false)
fi



if test "${with_libplot}" = "yes" ; then
dnl
dnl Driver::libplotter
dnl
HAVE_LIBPLOTTER=no
LIBPLOTTER_LDFLAGS=
LIBPLOTTER_CFLAGS=
dnl AC_CHECK_LIB(plotter,main,
dnl	[LIBPLOTTER_LDFLAGS=-lplotter],,-lstdc++)
AC_CHECK_LIB(plotter,main,
	[LIBPLOTTER_LDFLAGS=-lplotter])
AC_CHECK_HEADER(plotter.h,
        [LIBPLOTTER_CFLAGS="-DHAVE_LIBPLOTTER"])

if test -n "${LIBPLOTTER_LDFLAGS}" && test -n "${LIBPLOTTER_CFLAGS}"; then
   HAVE_LIBPLOTTER=yes
   AC_MSG_CHECKING(for version of "lib plot" )   
   dnl See if we have a 2.3 or newer lib Plot version
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
		#include <plotter.h>
	     	typedef int Point; 
		]], [[ ]])],[AC_MSG_RESULT(you seem to have a compatible version )],[LIBPLOTTER_CFLAGS="$LIBPLOTTER_CFLAGS -DOLD_LIBPLOTTER";   
		    AC_MSG_RESULT(you seem to have an older version - need at least version 2.3)])
   AC_MSG_RESULT([** libplotter driver is enabled.])
else
   LIBPLOTTER_LDFLAGS=
   LIBPLOTTER_CFLAGS=
   AC_MSG_WARN([** libplotter driver is disabled.])
fi
AC_SUBST(LIBPLOTTER_LDFLAGS)
AC_SUBST(LIBPLOTTER_CFLAGS)
AM_CONDITIONAL(HAVE_LIBPLOTTER, test "$HAVE_LIBPLOTTER" = yes)
else
   AC_MSG_WARN([libplot support disabled by configure argument .])
   AM_CONDITIONAL(HAVE_LIBPLOTTER, false )
fi

CPPFLAGS=${OLD_CPPFLAGS}

if test "${with_gui}" = "yes" ; then
dnl
dnl QT GUI
dnl
HAVE_QT=no
AC_CHECK_PROG([QMAKE6FOUND],[qmake6],[true],[false])

if test "${QMAKE6FOUND}"; then
   QHEADERS=`qmake6 -query QT_INSTALL_HEADERS`
   echo "QHEADERS=$QHEADERS"
   QHEADERDIR=`echo "$QHEADERS" | sed s/-I//g`
   if test -f "$QHEADERDIR/QtWidgets/QMainWindow" ; then
     HAVE_QT=yes;
     AC_MSG_RESULT(you seem to have QT headers)
     AC_MSG_RESULT([** separate GUI enabled.])
   else
     AC_MSG_RESULT(you do no have QT headers. Cannot build the GUI.)
   fi

dnl   CPPFLAGS="$CPPFLAGS -I$QHEADERS"
dnl   echo "WWWWW CPPFLAGS=$CPPFLAGS"
dnl   AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
dnl		#include <QtWidgets/QMainWindow>
dnl		]], [[ ]])],
dnl	[HAVE_QT=yes;AC_MSG_RESULT(you seem to have QT headers)],
dnl      [HAVE_QT=no;AC_MSG_RESULT(you do no have QT headers)])
dnl   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
dnl		#include <QtWidgets/QMainWindow>
dnl		]], [[ ]])],
dnl		[HAVE_QT=yes;AC_MSG_RESULT(you seem to have QT headers );AC_MSG_RESULT([** QT GUI is enabled.])],
dnl		[AC_MSG_RESULT(QT headers not found)])
dnl    CPPFLAGS=${OLD_CPPFLAGS}
else
   AC_MSG_WARN([** QT GUI is disabled.])
fi
   AM_CONDITIONAL(HAVE_QT, test "$HAVE_QT" = yes)
else
   AC_MSG_WARN([QT GUI disabled by configure argument .])
   AM_CONDITIONAL(HAVE_QT, false )
fi





AC_MSG_CHECKING(for mkstemp)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
		 char buffer[] = "aaaXXXXXX";
	 	 int i = mkstemp(buffer); ]], [[ ]])],[HAVE_MKSTEMP=yes;
                MKSTEMP_CFLAGS="-DHAVE_MKSTEMP"; 
                AC_MSG_RESULT(you seem to have mkstemp )],[AC_MSG_RESULT(you do not have mkstemp - so will try using tempnam instead)])

AC_SUBST(MKSTEMP_CFLAGS)


if test "${with_pptx}" = "yes" ; then
dnl
dnl Driver::libpptx
dnl
HAVE_LIBZIP=no
LIBZIP_LDFLAGS=
LIBZIP_CFLAGS=

dnl If zip.h is found, use it.
AC_ARG_WITH([libzip-lib],
[AS_HELP_STRING([--with-libzip-lib=DIR],[look for libzip library in dir (e.g. /usr/local/lib)])],
[libzip_lib_dir=$withval],[libzip_lib_dir=])

AC_ARG_WITH([libzip-include],
[AS_HELP_STRING([--with-libzip-include=DIR],[look for libzip header in dir (e.g. /usr/local/include/libzip)])],
[libzip_include_dir=$withval],[libzip_include_dir=])

OLD_LIBS=${LIBS}
if test -n "${libzip_lib_dir}"; then
   LIBS="-L${libzip_lib_dir} ${LIBS}"
fi
AC_CHECK_LIB(zip,zip_add,
	[LIBZIP_LDFLAGS="-lzip -lz"],,-lz)
LIBS=${OLD_LIBS}

OLD_CPPFLAGS=${CPPFLAGS}
if test -n "${libzip_include_dir}"; then
   CPPFLAGS="-I${libzip_include_dir} ${CPPFLAGS}"
fi
AC_CHECK_HEADER(zip.h,
	[LIBZIP_CFLAGS="-DHAVE_LIBZIP"])
CPPFLAGS=${OLD_CPPFLAGS}

if test -n "${LIBZIP_LDFLAGS}" && test -n "${LIBZIP_CFLAGS}"; then
   HAVE_LIBZIP=yes
   if test -n "${libzip_include_dir}"; then
     LIBZIP_CFLAGS="-I${libzip_include_dir} ${LIBZIP_CFLAGS}"
   fi
   if test -n "${libzip_lib_dir}"; then
     LIBZIP_LDFLAGS="-L${libzip_lib_dir} ${LIBZIP_LDFLAGS}"
   fi   
   AC_MSG_RESULT([** libpptx driver is enabled.])
else
   LIBZIP_LDFLAGS=
   LIBZIP_CFLAGS=
   AC_MSG_WARN([** libpptx driver is disabled.])
fi
AC_SUBST(LIBZIP_LDFLAGS)
AC_SUBST(LIBZIP_CFLAGS)
AM_CONDITIONAL(HAVE_LIBZIP, test "$HAVE_LIBZIP" = yes)
else
   AC_MSG_WARN([pptx support disabled by configure argument .])
   AM_CONDITIONAL(HAVE_LIBZIP, false )
fi






if test "${with_magick}" = "yes" ; then
dnl
dnl Driver::libmagick++
dnl If Magick++.h is found, use it.
dnl
HAVE_LIBMAGICK=no
LIBMAGICK_CFLAGS=
LIBMAGICK_LDFLAGS=
PSTOEDIT_GCC_OK=yes
if test "x${CC}" = xgcc; then 
   AC_MSG_CHECKING(for gcc version)
   GCC_VERSION=`${CC} --version`
   changequote(,)dnl
   GCC_MAJOR_VERSION=`echo $GCC_VERSION \
   | sed -e "s/^\([0-9]*\)\.[0-9]*/\1/"`
   GCC_MINOR_VERSION=`echo $GCC_VERSION \
   | sed -e "s/^[0-9]*\.\([0-9]*\)/\1/"`
   changequote([,])dnl
   AC_MSG_RESULT([${GCC_MAJOR_VERSION}.${GCC_MINOR_VERSION}])
   if test "x${GCC_MAJOR_VERSION}" = x2; then
      PSTOEDIT_GCC_OK=no
   fi
fi

if test "x${PSTOEDIT_GCC_OK}" = xno ; then
      AC_MSG_WARN([** gcc version is too old to use Magick++ in pstoedit]) 
      AC_MSG_WARN([** gcc version >= 3 is required.]) 
      AC_MSG_WARN([** libMagick++ driver is disabled.])
else
      if test -n "$PKG_CONFIG"; then
        AC_MSG_CHECKING(ImageMagick flags through pkg-config)
	PKG_CHECK_MODULES(LIBMAGICK, ImageMagick++, 
		HAVE_LIBMAGICK=yes 
		LIBMAGICK_CFLAGS="-DHAVE_MAGIC $LIBMAGICK_CFLAGS" 
		LIBMAGICK_LDFLAGS="$LIBMAGICK_LIBS" , 
		echo "trying other methods for finding ImageMagick")
      else
	AC_PATH_PROG(MAGICK_CONFIG, Magick++-config)
	if test -n "${MAGICK_CONFIG}"; then
	   AC_MSG_CHECKING(for version of "GraphicsMagick++" )   
	   dnl See if we have a 1.0.6 or newer version
	   OLD_CPPFLAGS=${CPPFLAGS}
	   CPPFLAGS="$CPPFLAGS `Magick++-config --cppflags`"
	   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Magick++.h>
	            #if MagickLibVersion >= 0x000008
	 	    int correct;
	  	    #else
	  	    old version of GraphicsMagick;
	  	    #endif ]], [[ ]])],[MAGICKCORRECTVERSION="YES";AC_MSG_RESULT(you seem to have a compatible version )],[AC_MSG_RESULT(you seem to have an older version - need at least version 1.0.6)])
	   CPPFLAGS=$OLD_CPPFLAGS
	   if test -n "${MAGICKCORRECTVERSION}"; then
	      HAVE_LIBMAGICK=yes
	      LIBMAGICK_CFLAGS="-DHAVE_MAGIC `Magick++-config --cppflags`"
	      LIBMAGICK_LDFLAGS="`Magick++-config --libs` `Magick++-config --ldflags`"
	   else
	      AC_MSG_WARN([** libMagick++ driver is disabled because of too old version of GraphicsMagick (need at least 1.0.6).])
	   fi
	else
	      AC_MSG_WARN([** libMagick++ driver is disabled.])
	fi
      fi
fi
AC_SUBST(LIBMAGICK_CFLAGS)
AC_SUBST(LIBMAGICK_LDFLAGS)
AM_CONDITIONAL(HAVE_LIBMAGICK, test "$HAVE_LIBMAGICK" = yes)
else
   AC_MSG_WARN([magick support disabled by configure argument .])
   AM_CONDITIONAL(HAVE_LIBMAGICK, false )
fi





if test "${with_emf}" = "yes" ; then
dnl
dnl Driver::libEMF
dnl Check for EMF support library
dnl
HAVE_LIBEMF=no
LIBEMF_CFLAGS=
LIBEMF_LDFLAGS=

OLD_CPPFLAGS=
OLD_LIBS=


AC_ARG_WITH([libemf-src],
[AS_HELP_STRING([--with-libemf-src=DIR],[look for libEMF src in dir (e.g. /usr/local/lib)])],
[libemf_lib_src=$withval],[libemf_lib_src=])

if test -n "${libemf_lib_src}"; then
dnl use libemf source directly
HAVE_LIBEMF=yes
AM_CONDITIONAL(USE_EMFBYSOURCE, true )
AM_CONDITIONAL(HAVE_LIBEMF, true )
LIBEMF_CFLAGS="-DHAVE_LIBEMF -I${libemf_lib_src}/include -I${libemf_lib_src}/libemf -I${libemf_lib_src}/config "
AC_SUBST(LIBEMF_CFLAGS)

else
AM_CONDITIONAL(USE_EMFBYSOURCE, false )

AC_ARG_WITH([libemf-lib],
[AS_HELP_STRING([--with-libemf-lib=DIR],[look for libEMF library in dir (e.g. /usr/local/lib)])],
[libemf_lib_dir=$withval],[libemf_lib_dir=])

AC_ARG_WITH([libemf-include],
[AS_HELP_STRING([--with-libemf-include=DIR],[look for libEMF header in dir (e.g. /usr/local/include/libEMF)])],
[libemf_include_dir=$withval],[libemf_include_dir=])

OLD_LIBS=${LIBS}
if test -n "${libemf_lib_dir}"; then
   LIBS="-L${libemf_lib_dir} ${LIBS}"
fi
AC_CHECK_LIB(EMF,main, [LIBEMF_LDFLAGS="-lEMF -lm"],,-lm)
if test -n "${LIBEMF_LDFLAGS}"; then
  if test -n "${libemf_lib_dir}"; then
     LIBEMF_LDFLAGS="-L${libemf_lib_dir} ${LIBEMF_LDFLAGS}"
  fi   
else
      AC_MSG_WARN([** Cannot find libEMF. libEMF supports are disabled.])
fi
LIBS=${OLD_LIBS}

OLD_CPPFLAGS=${CPPFLAGS}
if test -n "${libemf_include_dir}"; then
   CPPFLAGS="-I${libemf_include_dir} ${CPPFLAGS}"
fi
AC_CHECK_HEADER(emf.h,
		[LIBEMF_CFLAGS="-DHAVE_LIBEMF -DOLDLIBEMF"])
AC_CHECK_HEADER(libemf/emf.h,
		[LIBEMF_CFLAGS="-DHAVE_LIBEMF"])
AC_CHECK_HEADER(libEMF/emf.h,
		[LIBEMF_CFLAGS="-DHAVE_LIBEMF"])
if test -n "${LIBEMF_CFLAGS}"; then
   if test -n "${libemf_include_dir}"; then
	 LIBEMF_CFLAGS="-I${libemf_include_dir} ${LIBEMF_CFLAGS}"
   fi
   AC_MSG_RESULT([** libEMF driver is enabled.])
else
   AC_MSG_WARN([** Cannot find emf.h. libEMF supports are disabled.])
fi
CPPFLAGS=${OLD_CPPFLAGS}

if test -n "${LIBEMF_LDFLAGS}" && test -n "${LIBEMF_CFLAGS}"; then
   HAVE_LIBEMF=yes
else
   LIBEMF_CFLAGS=
   LIBEMF_LDFLAGS=
fi

AC_SUBST(LIBEMF_LDFLAGS)
AC_SUBST(LIBEMF_CFLAGS)
AM_CONDITIONAL(HAVE_LIBEMF, test "$HAVE_LIBEMF" = yes)
fi
else
   AC_MSG_WARN([EMF support disabled by configure argument .])
   AM_CONDITIONAL(USE_EMFBYSOURCE, false )
   AM_CONDITIONAL(HAVE_LIBEMF, false )
fi





dnl
dnl PNG and Zlib
dnl
dnl OBS: HAVE_LIBPNG=no
dnl OBS: LIBPNG_CFLAGS=
dnl OBS: LIBPNG_LDFLAGS=
dnl OBS: AC_MSG_CHECKING(See if we have libpng and zlib)
dnl OBS: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <png.h>
dnl OBS: 	 	 int i = PNG_TRANSFORM_IDENTITY; ]], [[ ]])],[dnl OBS:                HAVE_LIBPNG=yes;
dnl OBS:                 LIBPNG_CFLAGS="-DHAVE_LIBPNG"; 
dnl OBS:                 LIBPNG_LDFLAGS="-lpng -lz ";
dnl OBS:                 AC_MSG_RESULT(you seem to have compatible version of libpng)],[dnl OBS:                AC_MSG_RESULT(you either have no libpng or an old version - 1.0.8 should be ok.)])
dnl OBS: AC_SUBST(LIBPNG_LDFLAGS)
dnl OBS: AC_SUBST(LIBPNG_CFLAGS)
dnl OBS: AM_CONDITIONAL(HAVE_LIBPNG, test "$HAVE_LIBPNG" = yes)

dnl
dnl C++ compiler related checking
dnl

dnl See if we need to define a "bool" type.
AC_MSG_CHECKING(for built-in "bool" datatype)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[bool testing_bool; testing_bool=true;]])],[CXXFLAGS="$CXXFLAGS -DINTERNALBOOL"; AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])

dnl Add extra, platform-specific, C++ compiler options.
AC_MSG_CHECKING(C++ compiler model)
if test "$GXX" = yes; then
  if test "$host_os" = riscos; then
    AC_MSG_RESULT([GNU on RiscOS])
    SPECIAL_CXXFLAGS="-Wall -Dunix -Ilibgpp: -Ilibstdc: -Ilibio:"
    LDLIBS="-rescan libgpp:o.libg++ libstdc:o.libstdc++ libio:o.libiostrea gcc:o.libgcc Unix:o.UnixLib"
    LINK=link
    AC_SUBST(LINK)
    AC_SUBST(LDLIBS)
  else
    AC_MSG_RESULT([GNU])
#   need to disable long long warning here because of ImageMagick using it
    SPECIAL_CXXFLAGS="-Wall -Wextra -Wuninitialized -Wswitch-default -Wunused -Wshadow -Wwrite-strings -Wcast-qual -Wpointer-arith -Wno-long-long"
  fi
elif test `echo "$CXX" | egrep -c 'xlC$'` -eq 1; then
  AC_MSG_RESULT([AIX xlC])
  SPECIAL_CXXFLAGS="-D__unix__ -g -+ -I/usr/lpp/xlC/src/nihC/aixinclude"
elif test `echo "$CXX" | egrep -c 'cxx$'` -eq 1; then
  AC_MSG_RESULT([OSF/1 cxx])
  SPECIAL_CXXFLAGS="-w -define_templates"
elif test `echo "$CXX" | egrep -c 'CC$'` -eq 1; then
  if test "$host_os" = irix5.3; then
    AC_MSG_RESULT([Irix 5.3])
    SPECIAL_CXXFLAGS="-O2 -mips2 -Olimit 2400"
  elif test "$host_os" = irix6.2; then
    AC_MSG_RESULT([Irix 6.2])
    SPECIAL_CXXFLAGS="-mips3 -n32 -O2 -OPT:fold_arith_limit=2500"
  elif test "$host_vendor" = sun; then
    AC_MSG_RESULT([Sun])
    SPECIAL_CXXFLAGS="-w"
  fi
else
  AC_MSG_RESULT(unknown)
fi

AC_ARG_ENABLE([wrapper],
              [AS_HELP_STRING([--enable-wrapper=PROGRAM],
                          [Wrap (i.e. prefix) compiler invocations with PROGRAM (e.g. \"insure\" or \"purify\")])],
              [CXX="$enableval $CXX"])

AC_SUBST(SPECIAL_CXXFLAGS)

dnl
dnl Standard C++ library and C++ Runtime
dnl
CXX_RUNTIME_LIB=
CXX_STD_LIB=
if test x"$GXX" = xyes; then
   AC_CHECK_LIB(g++,main,CXX_RUNTIME_LIB=-lg++)
   AC_CHECK_LIB(stdc++,main,CXX_STD_LIB=-lstdc++,,${CXX_RUNTIME_LIB})
fi
AC_SUBST(CXX_STD_LIB)
AC_SUBST(CXX_RUNTIME_LIB)

dnl Write the resulting Makefile.
AC_CONFIG_FILES([Makefile 
src/Makefile 
config/Makefile config/pstoedit.pc
doc/Makefile
doc/version.tex
examples/Makefile 
contrib/Makefile contrib/cairo/Makefile
contrib/java/Makefile contrib/java/java1/Makefile contrib/java/java2/Makefile 
misc/Makefile 
QT/Makefile  QT/PstoeditQtGui/Makefile
othersrc/Makefile othersrc/gsdllinc/Makefile])

AC_OUTPUT
 
