view configure.in @ 1233:be470fb54633

[project @ 1995-04-10 05:20:52 by jwe]
author jwe
date Mon, 10 Apr 1995 05:20:52 +0000
parents b013cff15746
children 6c77481483bb
line wrap: on
line source

dnl configure.in
dnl
dnl Process this file with autoconf to produce a configure script.
dnl Requires GNU autoconf 1.8 or later.
dnl
dnl Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
### 
### This file is part of Octave.
### 
### Octave is free software; you can redistribute it and/or modify it
### under the terms of the GNU General Public License as published by the
### Free Software Foundation; either version 2, or (at your option) any
### later version.
### 
### Octave is distributed in the hope that it will be useful, but WITHOUT
### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
### FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
### for more details.
### 
### You should have received a copy of the GNU General Public License
### along with Octave; see the file COPYING.  If not, write to the Free
### Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

AC_REVISION($Revision: 1.110 $)
AC_PREREQ(2.0)
AC_INIT(src/octave.cc)
AC_CONFIG_HEADER(config.h)

AC_DEFINE(OCTAVE_SOURCE, 1)

AC_CANONICAL_HOST
if test -z "$host"; then
  host=unknown
fi
target_host_type=$host
canonical_host_type=$host
if test "$host" = unknown; then
  AC_MSG_WARN([configuring Octave for unknown system type
])
fi
AC_SUBST(target_host_type)

### Allow the user to force us to use f2c.

AC_ARG_WITH(f2c,
  [  --with-f2c              use f2c even if Fortran compiler is available],
  [if test $withval = no; then use_f2c=false; else use_f2c=true; fi],
  use_f2c=false)

### Allow the user to force us to use g77.

AC_ARG_WITH(g77,
  [  --with-g77              use g77 to compile Fortran subroutines],
  [if test $withval = no; then use_g77=false; else use_g77=true; fi],
  use_g77=false)

if $use_f2c && $use_g77; then
  AC_MSG_WARN([--with-f2c and --with-g77 both specified!  Using g77...])
  use_f2c=false
fi

### Allow the user to experiment with dynamic linking using GNU dld.

AC_ARG_ENABLE(dld,
  [  --enable-dld            use DLD for dynamic linking (not all systems)],
  [if test $enableval = no; then use_dld=false; else use_dld=true; fi],
  use_dld=false)
AC_SUBST(use_dld)

### Allow compilation of smaller kernel.  This only works if some form
### of dynamic linking is also supported and used.

AC_ARG_ENABLE(lite-kernel,
  [  --enable-lite-kernel    compile smaller kernel (requires DLD)],
  [if test $enableval = no; then lite_kernel=false; else lite_kernel=true; fi],
  lite_kernel=false)
if $lite_kernel; then
  AC_DEFINE(OCTAVE_LITE, 1)
fi
AC_SUBST(lite_kernel)

### Allow the user disable support for GNU info.

USE_GNU_INFO=true
LIBINFO=../info/libinfo.a
AC_ARG_ENABLE(info,
  [  --enable-info           use GNU info (default is yes)],
  [if test $enableval = no; then USE_GNU_INFO=false; LIBINFO=""; fi], [])
AC_SUBST(USE_GNU_INFO)
AC_SUBST(LIBINFO)

### Allow the user disable support for command line editing using GNU
### readline.

USE_READLINE=true
LIBREADLINE=../readline/libreadline.a
AC_ARG_ENABLE(readline,
  [  --enable-readline       use readline library (default is yes)],
  [if test "$enableval" = no; then USE_READLINE=false; LIBREADLINE=""; fi], [])
AC_SUBST(USE_READLINE)
AC_SUBST(LIBREADLINE)

### some defaults

AC_PREFIX_DEFAULT(/usr/local)

