dnl
dnl New-style (automake, libtool, autoconf) configuration script
dnl for XmHTML.
dnl
dnl Based on configure.in provided by Danny Backx
dnl

AC_INIT()

AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE(XmHTML,1107)

AC_PREREQ(2.12)
AM_CONFIG_HEADER(include/config.h)
AM_PROG_LIBTOOL

dnl
dnl Add macros
dnl AC_PATH_XPM_DIRECT
dnl	AC_PATH_MOTIF_DIRECT
dnl AC_PATH_JPEG_DIRECT
dnl AC_PATH_PNG_DIRECT
dnl AC_PATH_ZLIB_DIRECT
dnl AC_PATH_XPM
dnl	AC_PATH_MOTIF
dnl	AC_PATH_JPEG
dnl	AC_PATH_PNG
dnl	AC_PATH_ZLIB
dnl	AC_XT_VERSION6
dnl	AC_XT_VERSION5
dnl	AM_MAINTAINER_MODE
dnl
dnl This configure.in contains checks version numbers of libXpm, libjpeg,
dnl libpng and libz.
dnl It will abort when libXpm can not be found or when libXpm is older than
dnl version 3.4.f
dnl The checks are in the AC_PATH_XPM, AC_PATH_JPEG, AC_PATH_PNG and
dnl AC_PATH_ZLIB macros.
dnl
dnl

dnl
dnl Check if we can find libXpm. This is a *mandatory* library
dnl
AC_DEFUN(AC_PATH_XPM_DIRECT,
[test -z "$xpm_direct_test_library" && xpm_direct_test_library=Xpm
test -z "$xpm_direct_test_function" && xpm_direct_test_function=XpmCreateXpmImageFromBuffer
test -z "$xpm_direct_test_include" && xpm_direct_test_include=X11/xpm.h
  for ac_dir in               \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
    /usr/openwin/include      \
    /opt/openwin/include      \
                              \
    /usr/include              \
    /usr/local/include        \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    ; \
  do
    if test -r "$ac_dir/$xpm_direct_test_include"; then
      no_xpm= ac_xpm_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$xpm_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_xpm_includes" | sed s/include/lib/` \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
                          \
    /usr/lib/X11R6        \
    /usr/lib/X11R5        \
                          \
    /usr/local/X11R6/lib  \
    /usr/local/X11R5/lib  \
                          \
    /usr/local/lib/X11R6  \
    /usr/local/lib/X11R5  \
                          \
    /usr/X11/lib          \
    /usr/lib/X11          \
    /usr/local/X11/lib    \
                          \
    /usr/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/dt/lib           \
    /usr/openwin/lib      \
    /opt/openwin/lib      \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${xpm_direct_test_library}.$ac_extension; then
      no_xpm= ac_xpm_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS=$ac_save_LIBS])

