dnl
dnl New-style (automake, libtool, autoconf) configuration script
dnl for LessTif.
dnl
dnl $Id: configure.in,v 1.99 1998/03/14 14:59:32 rwscott Exp $
dnl

AC_INIT()

AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE(LessTif,0.83)

MAJOR_VERSION=0
MINOR_VERSION=83
PICO_VERSION=""

LIBTOOL_VERSION=$MAJOR_VERSION:$MINOR_VERSION:0

dnl
dnl Override a default in libtool.
dnl
enable_static=no
if test x$USER = xrwscott
then
    enable_maintainer_mode=yes
fi

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

dnl
dnl Are we on Linux ?
dnl
dnl This is just to work around libtool strangeness.
dnl
canonical=$host
configuration=$host_alias

case ${target_os} in
  linux*) linux=1;;
  *) linux=0;;
esac

AM_CONDITIONAL(LinuxOS, test x$linux = x1)

dnl
dnl OSF/Motifİ 1.2 compatibility is still the default version
dnl
version=1.2
version_suffix=""
include_version_suffix=-$version

AC_ARG_ENABLE(build-12,
[  --enable-build-12,         build Motif-1.2 compatible version (default)],
version=1.2;version_suffix="";include_version_suffix=-$version)
AC_ARG_ENABLE(build-20,
[  --enable-build-20,         build Motif-2.0 compatible version],
version=2.0; version_suffix=-$version;include_version_suffix=-$version)
AC_ARG_ENABLE(build-21,
[  --enable-build-21,         build Motif-2.1 compatible version],
version=2.1; version_suffix=-$version;include_version_suffix=-$version)
AC_ARG_ENABLE(build-CDE,
[  --enable-build-CDE,         build Motif-CDE compatible version],
version=CDE; version_suffix=-$version;include_version_suffix=-$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)
AM_CONDITIONAL(Version_CDE, test x$version = xCDE)

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

dnl
dnl Add macros
dnl	AC_PATH_MOTIF_DIRECT
dnl	AC_PATH_MOTIF
dnl	AC_XT_VERSION6
dnl	AC_XT_VERSION5
dnl	AM_MAINTAINER_MODE
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/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)])])


# Add --enable-maintainer-mode option to configure.
# From Jim Meyering

# serial 1

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 LessTif 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

dnl
dnl Whether to ask LessTif to be verbose
dnl Verbose means more messages may come out of LessTif than out of Motif.
dnl
AC_ARG_ENABLE(verbose,
[  --enable-verbose,         configure LessTif to be verbose (default)])

if test "x$enable_verbose" = "xno" ; then
	verbose_flag=""
else
	verbose_flag="-DLESSTIF_VERBOSE"
fi

dnl
dnl Whether to include nonstandard converters
dnl
AC_ARG_ENABLE(nonstandard-conversions,
[  --enable-nonstandard-conversions,         include nonstandard conversions])

if test "x$enable_nonstandard_conversions" = "xno" ; then
	conversions_flag=""
else
	conversions_flag="-DNONSTANDARD_CONVERTERS"
fi

dnl
dnl Build a production version of the library
dnl This will compile out XdbDebug statements
dnl
AC_ARG_ENABLE(production,
[  --enable-production,         build a production version])

if test "x$enable_production" = "xyes" ; then
	production_flag="-DLESSTIF_PRODUCTION"
else
	production_flag=""
fi

AC_MSG_RESULT($debug_flag $conversions_flag $verbose_flag $production_flag)

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

AC_PROG_YACC
AC_PROG_LEX
AC_DECL_YYTEXT

AC_HEADER_STDC
AC_CHECK_HEADERS(memory.h unistd.h string.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)
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)
AM_CONDITIONAL(HaveGetHostName, test x$version = x1.2)

AC_FUNC_STRCOLL

dnl
dnl Check integer sizes
dnl

AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 8)

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
if test "x$x_includes" != x ; then
  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 Lesstif)
  else
    AC_MSG_RESULT(revision 5)
    Editres=V5
  fi
else
  AC_MSG_RESULT(revision 6)
  R6libs="-lXext -lSM -lICE"
  Editres=V6
fi

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

dnl
dnl The constants are only used when cross compiling; if I understand the
dnl documentation well enough, those get substituted for the target.  The
dnl values given are the most common values, but may need customization if
dnl someone is desparate enough to _want_ to cross compile to a 64 bit
dnl machine from a 32 bit machine, for example.
dnl
dnl end integer sizes
dnl

dnl Now we handle the various system dependant problems
dnl that aren't addressed in the X header files, or things dealing
dnl with utility quirks on some systems.
dnl
dnl 1.  Whether the readdir call returns things in lexicographic order
dnl
dnl 2.  CFLAGS for ansi compliance on some platforms (HPUX)
dnl
dnl 3.  The makefile to use for building shared libraries
dnl
dnl (to be continued)

lexicographic_readdir=1

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

if test "x$lexicographic_readdir" != x ; then
   AC_DEFINE(READDIR_LEXICOGRAPHIC_ORDER)
fi

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

dnl
dnl We've taken a quick look at the world and have found that man pages
dnl in traditional man page source are a good source. This source format
dnl can be translated into e.g. HTML easily.
dnl We provide for such a translation via Debian's man2html.
dnl

AC_CHECK_PROG(VarHaveMan2html, man2html, 1, 0)
AM_CONDITIONAL(HaveMan2html, test x$VarHaveMan2html = x1)