exec_prefix='$(prefix)'
bindir='$(exec_prefix)/bin'
datadir='$(prefix)/lib'
libdir='$(exec_prefix)/lib'
includedir='$(prefix)/include/octave'
mandir='$(prefix)/man/man1'
infodir='$(prefix)/info'
fcnfiledir='$(datadir)/octave/$(version)/m'
localfcnfiledir='$(datadir)/octave/site/m'
localfcnfilepath='$(localfcnfiledir)//'
archlibdir='$(libdir)/octave/$(version)/exec/$(target_host_type)'
octfiledir='$(libdir)/octave/$(version)/oct/$(target_host_type)'
localoctfiledir='$(datadir)/octave/site/oct/$(target_host_type)'
localoctfilepath='$(localoctfiledir)//'
fcnfilepath='.:$(localoctfilepath):$(localfcnfilepath):$(octfiledir)//:$(fcnfiledir)//'
imagedir='$(datadir)/octave/$(version)/imagelib'
imagepath='.:$(imagedir)//'

AC_MSG_RESULT([defining prefix to be $prefix])
AC_MSG_RESULT([defining exec_prefix to be $exec_prefix])
AC_MSG_RESULT([defining bindir to be $bindir])
AC_MSG_RESULT([defining datadir to be $datadir])
AC_MSG_RESULT([defining libdir to be $libdir])
AC_MSG_RESULT([defining includedir to be $includedir])
AC_MSG_RESULT([defining mandir to be $mandir])
AC_MSG_RESULT([defining infodir to be $infodir])
AC_MSG_RESULT([defining fcnfiledir to be $fcnfiledir])
AC_MSG_RESULT([defining localfcnfiledir to be $localfcnfiledir])
AC_MSG_RESULT([defining localfcnfilepath to be $localfcnfilepath])
AC_MSG_RESULT([defining archlibdir to be $archlibdir])
AC_MSG_RESULT([defining octfiledir to be $octfiledir])
AC_MSG_RESULT([defining localoctfiledir to be $localoctfiledir])
AC_MSG_RESULT([defining localoctfilepath to be $localoctfilepath])
AC_MSG_RESULT([defining fcnfilepath to be $fcnfilepath])
AC_MSG_RESULT([defining imagedir to be $imagedir])
AC_MSG_RESULT([defining imagepath to be $imagepath])
AC_SUBST(exec_prefix)
AC_SUBST(bindir)
AC_SUBST(datadir)
AC_SUBST(libdir)
AC_SUBST(includedir)
AC_SUBST(mandir)
AC_SUBST(infodir)
AC_SUBST(fcnfiledir)
AC_SUBST(localfcnfiledir)
AC_SUBST(localfcnfilepath)
AC_SUBST(archlibdir)
AC_SUBST(octfiledir)
AC_SUBST(localoctfiledir)
AC_SUBST(localoctfilepath)
AC_SUBST(fcnfilepath)
AC_SUBST(imagedir)
AC_SUBST(imagepath)

### Path separator.

AC_DEFINE(SEPCHAR, [':'])
AC_DEFINE(SEPCHAR_STR, [":"])

### Do special stuff if using dld.

DLD_DIR=
LIBDLD=
LIBOCTDLD='liboctdld.a'
LD_STATIC_FLAG=
if $use_dld; then
  DLD_DIR=dld
  LIBDLD='../dld/libdld.a'
# don't link them in only if doing dynamic linking and small kernel
# requested.
  if $lite_kernel; then
    LIBOCTDLD=
  fi
  LD_STATIC_FLAG=-static
  AC_DEFINE(WITH_DLD, 1)
fi

### Also use -static if compiling on Alpha OSF/1 1.3 systems.

case "$canonical_host_type" in
  alpha-dec-osf1.3)
    LD_STATIC_FLAG=-static
  ;;
esac

if test -n "$DLD_DIR"; then
  AC_MSG_RESULT([defining DLD_DIR to be $DLD_DIR])
fi
if test -n "$LIBDLD"; then
  AC_MSG_RESULT([defining LIBDLD to be $LIBDLD])
fi
if test -n "$LIBOCTDLD"; then
  AC_MSG_RESULT([defining LIBOCTDLD to be $LIBOCTDLD])
fi
if test -n "$LD_STATIC_FLAG"; then
  AC_MSG_RESULT([defining LD_STATIC_FLAG to be $LD_STATIC_FLAG])
