dnl withenable.ac: --with and --enable options.

AC_ARG_WITH(mktexmf-default,
[  --without-mktexmf-default    do not run mktexmf if MF source missing],
  , withval=yes)
if test "x$withval" = xyes; then
  AC_DEFINE(MAKE_TEX_MF_BY_DEFAULT)
fi
AC_ARG_WITH(mktexpk-default,
[  --without-mktexpk-default    do not run mktexpk if PK font missing],
  , withval=yes)
if test "x$withval" = xyes; then
  AC_DEFINE(MAKE_TEX_PK_BY_DEFAULT)
fi
AC_ARG_WITH(mktextfm-default,
[  --without-mktextfm-default   do not run mktextfm if TFM file missing],
   , withval=yes)
if test "x$withval" = xyes; then
  AC_DEFINE(MAKE_TEX_TFM_BY_DEFAULT)
fi
AC_ARG_WITH(mkocp-default,
[  --without-mkocp-default     do not run mkocp if OCP file missing],
   , withval=yes)
if test "x$withval" = xyes; then
  AC_DEFINE(MAKE_OMEGA_OCP_BY_DEFAULT)
fi
AC_ARG_WITH(mkofm-default,
[  --without-mkofm-default     do not run mkofm if OFM file missing],
   , withval=yes)
if test "x$withval" = xyes; then
  AC_DEFINE(MAKE_OMEGA_OFM_BY_DEFAULT)
fi

dnl The --enable-multiplatform option.
AC_CANONICAL_HOST
AC_ARG_ENABLE(multiplatform,
[  --enable-multiplatform     put executables in bin/PLATFORM],
if test "x$enable_multiplatform" = xyes &&
    test "x$bindir" = 'x${exec_prefix}/bin'
then
  bindir="$bindir/$host"
fi)

dnl Check whether we can find a texmf tree.  Look at the most common spots.
dnl Not a switch, but something that must be included everywhere, even at
dnl at the top level, so putting it in common.ac is not enough.
AC_MSG_CHECKING(where the main texmf tree is located)
texmfmain=
if test "x$datadir" != 'x${prefix}/share'; then
  # First case, datadir is defined...
  eval p=\"$datadir\"
  if test -d "$p/texmf"; then
    texmfmain="$p/texmf"
  fi
else
  # Second case, datadir is default...
  if test "x$prefix" = "xNONE"; then
    p="$ac_default_prefix"
  else
    eval p=\"$prefix\"
  fi
  for e in share/texmf lib/texmf texmf; do
    if test -d "$p/$e"; then
      texmfmain="$p/$e"
      break
    fi
  done
fi
texmfmain=`echo "$texmfmain" | sed 's,//*,/,g'`
if test -n "$texmfmain"; then
  AC_MSG_RESULT("$texmfmain")
else
  AC_MSG_RESULT([not found])
dnl Octave doesn't need this, so don't worry users if it can't be found.
dnl
dnl  AC_MSG_WARN([The main texmf tree was not found.
dnl  Specify the location of its parent directory with the --datadir option.
dnl  If you do not have the files, you can retrieve a minimal set from
dnl  ftp://ftp.tug.org/tex/texmflib.tar.gz, which is mirrored on CTAN hosts
dnl  in systems/web2c.  Winging it by using the default location.])
dnl  texmfmain="$datadir/texmf"
fi
AC_SUBST(texmfmain)