dnl
dnl End man2html section
dnl

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(motif_libraries)
AC_SUBST(motif_includes)
AC_SUBST(R6libs)
AC_SUBST(Editres)
AC_SUBST(extralibs)

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
lib/Makefile
lib/config/Makefile
lib/config/Imake.tmpl
lib/config/Motif.rules
lib/config/Motif.tmpl
lib/config/mxmkmf
lib/Xm/Makefile
lib/Mrm/Makefile
lib/Uil/Makefile
lib/Xm-2.0/Makefile
lib/Mrm-2.0/Makefile
lib/Uil-2.0/Makefile
lib/Xm-2.1/Makefile
lib/Mrm-2.1/Makefile
lib/Xm-CDE/Makefile
lib/Mrm-CDE/Makefile
include/Makefile
include/Motif-1.2/Makefile
include/Motif-1.2/Mrm/Makefile
include/Motif-1.2/Xm/Makefile
include/Motif-1.2/Xm/Xm.h
include/Motif-1.2/XmI/Makefile
include/Motif-2.0/Makefile
include/Motif-2.0/Mrm/Makefile
include/Motif-2.0/Xm/Makefile
include/Motif-2.0/Xm/Xm.h
include/Motif-2.0/XmI/Makefile
include/Motif-2.1/Makefile
include/Motif-2.1/Mrm/Makefile
include/Motif-2.1/Xm/Makefile
include/Motif-2.1/XmI/Makefile
include/Motif-CDE/Makefile
include/Motif-CDE/Dt/Makefile
include/Motif-CDE/DtI/Makefile
include/Motif-CDE/Mrm/Makefile
include/Motif-CDE/Xm/Makefile
include/Motif-CDE/XmI/Makefile
clients/Makefile
clients/Motif-1.2/Makefile
clients/Motif-1.2/lib/Makefile
clients/Motif-1.2/mwm/Makefile
clients/Motif-1.2/uil/Makefile
clients/Motif-1.2/xmbind/Makefile
scripts/Makefile
scripts/FreeBSD/Makefile
scripts/RedHat/Makefile
scripts/RedHat/spec
scripts/Slackware/Makefile
scripts/Slackware/disklesstif1
scripts/Slackware/doinst.sh
doc/Makefile
doc/www.lesstif.org/Makefile
doc/www.lesstif.org/images/Makefile
doc/lessdox/Makefile
doc/lessdox/clients/Makefile
test/Makefile
test/Xm/Makefile
test/Xm/arrowbg/Makefile
test/Xm/arrowbutton/Makefile
test/Xm/baseclass/Makefile
test/Xm/bulletinboard/Makefile
test/Xm/cascadebutton/Makefile
test/Xm/cascadebuttong/Makefile
test/Xm/cmap/Makefile
test/Xm/combobox/Makefile
test/Xm/command/Makefile
test/Xm/cutpaste/Makefile
test/Xm/daniel/Makefile
test/Xm/dialogs/Makefile
test/Xm/drag_drop/Makefile
test/Xm/drag_help/Makefile
test/Xm/drag_icon/Makefile
test/Xm/drag_move/Makefile
test/Xm/drag_pixmaps/Makefile
test/Xm/drag_simple/Makefile
test/Xm/drawingarea/Makefile
test/Xm/drawnbutton/Makefile
test/Xm/dsscale/Makefile
test/Xm/scale/Makefile
test/Xm/dynamic_drag/Makefile
test/Xm/extobj/Makefile
test/Xm/filesb/Makefile
test/Xm/fonts/Makefile
test/Xm/form/Makefile
test/Xm/frame/Makefile
test/Xm/geometry/Makefile
test/Xm/imagecache/Makefile
test/Xm/international/Makefile
test/Xm/label/Makefile
test/Xm/labelg/Makefile
test/Xm/list/Makefile
test/Xm/mainw/Makefile
test/Xm/megabutton/Makefile
test/Xm/menushell/Makefile
test/Xm/messagebox/Makefile
test/Xm/misc/Makefile
test/Xm/mwm/Makefile
test/Xm/newtoggleb/Makefile
test/Xm/panedw/Makefile
test/Xm/protocols/Makefile
test/Xm/pushbg/Makefile
test/Xm/pushbutton/Makefile
test/Xm/region/Makefile
test/Xm/reptype/Makefile
test/Xm/resconvert/Makefile
test/Xm/resind/Makefile
test/Xm/rowcolumn/Makefile
test/Xm/screen/Makefile
test/Xm/scrollbar/Makefile
test/Xm/scrolledwindow/Makefile
test/Xm/selectionbox/Makefile
test/Xm/selections/Makefile
test/Xm/separator/Makefile
test/Xm/sepg/Makefile
test/Xm/smartmb/Makefile
test/Xm/spinbutton/Makefile
test/Xm/tearoff/Makefile
test/Xm/text/Makefile
test/Xm/textf/Makefile
test/Xm/togglebg/Makefile
test/Xm/togglebplus/Makefile
test/Xm/togglebutton/Makefile
test/Xm/tracking/Makefile
test/Xm/traversal/Makefile
test/Xm/vasimple/Makefile
test/Xm/vendor/Makefile
test/Xm/virtualkeys/Makefile
test/Xm/xmos/Makefile
test/Xm/xmstring/Makefile
test/Xm-2.0/Makefile
test/Xm-2.0/combobox/Makefile
test/Xm-2.0/draw/Makefile
test/Xm-2.0/grabshell/Makefile
test/Xm-2.0/spinbox/Makefile
test/Xm-2.0/notebook/Makefile
)

dnl
dnl The End.
dnl