fi
AC_SUBST(DLD_DIR)
AC_SUBST(LIBDLD)
AC_SUBST(LIBOCTDLD)
AC_SUBST(LD_STATIC_FLAG)

### See if the optional nonlinear programming code is present.

AC_MSG_CHECKING([for npsol])
if test -f $srcdir/libcruft/npsol/npsol.f; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_DEFINE(NPSOL_MISSING, 1)
fi

AC_MSG_CHECKING([for qpsol])
if test -f $srcdir/libcruft/qpsol/qpsol.f; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_DEFINE(QPSOL_MISSING, 1)
fi

AC_MSG_CHECKING([for fsqp])
if test -f $srcdir/libcruft/fsqp/fsqpd.f; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_DEFINE(FSQP_MISSING, 1)
fi

### See which C++ compiler to use (we expect to find g++).

AC_PROG_CXX
AC_PROG_CXXCPP

### Do special things for g++.

ADD_CXX_WALL=false
NO_IMPLICIT_TEMPLATES=
gxx_version=`$CXX -v 2>&1 | grep "^.*g.. version" | sed 's/^.*g.. version *//'`
case "$gxx_version" in
changequote(,)dnl
  2.[6789].*|2.[123456789][0123456789].*)
changequote([,])dnl
    if test -z "$CXXFLAGS"; then
      CXXFLAGS="-g -O"
      AC_MSG_RESULT([defining CXXFLAGS to be $CXXFLAGS])
      ADD_CXX_WALL=true
    fi
    NO_IMPLICIT_TEMPLATES="-fno-implicit-templates"
    AC_MSG_RESULT([defining NO_IMPLICIT_TEMPLATES to be $NO_IMPLICIT_TEMPLATES])
  ;;
changequote(,)dnl
  1.*|2.[012345].*)
changequote([,])dnl
    AC_MSG_WARN([g++ version $gxx_version will not work to compile Octave])
  ;;
  *)
    AC_MSG_WARN([Octave has only been tested with g++, and I can't find it])
  ;;
esac

HOST_CXXFLAGS=
case "$gxx_version" in
  2.6.*)
    case "$canonical_host_type" in
      rs6000-ibm-aix*)
        HOST_CXXFLAGS="-Wa,-u"
        AC_MSG_RESULT([defining HOST_CXXFLAGS to be $HOST_CXXFLAGS])
      ;;
    esac
  ;;
esac

AC_SUBST(HOST_CXXFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(NO_IMPLICIT_TEMPLATES)

### See which C compiler to use (we expect to find gcc).

AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL

### Do special things for gcc.

ADD_CC_WALL=false
gcc_version=`$CC -v 2>&1 | grep "^.*gcc version" | sed 's/^.*gcc version *//'`
case "$gcc_version" in
  2.*)
    if test -z "$CFLAGS"; then
      CFLAGS="-g -O"
      AC_MSG_RESULT([defining CFLAGS to be $CFLAGS])
      ADD_CC_WALL=true
    fi
    if test -z "$LDFLAGS"; then
      LDFLAGS="-g"
      AC_MSG_RESULT([defining LDFLAGS to be $LDFLAGS])
    fi
  ;;
  1.*)
    AC_MSG_WARN([gcc version $gcc_version is likely to cause problems])
  ;;
  *)
    AC_MSG_WARN([Octave has only been tested with gcc, and I can't find it])
  ;;
esac

AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)

### On Linux systems we need to compile with -mieee-fp to get full
### support for IEEE floating point.

case "$canonical_host_type" in
  i386-*-linux | i486-*-linux | i586-*-linux)
    GCC_IEEE_FP_FLAG="-mieee-fp"
    AC_MSG_RESULT([defining GCC_IEEE_FP_FLAG to be $GCC_IEEE_FP_FLAG])
  ;;
esac

AC_SUBST(GCC_IEEE_FP_FLAG)

### Special checks for odd OS specific things.

