dnl
dnl New-style (automake, libtool, autoconf) configuration script
dnl for LessTif's test/ tree
dnl
dnl $Header: /cvsroot/lesstif/lesstif/test/configure.in,v 1.178 2006/06/10 09:22:48 dannybackx Exp $
dnl

AC_INIT
AC_CONFIG_SRCDIR([common/Test.h])

AC_CANONICAL_HOST

dnl version numbers (are not required/used in test/ !?)
MAJOR_VERSION=0
MINOR_VERSION=95
PICO_VERSION=0

AC_CONFIG_AUX_DIR(..)
AM_INIT_AUTOMAKE(LessTif-Tests,$MAJOR_VERSION.$MINOR_VERSION)

dnl AM_AUTOMAKE_OPTIONS(1.5 foreign dejagnu)


LIBTOOL_VERSION=$MAJOR_VERSION:$MINOR_VERSION:0

dnl
dnl Override a default in libtool. (why that?)
dnl
AM_DISABLE_STATIC

dnl
dnl Replacement for acconfig.h
dnl
AH_TEMPLATE([HAVE_LIB_XP], [Define if libXp is available])
AH_TEMPLATE([HAVE_GL_GLWMDRAWA_H], [Define if the GL (Mesa) include files are available])

AC_PREREQ(2.59)
AM_CONFIG_HEADER(LTTconfig.h)
AC_PROG_CC
AC_AIX
AM_PROG_LIBTOOL

dnl
dnl OSF/Motif� 2.1 compatibility is the default version
dnl
version=2.1
version_suffix="-2.1"
include_version_suffix=-$version

AC_ARG_ENABLE(build-21,
[  --enable-build-21       build Motif-2.1 compatible version (default)],
test $enableval = "yes" && version="2.1")

version_suffix=-$version
include_version_suffix=-$version
xmVer=$version

AM_CONDITIONAL(Version_1_2, test x$version = x1.2)
AM_CONDITIONAL(Version_2_0, test x$version = x2.0)
AM_CONDITIONAL(Version_2_1, test x$version = x2.1)

AC_MSG_RESULT(Building OSF/Motif $version compatible version of LessTif Tests)

AM_PROG_CC_STDC
dnl No longer necessary - it's in AC_CANONICAL_HOST - AC_CYGWIN
AC_EXEEXT
AC_PROG_LN_S
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 LessTif tests with debugging options (-g)(default)],
, enable_debug=yes)

dnl Don't touch compiler flags, if debugging was not explicitly specified.
dnl Use environment variables, compiler defaults, etc.
if test "x$enable_debug" = "xyes" ; then
	if test "x$CC" = "xgcc" ; then
		if test "$lt_cs_test_CFLAGS" = "set" ; then
			if [ echo "$CFLAGS" | grep -v -e "\-g" > /dev/null ] ; then
				if test $ac_cv_prog_cc_g = yes ; then
					CFLAGS="$CFLAGS -g"
				fi
			fi
		else
			debug_flags=-Wall
			if echo $CFLAGS | grep -e "\-g" > /dev/null ; then
				CFLAGS=-g
			else
				CFLAGS=
			fi
		fi
	else
		if test "$lt_cs_test_CFLAGS" = "set" ; then
			if [ echo "$CFLAGS" | grep -v -e "\-g" > /dev/null ] ; then
	 			if test $ac_cv_prog_cc_g = yes ; then
					CFLAGS="$CFLAGS -g"
				fi
			fi
		else
			debug_flags=
			if test $ac_cv_prog_cc_g = yes ; then
				CFLAGS=-g
			else
				CFLAGS=
			fi
		fi
	fi
fi
AC_MSG_RESULT("$CFLAGS $debug_flags")


AC_CHECK_PROG(AR, ar, ar, ar)
AC_PROG_MAKE_SET
AC_PROG_INSTALL

dnl
dnl check for ANSI C89 compatibility and then do never check
dnl for such stuff again!
dnl
AC_HEADER_STDC
AC_C_CONST

# function checks
AC_CHECK_FUNCS(access  chdir   close   getcwd   getpwnam   getpwuid)
AC_CHECK_FUNCS(mkdir   open   popen   sbrk   symlink)

dnl Misc other stuff
AC_CHECK_HEADERS(fcntl.h pwd.h)
AC_CHECK_HEADERS(sys/param.h sys/stat.h sys/time.h sys/types.h)
AC_CHECK_HEADERS(unistd.h)
AC_HEADER_TIME

dnl Search for X11 headers/libs
AC_PATH_X
AC_PATH_XTRA

if test "x$x_includes" = "x"; then
  x_includes="/usr/include"
fi

dnl Set the CFLAGS variable to the location of the found X-header files
dnl This is necessary for the tests below to work !
dnl
lt_save_CFLAGS="$CFLAGS"
if test "x$x_includes" != x ; then
  CFLAGS="$CFLAGS -I$x_includes"
fi

XTversion=""
AC_XT_VERSION6

if test "x$XTversion" = x ; then
  AC_XT_VERSION5
  if test "x$XTversion" = x; then
    AC_MSG_ERROR(You must have X11 Revision 5 or higher to compile the Lesstif tests)
  else
    AC_MSG_RESULT(revision 5)
  fi
else
  AC_MSG_RESULT(revision 6)
fi

dnl Check for print extensions
LT_HAVE_LIBXP