AC_DEFUN(AC_PATH_XPM,
[AC_REQUIRE_CPP()dnl

xpm_includes=NONE
xpm_libraries=NONE

AC_MSG_CHECKING(for libXpm)
AC_ARG_WITH(xpm, [  --with-xpm              enable Xpm tests])
if test "x$with_xpm" = xno; then
  no_xpm=yes
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Xpm support required by XmHTML)
else
  if test "x$xpm_includes" != xNONE && test "x$xpm_libraries" != xNONE; then
    no_xpm=
  else
AC_CACHE_VAL(ac_cv_path_xpm,
[# One or both of these vars are not set, and there is no cached value.
no_xpm=yes
AC_PATH_XPM_DIRECT

if test "$no_xpm" = yes; then
  ac_cv_path_xpm="no_xpm=yes"
  AC_MSG_ERROR(Xpm support required by XmHTML)
else
  ac_cv_path_xpm="no_xpm= ac_xpm_includes=$ac_xpm_includes ac_xpm_libraries=$ac_xpm_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_xpm"
fi # with_xpm != no

if test "$no_xpm" = yes; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(Xpm support required by XmHTML)
else
dnl
dnl Before continuing, check if we have at least libXpm Version 3.4.f
dnl XmHTML uses some features that are not present in the versions prior
dnl to libXpm 3.4.f
dnl libXpm is a *mandatory* library!
dnl
  AC_MSG_RESULT(found)

  AC_MSG_CHECKING([for Xpm Revision 3.4.f or newer])
  ac_save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="-I$ac_xpm_includes $CPPFLAGS"
    AC_TRY_LINK([#include <X11/xpm.h>],
      [#if XpmIncludeVersion < 30406
      fail;
      #endif
    ],
    [AC_MSG_RESULT(OK)
     AC_MSG_CHECKING(for libXpm)
     test "x$xpm_includes" = xNONE && xpm_includes=$ac_xpm_includes
     test "x$xpm_libraries" = xNONE && xpm_libraries=$ac_xpm_libraries
     ac_cv_path_xpm="no_xpm= ac_xpm_includes=$xpm_includes ac_xpm_libraries=$xpm_libraries"
     AC_MSG_RESULT([libraries $xpm_libraries, headers $xpm_includes])],
    [AC_MSG_ERROR(XmHTML requires libXpm 3.4.f or newer)])
  CPPFLAGS=$ac_save_CPPFLAGS
fi
])

dnl
dnl Check if Motif is here somewhere
dnl

AC_DEFUN(AC_PATH_MOTIF_DIRECT,
[test -z "$motif_direct_test_library" && motif_direct_test_library=Xm
test -z "$motif_direct_test_function" && motif_direct_test_function=XmCreatePushButton
test -z "$motif_direct_test_include" && motif_direct_test_include=Xm/Xm.h
  for ac_dir in               \
    /usr/include/Motif1.2     \
    /usr/Motif1.2/include     \
                              \
    /usr/lesstif20/include    \
    /usr/lesstif/include      \
                              \
    /usr/lesstif*/include     \
                              \
    /usr/motif/include        \
                              \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
                              \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
                              \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
                              \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
                              \
    /usr/X11/include          \
    /usr/include/X11          \
    /usr/local/X11/include    \
    /usr/local/include/X11    \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/dt/include           \
    /usr/openwin/include      \
    /opt/openwin/include      \
                              \
    /usr/include              \
    /usr/local/include        \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
    ; \
  do
    if test -r "$ac_dir/$motif_direct_test_include"; then
      no_motif= ac_motif_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$motif_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_motif_includes" | sed s/include/lib/` \
    /usr/lib/Motif1.2     \
    /usr/Motif1.2/lib     \
                          \
    /usr/motif/lib        \
                          \
    /usr/X11R6/lib        \
    /usr/X11R5/lib        \
                          \
    /usr/lib/X11R6        \
    /usr/lib/X11R5        \
                          \
    /usr/local/X11R6/lib  \
    /usr/local/X11R5/lib  \
                          \
    /usr/local/lib/X11R6  \
    /usr/local/lib/X11R5  \
                          \
    /usr/X11/lib          \
    /usr/lib/X11          \
    /usr/local/X11/lib    \
                          \
    /usr/X386/lib         \
    /usr/x386/lib         \
    /usr/XFree86/lib/X11  \
                          \
    /usr/dt/lib           \
    /usr/openwin/lib      \
    /opt/openwin/lib      \
                          \
    /usr/lib              \
    /usr/local/lib        \
    /usr/unsupported/lib  \
    /usr/athena/lib       \
    /usr/local/x11r5/lib  \
    /usr/lpp/Xamples/lib  \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${motif_direct_test_library}.$ac_extension; then
      no_motif= ac_motif_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS=$ac_save_LIBS])

AC_DEFUN(AC_PATH_MOTIF,
[AC_REQUIRE_CPP()dnl

motif_includes=NONE
motif_libraries=NONE

AC_MSG_CHECKING(for Motif)
AC_ARG_WITH(motif, [  --with-motif            enable Motif tests])
if test "x$with_motif" = xno; then
  no_motif=yes
else
  if test "x$motif_includes" != xNONE && test "x$motif_libraries" != xNONE; then
    no_motif=
  else
AC_CACHE_VAL(ac_cv_path_motif,
[# One or both of these vars are not set, and there is no cached value.
no_motif=yes
AC_PATH_MOTIF_DIRECT

if test "$no_motif" = yes; then
  ac_cv_path_motif="no_motif=yes"
else
  ac_cv_path_motif="no_motif= ac_motif_includes=$ac_motif_includes ac_motif_libraries=$ac_motif_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_motif"
fi # with_motif != no

if test "$no_motif" = yes; then
  AC_MSG_RESULT(no)
else
  test "x$motif_includes" = xNONE && motif_includes=$ac_motif_includes
  test "x$motif_libraries" = xNONE && motif_libraries=$ac_motif_libraries
  ac_cv_path_motif="no_motif= ac_motif_includes=$motif_includes ac_motif_libraries=$motif_libraries"
  AC_MSG_RESULT([libraries $motif_libraries, headers $motif_includes])
fi
])

AC_DEFUN(AC_XT_VERSION6,
[AC_MSG_CHECKING([for Xt Revision Number 6])
  AC_TRY_LINK([#include <X11/Intrinsic.h>],
[#if XtSpecificationRelease < 6
fail;
#endif
], XTversion="6",
   [AC_MSG_RESULT(no)])])

AC_DEFUN(AC_XT_VERSION5,
[AC_MSG_CHECKING([for Xt Revision Number 5])
  AC_TRY_LINK([#include <X11/Intrinsic.h>],
[#if XtSpecificationRelease < 5
fail;
#endif
], XTversion="5",
   [AC_MSG_RESULT(no)])])

dnl
dnl Figure out if JPEG is here somewhere
dnl
AC_DEFUN(AC_PATH_JPEG_DIRECT,
[test -z "$jpeg_direct_test_library" && jpeg_direct_test_library=jpeg
test -z "$jpeg_direct_test_function" && jpeg_direct_test_function=jpeg_read_header
test -z "$jpeg_direct_test_include" && jpeg_direct_test_include=jpeglib.h
  for ac_dir in               \
    /usr/include              \
    /usr/include/jpeg         \
    /usr/local/include        \
    /usr/jpeg/include         \
    /usr/unsupported/include  \
    /usr/share/include        \
    /usr/lpp/include          \
    /usr/lpp/jpeg/include     \
    ; \
  do
    if test -r "$ac_dir/$jpeg_direct_test_include"; then
      no_jpeg= ac_jpeg_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$jpeg_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_jpeg_includes" | sed s/include/lib/` \
    /usr/lib              \
    /usr/jpeg/lib         \
    /usr/local/lib        \
    /usr/local/jpeg/lib   \
    /usr/unsupported/lib  \
    /usr/share/lib        \
    /usr/lpp/lib          \
    /usr/lpp/jpeg/lib     \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${jpeg_direct_test_library}.$ac_extension; then
      no_jpeg= ac_jpeg_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS=$ac_save_LIBS])

AC_DEFUN(AC_PATH_JPEG,
[AC_REQUIRE_CPP()dnl

jpeg_includes=NONE
jpeg_libraries=NONE

AC_MSG_CHECKING(for libjpeg)
AC_ARG_WITH(jpeg, [  --with-jpeg             enable libjpeg tests])
if test "x$with_jpeg" = xno; then
  no_jpeg=yes
else
  if test "x$jpeg_includes" != xNONE && test "x$jpeg_libraries" != xNONE; then
    no_jpeg=
  else
AC_CACHE_VAL(ac_cv_path_jpeg,
[# One or both of these vars are not set, and there is no cached value.
no_jpeg=yes
AC_PATH_JPEG_DIRECT

if test "$no_jpeg" = yes; then
  ac_cv_path_jpeg="no_jpeg=yes"
else
  ac_cv_path_jpeg="no_jpeg= ac_jpeg_includes=$ac_jpeg_includes ac_jpeg_libraries=$ac_jpeg_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_jpeg"
fi # with_jpeg != no

if test "$no_jpeg" = yes; then
  AC_MSG_RESULT(no)
else
dnl
dnl Check that we have at least libjpeg version 6a or newer before
dnl deciding we can enable libjpeg support.
dnl
  AC_MSG_RESULT(found)

  AC_MSG_CHECKING([for libjpeg Revision 6a or newer])
  ac_save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="-I$ac_jpeg_includes $CPPFLAGS"
    AC_TRY_LINK([#include <stdio.h>
    #include <sys/types.h>
    #include <jpeglib.h>],
  [#if JPEG_LIB_VERSION < 61
  fail;
  #endif
  ],
    [AC_MSG_RESULT(OK)
     AC_MSG_CHECKING(for libjpeg)
     test "x$jpeg_includes" = xNONE && jpeg_includes=$ac_jpeg_includes
     test "x$jpeg_libraries" = xNONE && jpeg_libraries=$ac_jpeg_libraries
     ac_cv_path_jpeg="no_jpeg= ac_jpeg_includes=$jpeg_includes ac_jpeg_libraries=$jpeg_libraries"
     AC_MSG_RESULT([libraries $jpeg_libraries, headers $jpeg_includes])
     AC_DEFINE(HAVE_LIBJPEG)],
    [AC_MSG_RESULT(older)
     AC_MSG_WARN(XmHTML JPEG support requires libjpeg 6a or newer)
     AC_MSG_WARN(JPEG support disabled)
     no_jpeg=yes
     jpeg_libraries=
     jpeg_includes=
    ])
  CPPFLAGS=$ac_save_CPPFLAGS
fi
])

dnl
dnl Figure out if PNG is here somewhere
dnl
AC_DEFUN(AC_PATH_PNG_DIRECT,
[test -z "$png_direct_test_library" && png_direct_test_library=png
test -z "$png_direct_test_function" && png_direct_test_function=png_check_sig
test -z "$png_direct_test_include" && png_direct_test_include=png.h
  for ac_dir in               \
    /usr/include              \
    /usr/include/png          \
    /usr/local/include        \
    /usr/png/include          \
    /usr/unsupported/include  \
    /usr/share/include        \
    /usr/lpp/include          \
    /usr/lpp/png/include      \
    ; \
  do
    if test -r "$ac_dir/$png_direct_test_include"; then
      no_png= ac_png_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$png_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_png_includes" | sed s/include/lib/` \
    /usr/lib              \
    /usr/png/lib          \
    /usr/local/lib        \
    /usr/local/png/lib    \
    /usr/unsupported/lib  \
    /usr/share/lib        \
    /usr/lpp/lib          \
    /usr/lpp/png/lib      \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${png_direct_test_library}.$ac_extension; then
      no_png= ac_png_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS=$ac_save_LIBS])

AC_DEFUN(AC_PATH_PNG,
[AC_REQUIRE_CPP()dnl

png_includes=NONE
png_libraries=NONE

AC_MSG_CHECKING(for libpng)
AC_ARG_WITH(png, [  --with-png              enable libpng tests])
if test "x$with_png" = xno; then
  no_png=yes
else
  if test "x$png_includes" != xNONE && test "x$png_libraries" != xNONE; then
    no_png=
  else
AC_CACHE_VAL(ac_cv_path_png,
[# One or both of these vars are not set, and there is no cached value.
no_png=yes
AC_PATH_PNG_DIRECT

if test "$no_png" = yes; then
  ac_cv_path_png="no_png=yes"
else
  ac_cv_path_png="no_png= ac_png_includes=$ac_png_includes ac_png_libraries=$ac_png_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_png"
fi # with_png != no

if test "$no_png" = yes; then
  AC_MSG_RESULT(no)
else
dnl
dnl Check that we have at least libpng version 0.96 or newer before
dnl deciding we can enable libpng support.
dnl
  AC_MSG_RESULT(found)

  AC_MSG_CHECKING([for libpng Revision 0.96 or newer])
  ac_save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="-I$ac_png_includes $CPPFLAGS"
    AC_TRY_LINK([#include <png.h>],
  [#if PNG_LIBPNG_VER < 96
  fail;
  #endif
  ],
    [AC_MSG_RESULT(OK)
     AC_MSG_CHECKING(for libpng)
     test "x$png_includes" = xNONE && png_includes=$ac_png_includes
     test "x$png_libraries" = xNONE && png_libraries=$ac_png_libraries
     ac_cv_path_png="no_png= ac_png_includes=$png_includes ac_png_libraries=$png_libraries"
     AC_MSG_RESULT([libraries $png_libraries, headers $png_includes])],
dnl HAVE_LIBPNG is set when the libz test succeeds
    [AC_MSG_RESULT(older)
     AC_MSG_WARN(XmHTML PNG support requires libpng 0.96 or newer)
     AC_MSG_WARN(PNG support disabled)
     no_png=yes
     png_libraries=
     png_includes=
    ])
  CPPFLAGS=$ac_save_CPPFLAGS
fi
])

dnl
dnl Figure out if zlib is here somewhere (should be here if libpng is found)
dnl
AC_DEFUN(AC_PATH_ZLIB_DIRECT,
[test -z "$zlib_direct_test_library" && zlib_direct_test_library=z
test -z "$zlib_direct_test_function" && zlib_direct_test_function=compress
test -z "$zlib_direct_test_include" && zlib_direct_test_include=zlib.h
  for ac_dir in               \
    /usr/include              \
    /usr/include/zlib         \
    /usr/local/include        \
    /usr/zlib/include         \
    /usr/unsupported/include  \
    /usr/share/include        \
    /usr/lpp/include          \
    /usr/lpp/zlib/include     \
    ; \
  do
    if test -r "$ac_dir/$zlib_direct_test_include"; then
      no_zlib= ac_zlib_includes=$ac_dir
      break
    fi
  done

# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS="$LIBS"
LIBS="-l$zlib_direct_test_library $LIBS"
# First see if replacing the include by lib works.
for ac_dir in `echo "$ac_zlib_includes" | sed s/include/lib/` \
    /usr/lib              \
    /usr/zlib/lib         \
    /usr/local/lib        \
    /usr/local/zlib/lib   \
    /usr/unsupported/lib  \
    /usr/share/lib        \
    /usr/lpp/lib          \
    /usr/lpp/zlib/lib     \
    ; \
do
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${zlib_direct_test_library}.$ac_extension; then
      no_zlib= ac_zlib_libraries=$ac_dir
      break 2
    fi
  done
done
LIBS=$ac_save_LIBS])

AC_DEFUN(AC_PATH_ZLIB,
[AC_REQUIRE_CPP()dnl

zlib_includes=NONE
zlib_libraries=NONE

AC_MSG_CHECKING(for zlib)
AC_ARG_WITH(zlib, [  --with-zlib             enable zlib tests])
if test "x$with_zlib" = xno; then
  no_zlib=yes
else
  if test "x$zlib_includes" != xNONE && test "x$zlib_libraries" != xNONE; then
    no_zlib=
  else
AC_CACHE_VAL(ac_cv_path_zlib,
[# One or both of these vars are not set, and there is no cached value.
no_zlib=yes
AC_PATH_ZLIB_DIRECT

if test "$no_zlib" = yes; then
  ac_cv_path_zlib="no_zlib=yes"
else
  ac_cv_path_zlib="no_zlib= ac_zlib_includes=$ac_zlib_includes ac_zlib_libraries=$ac_zlib_libraries"
fi])dnl
  fi
  eval "$ac_cv_path_zlib"
fi # with_zlib != no

if test "$no_zlib" = yes; then
  AC_MSG_RESULT(no)
else
dnl
dnl Check that we have at least libz version 1.0.2 or newer before
dnl deciding we can enable libpng/gzf support.
dnl
  AC_MSG_RESULT(found)

  AC_MSG_CHECKING([for zlib Revision 1.0.2 or newer])
  ac_save_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="-I$ac_zlib_includes $CPPFLAGS"
  AC_TRY_LINK([#include <zlib.h>],
    [#ifndef zlib_version
     fail
     #endif
    ],
    [AC_MSG_RESULT(OK)
     AC_MSG_CHECKING(for zlib)
     test "x$zlib_includes" = xNONE && zlib_includes=$ac_zlib_includes
     test "x$zlib_libraries" = xNONE && zlib_libraries=$ac_zlib_libraries
     ac_cv_path_zlib="no_zlib= ac_zlib_includes=$zlib_includes ac_zlib_libraries=$zlib_libraries"
     AC_MSG_RESULT([libraries $zlib_libraries, headers $zlib_includes])
     AC_DEFINE(HAVE_LIBZ)
dnl export HAVE_LIBPNG if it was detected okay.
     if test x"$no_png" != xyes; then
       AC_DEFINE(HAVE_LIBPNG)
     fi],
    [AC_MSG_RESULT(older)
     AC_MSG_WARN(XmHTML PNG/GZF support requires zlib 1.0.2 or newer)
     AC_MSG_WARN(PNG/GZF support disabled)
     no_png=yes
     no_zlib=yes
     png_libraries=
     png_includes=
     zlib_libraries=
     zlib_includes=
    ])
  CPPFLAGS=$ac_save_CPPFLAGS
fi
])

AC_DEFUN(AM_MAINTAINER_MODE,
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
  dnl maintainer-mode is disabled by default
  AC_ARG_ENABLE(maintainer-mode,
[  --enable-maintainer-mode enable make rules and dependencies not useful
                          (and sometimes confusing) to the casual installer],
      USE_MAINTAINER_MODE=$enableval,
      USE_MAINTAINER_MODE=no)
  AC_MSG_RESULT($USE_MAINTAINER_MODE)
  if test $USE_MAINTAINER_MODE = yes; then
    MAINT=
  else
    MAINT='#M#'
  fi
  AC_SUBST(MAINT)dnl
]
)

dnl
dnl End of special macros.
dnl

AM_CYGWIN32
AM_EMX
AM_WITH_DMALLOC
AM_MAINTAINER_MODE

AC_MSG_CHECKING(compiler flags)
dnl
dnl Whether to compile with -g for debugging
dnl
AC_ARG_ENABLE(debug,
[  --enable-debug,         build with debugging options (-g)(default)])

if test "x$enable_debug" = "xno" ; then
	debug_flag="-O"
else
	if test "x$CC" = "xgcc" ; then
	    debug_flag="-g -Wall"
	else
	    debug_flag="-g"
	fi
fi

AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_AIX

dnl
dnl No checks for yacc or lex as we won't be using it.
dnl

AC_HEADER_STDC
AC_CHECK_HEADERS(memory.h unistd.h string.h strings.h getopt.h limits.h)
AC_CHECK_HEADERS(fcntl.h sys/time.h sys/systeminfo.h sys/stat.h)
AC_CHECK_HEADERS(sys/select.h pwd.h sys/types.h sys/wait.h regex.h)
AC_HEADER_DIRENT
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME

AC_TYPE_SIGNAL
AC_CHECK_FUNCS(uname putenv select strstr strcasecmp strncasecmp sysconf)
AC_CHECK_FUNCS(waitpid getitimer setitimer strdup memmove basename)
AC_CHECK_FUNCS(gethostname strcmpi strncmpi)
AM_CONDITIONAL(HaveGetHostName, test x$version = x1.2)

AC_FUNC_STRCOLL

AC_PATH_XPM
AC_PATH_X
AC_PATH_XTRA

AC_PATH_MOTIF
AC_PATH_JPEG
AC_PATH_PNG
AC_PATH_ZLIB

AM_CONDITIONAL(NLIBJPEG, test "x$no_jpeg" = xyes)
AM_CONDITIONAL(NLIBPNG, test "x$no_png" = xyes)
AM_CONDITIONAL(NLIBZ, test "x$no_zlib" = xyes)

AC_SUBST(libdir)
AC_SUBST(bindir)

AC_SUBST(version_suffix)
AC_SUBST(include_version_suffix)

AC_SUBST(shared_make)
AC_SUBST(x_lib_path)
AC_SUBST(x_libraries)
AC_SUBST(x_inc_path)
AC_SUBST(x_includes)
AC_SUBST(xpm_includes)
AC_SUBST(xpm_libraries)
AC_SUBST(motif_libraries)
AC_SUBST(motif_includes)
AC_SUBST(R6libs)
AC_SUBST(Editres)
AC_SUBST(extralibs)
AC_SUBST(jpeg_libraries)
AC_SUBST(jpeg_includes)
AC_SUBST(png_libraries)
AC_SUBST(png_includes)
AC_SUBST(zlib_libraries)
AC_SUBST(zlib_includes)

AC_SUBST(subdirs)

AC_SUBST(LIBTOOL_VERSION)
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(PICO_VERSION)

dnl
dnl Which output files do we generate ?
dnl

AC_OUTPUT(Makefile
book/Makefile
contrib/Makefile
examples/Makefile
http/Makefile
lib/Makefile
lib/common/Makefile
lib/compat/Makefile
lib/Motif/Makefile
lib/gtk/Makefile
tools/Makefile
)

dnl
dnl The End.
dnl