AC_ISC_POSIX
AC_MINIX
AC_AIX
AC_CHECK_LIB(sun, getpwnam)

### How big are ints and how are they oriented?  These could probably
### be eliminated in favor of run-time checks.

AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_C_BIGENDIAN

### Does the C compiler handle alloca() and const correctly?

AC_ALLOCA
AC_C_CONST

### Get the list of libraries that the C++ compiler normally uses.

OCTAVE_CXXLIBS

### If we haven't been forced to use f2c, try to find a Fortran compiler
### under any one of several common Un*x Fortran compiler names. 
### Put fc last to avoid confusion with some vendor's /bin/sh fc
### builtin.
###
###    xlf : IBM / AIX
###   cf77 : Cray / Unicos
###    g77 : GNU Fortran (someday...)
###     fc : Convex
###
### I don't think the Cray compiler will ever work like f2c...

### XXX FIXME XXX -- I don't think the logic here is quite right if we
### want to allow --with-g77 or --with-f2c to force them to be used
### even if they aren't available or don't appear to work correctly.

if $use_g77; then
  F77=g77
elif $use_f2c; then
  F77=
else
  AC_CHECK_PROGS(F77, xlf cf77 f77 g77 fc)
fi

# If it looks like we have a Fortran compiler, try to determine
# whether it might be compatible with f2c.

if test -n "$F77"; then
  OCTAVE_FLIBS
  OCTAVE_F77_APPEND_UNDERSCORE
  OCTAVE_F2C_F77_COMPAT

  if test "$octave_cv_f2c_f77_compat" = no; then
    F77=
  else
    if test -z "$FFLAGS"; then
      FFLAGS="-O"
      AC_MSG_RESULT([defining FFLAGS to be $FFLAGS])
    fi
  fi
fi

### If we can't find a Fortran compiler, or if it looks like it isn't
### compatible with f2c, try to find f2c.

if test -z "$F77"; then
  AC_CHECK_PROG(F2C, f2c, f2c, [])
fi

### At this point, either F77, F2C, use_f2c, or use_g77 should be set.

if test -n "$F77"; then
  if test "$F77" = "g77"; then
    FUGLY=-fugly
    AC_MSG_RESULT([defining FUGLY to be $FUGLY])
  fi
  DOT_C_FROM_DOT_F_CMD=
  DOT_O_FROM_DOT_F_PAT='.f.o:'
  DOT_O_FROM_DOT_F_CMD='	$(FC) -c $(ALL_FFLAGS) $<'
elif test -n "$F2C" || $use_f2c; then
  AC_CHECK_LIB(f2c, main, FLIBS=-lf2c, [])
  if test -z "$FLIBS" ; then
    AC_CHECK_LIB(F77, main, FLIBS=-lF77, [])
    if test -n "$FLIBS" ; then
      AC_CHECK_LIB(I77, main, FLIBS="$FLIBS -lI77", [])
    fi
  fi
  if test -z "$FLIBS" ; then
    AC_MSG_WARN([I found f2c but not libf2c.a, or libF77.a and libI77.a])
  fi
  DOT_C_FROM_DOT_F_CMD='	cat $< | $(F2C) $(F2CFLAGS) > $(@F)'
  AC_MSG_RESULT([defining DOT_C_FROM_DOT_F_CMD to be $DOT_C_FROM_DOT_F_CMD])
  DOT_O_FROM_DOT_F_PAT='%.o : %.f'
  DOT_O_FROM_DOT_F_CMD=
  AC_MSG_RESULT([defining DOT_O_FROM_DOT_F_PAT to be $DOT_O_FROM_DOT_F_PAT])
  AC_DEFINE(F77_APPEND_UNDERSCORE, 1)
else
  AC_MSG_WARN([in order to build octave, you must have a compatible])
  AC_MSG_WARN([Fortran compiler or f2c installed and in your path.])
  AC_MSG_WARN([See the file INSTALL for more information.])
  AC_MSG_WARN([Continuing anyway...])
fi