dnl Third party stuff
AC_CHECK_HEADER(GL/GLwMDrawA.h,[AC_DEFINE(HAVE_GL_GLWMDRAWA_H)],[],[#include <X11/Intrinsic.h>])

dnl malloc debugging
LT_WITH_DMALLOC

AC_PATH_MOTIF
if test -n "$motif_includes"; then
  MOTIF_CFLAGS="-I$motif_includes"
fi
AC_SUBST(MOTIF_CFLAGS)
if test -n "$motif_libraries"; then
  MOTIF_LIBS="-L$motif_libraries"
fi
AC_SUBST(MOTIF_LIBS)

AM_CONDITIONAL(MotifTests, test x$no_motif != xyes)


AC_MSG_CHECKING(whether to link -lXp)
if test $lt_cv_libxp = yes;
then
  XPLIB="-lXp -lXext"
  AC_MSG_RESULT(yes)
else
  XPLIB=""
  AC_MSG_RESULT(no)
fi
AC_SUBST(XPLIB)

dnl Adjust some standard variables

CFLAGS="$CFLAGS $debug_flag"
GPROF_FLAGS="-pg"
GPROF_CFLAGS=""
EXTRACFLAGS=""
extralibs=""
run_libraries=""

case ${with_static} in
  yes) static_prefix=;;
  no) static_prefix="#";;
esac

dnl
dnl Now ensure that all required variables get substituted!
dnl

AC_SUBST(libdir)
AC_SUBST(bindir)

AC_SUBST(version_suffix)
AC_SUBST(include_version_suffix)
AC_SUBST(xmVer)

AC_SUBST(CFLAGS)
AC_SUBST(x_lib_path)
AC_SUBST(x_libraries)
AC_SUBST(x_inc_path)
AC_SUBST(x_includes)
AC_SUBST(motif_libraries)
AC_SUBST(motif_includes)
AC_SUBST(extralibs)

AC_SUBST(subdirs)

dnl for libtool
AC_SUBST(LIBTOOL_VERSION)
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(PICO_VERSION)
AC_SUBST(DLLTOOL)
AC_SUBST(OBJDUMP)
AC_SUBST(AS)
 
dnl
dnl Which output files do we generate ?
dnl

AC_CONFIG_FILES([Makefile \
common/Makefile \
config/Makefile \
Xm/Makefile \
Xm/arrowbg/Makefile \
Xm/arrowbutton/Makefile \
Xm/baseclass/Makefile \
Xm/bulletinboard/Makefile \
Xm/cascadebutton/Makefile \
Xm/cascadebuttong/Makefile \
Xm/command/Makefile \
Xm/cutpaste/Makefile \
Xm/dialogs/Makefile \
Xm/drag_drop/Makefile \
Xm/drag_help/Makefile \
Xm/drag_icon/Makefile \
Xm/drag_move/Makefile \
Xm/drag_pixmaps/Makefile \
Xm/drag_simple/Makefile \
Xm/drawingarea/Makefile \
Xm/drawnbutton/Makefile \
Xm/dynamic_drag/Makefile \
Xm/extobj/Makefile \
Xm/filesb/Makefile \
Xm/fonts/Makefile \
Xm/form/Makefile \
Xm/frame/Makefile \
Xm/geometry/Makefile \
Xm/imagecache/Makefile \
Xm/label/Makefile \
Xm/labelg/Makefile \
Xm/list/Makefile \
Xm/mainw/Makefile \
Xm/menushell/Makefile \
Xm/messagebox/Makefile \
Xm/misc/Makefile \
Xm/mwm/Makefile \
Xm/panedw/Makefile \
Xm/protocols/Makefile \
Xm/pushbg/Makefile \
Xm/pushbutton/Makefile \
Xm/region/Makefile \
Xm/reptype/Makefile \
Xm/resconvert/Makefile \
Xm/resind/Makefile \
Xm/rowcolumn/Makefile \
Xm/scale/Makefile \
Xm/screen/Makefile \
Xm/scrollbar/Makefile \
Xm/scrolledwindow/Makefile \
Xm/selectionbox/Makefile \
Xm/selections/Makefile \
Xm/separator/Makefile \
Xm/sepg/Makefile \
Xm/tearoff/Makefile \
Xm/text/Makefile \
Xm/textf/Makefile \
Xm/togglebg/Makefile \
Xm/togglebutton/Makefile \
Xm/tracking/Makefile \
Xm/traversal/Makefile \
Xm/vasimple/Makefile \
Xm/vendor/Makefile \
Xm/virtualkeys/Makefile \
Xm/xmos/Makefile \
Xm/xmstring/Makefile \
Xm-2.0/Makefile \
Xm-2.0/combobox/Makefile \
Xm-2.0/container/Makefile \
Xm-2.0/draw/Makefile \
Xm-2.0/grabshell/Makefile \
Xm-2.0/icong/Makefile \
Xm-2.0/messages/Makefile \
Xm-2.0/notebook/Makefile \
Xm-2.0/rendition/Makefile \
Xm-2.0/spinbox/Makefile \
Xm-2.0/translations/Makefile \
Xm-2.0/trait/Makefile \
Xm-2.0/xme/Makefile \
Xm-2.1/Makefile \
Xm-2.1/messages/Makefile \
Xm-2.1/print/Makefile \
Xm-2.1/translations/Makefile \
Mrm/Makefile \
Mrm/ch22/Makefile \
Mrm/mrm/Makefile \
Mrm/xmp/Makefile \
Uil/Makefile \
Uil/misc/Makefile \
extra/Makefile \
extra/cmap/Makefile \
extra/gl/Makefile \
extra/daniel/Makefile \
extra/megabutton/Makefile \
extra/newtoggleb/Makefile \
extra/smartmb/Makefile \
extra/spinbutton/Makefile \
extra/togglebplus/Makefile \
extra/Xlab/Makefile \
testall])
AC_OUTPUT

dnl
dnl The End.
dnl