FC=$F77
AC_SUBST(FC)
AC_SUBST(F77)
AC_SUBST(FFLAGS)
AC_SUBST(FUGLY)
AC_SUBST(FLIBS)
AC_SUBST(F2C)
AC_SUBST(F2CFLAGS)
AC_SUBST(DOT_C_FROM_DOT_F_CMD)
AC_SUBST(DOT_O_FROM_DOT_F_PAT)
AC_SUBST(DOT_O_FROM_DOT_F_CMD)

### Extract libraries and directories from FLIBS and CXXLIBS.
###
### Leave only libraries, with -lfoo converted to libfoo.a:

changequote(,)dnl
FLIB_LIST=`echo " $FLIBS " | sed -e 's/ -Xlinker *[^ ]*/ /g' \
	-e 's/ -[LR] *[^ ]*/ /g' \
	-e 's/ -l *\([^ ]*\)/ lib\1.a/g' -e 's/ -u *[^ ]*/ /g' \
	-e 's/ [^ ]*\.o//g' \
	-e 's/^ *//' -e 's/ *$//' -e 's/  */:/g'`

CXXLIB_LIST=`echo " $CXXLIBS " | sed -e 's/ -Xlinker *[^ ]*/ /g' \
	-e 's/ -[LR] *[^ ]*/ /g' \
	-e 's/ -l *\([^ ]*\)/ lib\1.a/g' -e 's/ -u *[^ ]*/ /g' \
	-e 's/ [^ ]*\.o//g' \
	-e 's/^ *//' -e 's/ *$//' -e 's/  */:/g'`

### Leave only directories where libraries might be found:

FLIB_PATH=`echo " $FLIBS " | sed \
	-e 's/ /  /g' -e 's/ -Xlinker *[^ ]*/ /g' \
	-e 's/ -[LR] *\([^ ]*\)/ \1/g' -e 's, /[^ ]*\.a , ,g' \
	-e 's/ -l *[^ ]*/ /g' -e 's/ -u *[^ ]*/ /g' \
	-e 's/ [^ ]*\.o//g' \
	-e 's/^ *//' -e 's/ *$//' -e 's/  */:/g'`

CXXLIB_PATH=`echo " $CXXLIBS " | sed -e 's/ -Xlinker *[^ ]*/ /g' \
	-e 's/ -[LR] *\([^ ]*\)/ \1/g' -e 's, /[^ ]*\.a , ,g' \
	-e 's/ /  /g' -e 's/ -Xlinker *[^ ]*/ /g' \
	-e 's/ -l *[^ ]*/ /g' -e 's/ -u *[^ ]*/ /g' \
	-e 's/ [^ ]*\.o//g' \
	-e 's/^ *//' -e 's/ *$//' -e 's/  */:/g'`
changequote([,])dnl

AC_MSG_RESULT([defining FLIB_LIST to be $FLIB_LIST])
AC_MSG_RESULT([defining FLIB_PATH to be $FLIB_PATH])

AC_MSG_RESULT([defining CXXLIB_LIST to be $CXXLIB_LIST])
AC_MSG_RESULT([defining CXXLIB_PATH to be $CXXLIB_PATH])

AC_SUBST(FLIB_LIST)
AC_SUBST(FLIB_PATH)

AC_SUBST(CXXLIB_LIST)
AC_SUBST(CXXLIB_PATH)

### Checks for header files.

AC_HEADER_STDC
AC_CHECK_HEADERS(assert.h float.h limits.h memory.h pwd.h stdlib.h)
AC_CHECK_HEADERS(string.h varargs.h unistd.h floatingpoint.h)
AC_CHECK_HEADERS(sys/utsname.h sys/time.h sys/fcntl.h)
AC_CHECK_HEADERS(sys/ttold.h sys/ptem.h sys/select.h sys/resource.h)
AC_HEADER_DIRENT
AC_TIME_WITH_SYS_TIME

### Use sgtty on Ultrix so that using DEC Migrate to convert a Mips
### binary to an Alpha binary will work.  Also on Alpha/OSF to avoid
### a readline bug.

case "$canonical_host_type" in
  mips-dec-ultrix* | alpha-dec-osf*)
    AC_CHECK_HEADER(sgtty.h, [AC_DEFINE(HAVE_SGTTY_H, 1)], [])

    if test "$ac_cv_header_sgtty_h" = no; then
      AC_CHECK_HEADERS(termios.h termio.h sgtty.h, [break], [])
    fi
  ;;
  *)
    AC_CHECK_HEADERS(termios.h termio.h sgtty.h, [break], [])
  ;;
esac

if test "$ac_cv_header_termios_h" = yes \
    || test "$ac_cv_header_termio_h" = yes \
    || test "$ac_cv_header_sgtty_h" = yes; then
  true
else
  AC_MSG_ERROR([I couldn't find termios.h, termio.h, or sgtty.h!])
fi

### Checks for functions.

AC_CHECK_FUNCS(setvbuf getcwd gethostname bzero bcopy rindex vfprintf vsprintf)
AC_CHECK_FUNCS(stricmp strnicmp strcasecmp strncasecmp strerror atexit)
AC_CHECK_FUNCS(on_exit tempnam memmove putenv gettimeofday getrusage)

dnl Would like to get rid of this cruft, and just have
dnl
dnl   AC_CHECK_FUNCS(finite isnan isinf)
dnl
dnl instead, but that used to fail on some systems...
dnl
dnl Also just using AC_CHECK_FUNCS doesn't seem to work to find isinf
dnl and isnan on Linux systems, so we use AC_CHECK_FUNC, and if that
dnl fails, we try again by including math.h and invoking the function
dnl with an argument. 

### Check to see if we have IEEE math functions, and if so, which ones.
###
### For Linux: add -mieee-fp flag to CFLAGS when checking for IEEE FP
### functions, otherwise we may not find them.
###
### Also check for some additional trig functions that aren't ANSI but
### are often available.  If they are missing, we try to replace them
### with functions from the BSD/NET2 math library.

AC_CHECK_LIB(sunmath, main)

dnl This is bogus.  We shouldn't have to explicitly add libc too!

case "$canonical_host_type" in
  *-*-linux*)
    AC_CHECK_LIB(m, main, , , -lc)
  ;;
  *)
    AC_CHECK_LIB(m, main)
  ;;
esac

XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $GCC_IEEE_FP_FLAG"

### Inf and NaN don't work with gcc on the Alpha yet.  I am also told
### that they don't work on m68k HP sytems either.

case "$canonical_host_type" in
  alpha-dec-osf* | m68k-hp-hpux*)
  ;;
  *)
    AC_CHECK_FUNCS(finite isnan isinf infinity quiet_nan)
  ;;
esac

### Check for nonstandard but common math functions that we need.

AC_CHECK_FUNCS(acosh asinh atanh erf erfc)

CFLAGS="$XCFLAGS"

### Checks for OS specific cruft.

AC_STRUCT_TM
AC_STRUCT_TIMEZONE
AC_FUNC_SETVBUF_REVERSED

TERMLIBS=""
for termlib in termcap terminfo curses termlib ; do
  AC_CHECK_LIB(${termlib}, main, [TERMLIBS="${TERMLIBS} -l${termlib}"])
  case "${TERMLIBS}" in
    *-l${termlib}*)
      AC_MSG_RESULT([defining TERMLIBS to be $TERMLIBS])
      break
    ;;
  esac
done
AC_SUBST(TERMLIBS)

AC_MSG_CHECKING([for struct exception in math.h])
AC_TRY_LINK([#include <math.h>],
  [struct exception *x; x->type; x->name;],
  AC_MSG_RESULT(yes)
  AC_DEFINE(EXCEPTION_IN_MATH, 1),
  AC_MSG_RESULT(no))

### Signal stuff.

AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST
AC_MSG_CHECKING([for sys_siglist variable])
AC_TRY_LINK([#include <stdio.h>],
  [extern char *sys_siglist[]; printf ("%s\n", sys_siglist[1]);],
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_SYS_SIGLIST, 1),
  AC_MSG_RESULT(no))

### Define VOID_SIGHANDLER for readline.

case "$RETSIGTYPE" in
  int)
  ;;
  *)
    VOID_SIGHANDLER="-DVOID_SIGHANDLER=1"
    AC_MSG_RESULT([defining VOID_SIGHANDLER to be 1])
  ;;
esac
AC_SUBST(VOID_SIGHANDLER)

### Checks for other programs used for building, testing, installing,
### and running Octave.
###
### For now, don't define LEXLIB to be -lfl -- we don't use anything in
### it, and it might not be installed.
###
### Also make sure that we generate an interactive scanner if we are
### using flex.

AC_PROG_LEX
case "$LEX" in
  flex*)
    LFLAGS="-t -I"
    AC_MSG_RESULT([defining LFLAGS to be $LFLAGS])
    LEXLIB=
  ;;
  *)
    LFLAGS="-t"
    AC_MSG_RESULT([defining LFLAGS to be $LFLAGS])
    AC_MSG_WARN([I didn't find flex, but that's only a problem])
    AC_MSG_WARN([if you need to reconstruct lex.cc])
  ;;
esac
AC_SUBST(LFLAGS)

AC_PROG_YACC
case "$YACC" in
  bison*)
  ;;
  *)
    AC_MSG_WARN([I didn't find bison, but that's only a problem])
    AC_MSG_WARN([if you need to reconstruct parse.cc])
  ;;
esac

AC_PROG_RANLIB

AC_CHECK_PROG(RUNTEST, runtest, runtest, [])
AC_CHECK_PROG(EXPECT, expect, expect, [])
if test -z "$EXPECT" ; then
  RUNTEST=
fi
AC_SUBST(RUNTEST)

AC_PROG_INSTALL

AC_CHECK_PROG(GNUPLOT_BINARY, gnuplot, gnuplot, [])
if test -z "$GNUPLOT_BINARY"; then
  AC_MSG_WARN([I didn't find gnuplot.  It isn't necessary to have gnuplot])
  AC_MSG_WARN([installed, but you won't be able to use any of Octave's])
  AC_MSG_WARN([plotting commands without it.])
  AC_MSG_WARN([])
  AC_MSG_WARN([If gnuplot is installed but it isn't in your path, you can])
  AC_MSG_WARN([tell Octave where to find it by typing the command])
  AC_MSG_WARN([])
  AC_MSG_WARN([gnuplot_binary = "/full/path/to/gnuplot/binary"])
  AC_MSG_WARN([])
  AC_MSG_WARN([at the Octave prompt.])
fi

AC_CHECK_PROGS(DEFAULT_PAGER, less more page pg, [])
if test -z "$DEFAULT_PAGER"; then
  AC_MSG_WARN([I couldn't find `less', `more', `page', or `pg'])
elif test "$DEFAULT_PAGER" = less; then
  DEFAULT_PAGER="less -e"
  AC_MSG_RESULT([defining DEFAULT_PAGER to be $DEFAULT_PAGER])
fi

### Even though we include config.h in most files, some need to be
### compiled with the -D options on the compiler command line.  Use
### UGLY_DEFS for that.

AC_OUTPUT_MAKE_DEFS
UGLY_DEFS="$DEFS"
AC_MSG_RESULT([defining UGLY_DEFS to be $UGLY_DEFS])
AC_SUBST(UGLY_DEFS)

### Maybe add -Wall to compiler flags now that we're done feature
### testing. 
###
### To get gcc and g++ to be really picky, try these adding these
### options to CFLAGS and CXXFLAGS along with -Wall:
###
###   -ansi
###   -pedantic
###   -Wwrite-strings
###   -Wid-clash-31
###   -Wpointer-arith
###   -Wcast-qual
###   -Wenum-clash
###   -Wcast-align
###   -Wtraditional
###   -Wstrict-prototypes
###   -Wmissing-prototypes
###   -Wnested-externs
###   -Woverloaded-virtual
###   -Winline
###   -felide-constructors
###   -fnonnull-objects

if $ADD_CXX_WALL; then
  CXXFLAGS="$CXXFLAGS -Wall"
  AC_MSG_RESULT([adding -Wall to CXXFLAGS])
fi
if $ADD_CC_WALL; then
  CFLAGS="$CFLAGS -Wall"
  AC_MSG_RESULT([adding -Wall to CFLAGS])
fi

### Run configure in subdirectories.

AC_CONFIG_SUBDIRS(kpathsea)

### Do the substitutions in all the Makefiles.

define([tmpA], [Makefile octMakefile Makeconf])dnl
define([tmpB], [libcruft/Makefile libcruft/Makerules])dnl
define([tmpC], [liboctave/Makefile src/Makefile dld/Makefile])dnl
define([tmpD], [info/Makefile readline/Makefile readline/doc/Makefile])dnl
define([tmpE], [readline/examples/Makefile doc/Makefile])dnl
define([tmpF], [test/Makefile])dnl
define([srcdirs], [tmpA tmpB tmpC tmpD tmpE tmpF])dnl

define([tmpa], [libcruft/blas/Makefile libcruft/balgen/Makefile])dnl
define([tmpb], [libcruft/dassl/Makefile libcruft/eispack/Makefile])dnl
define([tmpc], [libcruft/fftpack/Makefile libcruft/fsqp/Makefile])dnl
define([tmpd], [libcruft/lapack/Makefile libcruft/linpack/Makefile])dnl
define([tmpe], [libcruft/minpack/Makefile libcruft/misc/Makefile])dnl
define([tmpf], [libcruft/npsol/Makefile libcruft/odepack/Makefile])dnl
define([tmpg], [libcruft/qpsol/Makefile libcruft/quadpack/Makefile])dnl
define([tmph], [libcruft/ranlib/Makefile libcruft/slatec-fn/Makefile])dnl
define([tmpi], [libcruft/villad/Makefile])dnl

define([cruftdirs], [tmpa tmpb tmpc tmpd tmpe tmpf tmpg tmph tmpi])dnl
define([tmpSA], [scripts/Makefile scripts/control/Makefile])dnl
define([tmpSB], [scripts/general/Makefile scripts/image/Makefile])
define([tmpSC], [scripts/linear-algebra/Makefile])dnl
define([tmpSD], [scripts/miscellaneous/Makefile scripts/plot/Makefile])dnl
define([tmpSE], [scripts/polynomial/Makefile scripts/set/Makefile])dnl
define([tmpSF], [scripts/signal/Makefile scripts/special-matrix/Makefile])dnl
define([tmpSG], [scripts/startup/Makefile scripts/statistics/Makefile])dnl
define([tmpSH], [scripts/elfun/Makefile scripts/specfun/Makefile])dnl
define([tmpSI], [scripts/strings/Makefile scripts/time/Makefile])dnl
define([mdirs], [tmpSA tmpSB tmpSC tmpSD tmpSE tmpSF tmpSG tmpSH tmpSI])dnl

AC_OUTPUT([srcdirs cruftdirs mdirs])

### Print a summary so that important information isn't missed.

CXX_EXTRAS="$HOST_CXXFLAGS $NO_IMPLICIT_TEMPLATES $GCC_IEEE_FP_FLAG"

if test -z "$F77"; then
  FORT="$F2C $F2CFLAGS"
else
  FORT="$F77 $FFLAGS $FUGLY"
fi

AC_MSG_RESULT([

Octave is now configured for $canonical_host_type

  Source directory:       $srcdir
  Installation prefix:    $prefix
  C compiler:             $CC $GCC_IEEE_FP_FLAG $CFLAGS
  C++ compiler:           $CXX $CXX_EXTRAS $CXXFLAGS
  Fortran compiler:       $FORT
  Fortran libraries:      $FLIBS
  Dynamic Linking:        $use_dld
  Minimal kernel option:  $lite_kernel
  Use GNU readline:       $USE_READLINE
  Use GNU info reader:    $USE_GNU_INFO
  Default pager:          $DEFAULT_PAGER
  gnuplot:                $GNUPLOT_BINARY
])