AC_PREREQ(2.57)

######################
# aegisub version info 
######################
# MAKE SURE YOU UPDATE THE VERSION INFO BELOW WHEN YOU SET THIS TO '1'
m4_define([aegisub_FINAL_RELEASE], [1])

m4_define([aegisub_version_major], [2])
m4_define([aegisub_version_minor], [1])
m4_define([aegisub_version_revision], [9])
m4_define([aegisub_version], [aegisub_version_major.aegisub_version_minor.aegisub_version_revision])
m4_define([aegisub_version_data], [aegisub_version_major.aegisub_version_minor])


###################
# Required packages
###################
m4_define([lua_auto3_required_version], [5.0])
m4_define([lua_auto4_required_version], [5.1])
m4_define([portaudio_required_version], [19])
m4_define([pulseaudio_required_version], [0.5])

m4_define([fontconfig_required_version], [2.4])
m4_define([freetype_required_version], [9.7.0])
m4_define([perl_required_version], [5.004])
m4_define([pkgconfig_required_version], [0.20])
m4_define([ruby_required_version], [1.8])
m4_define([wx_required_version], [2.8.1])
m4_define([ffms_required_version], [2.13.1])
m4_define([libass_required_version], [0.9.11])


#######
# Setup
#######
AC_INIT([Aegisub], [aegisub_version],, [aegisub])
AC_CONFIG_SRCDIR([src/main.cpp])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([acconf.h])
AC_GNU_SOURCE
AC_CANONICAL_HOST


###########################
# Check target architecture
###########################

AC_MSG_CHECKING([for target architecture])
case x"$target" in
  xNONE | x)
    target_or_host="$host" ;;
  *)
    target_or_host="$target" ;;
esac
AC_MSG_RESULT([$target_or_host])

case "$target_or_host" in
  *-*-darwin*)
    build_darwin="yes"
  ;;

  *-*-linux*)
    build_linux="yes"
  ;;

  *)
    build_default="yes"
    ;;
esac

case "$target_or_host" in
  ppc-*-* | powerpc-*)
    arch_ppc="yes"
  ;;

  i*86-*-*)
    arch_x86="yes"
  ;;

  x86_64-*-*)
    arch_x86="yes"
    arch_x86_64="yes"
  ;;

  *)
  ;;
esac

# Darwin / OS X settings
if test "$build_darwin" = "yes"; then
  if test "$arch_x86" = "yes"; then
    DARWIN_ARCH="intel"
  elif test "$arch_ppc" = "yes"; then
    DARWIN_ARCH="ppc"
  fi
  AC_SUBST(DARWIN_ARCH)

  CXXFLAGS_OSX="-mmacosx-version-min=10.5"

  case "$target_or_host" in
    # 10.4
    *-*-darwin8*)
    ;;
    # 10.5
    *-*-darwin9*)
      CXXFLAGS_OSX="$CXXFLAGS_OSX -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
    ;;
  esac

  AC_SUBST(CXXFLAGS_OSX)
fi

# Used for universalchardet.
AC_AGI_MDCPUCFG($target_or_host)

# For conditional file building and options in Makefile(s).
AM_CONDITIONAL([BUILD_DARWIN], [test "$build_darwin" = "yes"])
AM_CONDITIONAL([BUILD_DEFAULT], [test "$build_default" = "yes"])

# FontConfig is used on Darwin for the fontlister, freetype for !Windows case.
AM_CONDITIONAL([FONTLISTER_FONTCONFIG], [test "$build_darwin" != "yes"])
AM_CONDITIONAL([FONTLISTER_FREETYPE], [test "$build_darwin" = "yes"])

# Handle endianess.
AC_C_BIGENDIAN(
    AC_DEFINE([HAVE_BIG_ENDIAN], [1], [Big Endian]),
    AC_DEFINE([HAVE_LITTLE_ENDIAN], [1], [Little Endian]),
    AC_DEFINE([HAVE_DYNAMIC_ENDIAN], [1], [Unknown endian]),
    AC_DEFINE([HAVE_UNIVERSAL_ENDIAN], [1], [Universal Endian (MAC Universal PPC/Intel Binaries, uses HAVE_DYNAMIC_ENDIAN)])
)


########################
# Configurable variables
########################

# These cannot be set before AC_INIT()
AEGISUB_VERSION_MAJOR=aegisub_version_major
AEGISUB_VERSION_MINOR=aegisub_version_minor
AEGISUB_VERSION=aegisub_version
# Used for gettext.
AEGISUB_VERSION_DATA=aegisub_version_data

# Suffix used for data paths.
AC_DEFINE_UNQUOTED(AEGISUB_VERSION_DATA, ["$AEGISUB_VERSION_DATA"], [Data path suffix.])
AC_SUBST(AEGISUB_VERSION_DATA)

# Shared data and Documents location.
aegisubdatadir="$datadir/$PACKAGE/aegisub_version_data"
AC_SUBST(aegisubdatadir)
aegisubdocdir="$docdir/$PACKAGE"
AC_SUBST(aegisubdocdir)

# Name of aegisub binary.
AEGISUB_COMMAND="aegisub-$AEGISUB_VERSION_MAJOR.$AEGISUB_VERSION_MINOR"
AC_SUBST(AEGISUB_COMMAND)

# Handle location of desktop files: http://freedesktop.org/wiki/Specifications/desktop-entry-spec
AC_ARG_WITH(desktop-dir, [  --with-desktop-dir=PATH desktop file locations (default: PREFIX/share)])
if ! test -z "$with_desktop_dir" ; then
  DESKTOP_DATADIR=$with_desktop_dir
else
  DESKTOP_DATADIR="$datadir"
fi
AM_CONDITIONAL(DESKTOP_DATADIR, test "$with_desktop_dir" != "no")
AC_SUBST(DESKTOP_DATADIR)


# Install prefix
# If a user doesn't supply --prefix then it is set to NONE so we
# set it to $ac_default_prefix if it hasn't been supplied.
if test "$prefix" = "NONE"; then
	prefix="$ac_default_prefix"
fi

# Install prefix used by wxStandardPaths::SetInstallPrefix.
AC_DEFINE_UNQUOTED([INSTALL_PREFIX], ["$prefix"], [Default install prefix, or --prefix.])

# Build credit
AC_ARG_WITH(build-credit, [  --with-build-credit=NAME
                          Build credit shown in the program title.], [use_build_credit="yes"])
AC_MSG_CHECKING([whether BUILD_CREDIT has been set])
if test "$use_build_credit" = "yes"; then
  if test "$with_build_credit" = "yes" || test -z "$with_build_credit"; then
    AC_MSG_FAILURE([You must set a value eg --with-build-credit=<username>])
  else
    AC_MSG_RESULT([yes ($with_build_credit)])
    AC_DEFINE_UNQUOTED([BUILD_CREDIT], ["$with_build_credit"], [Build credit supplied in application title using --with-build-credit=])
  fi
else
  AC_MSG_RESULT([no])
fi

# Set tags for the update checker.
if test "$build_darwin" = "yes"; then
  AC_DEFINE(UPDATE_CHECKER_ACCEPT_TAGS, "osx unix source", [Do not change these from the default.])
else
  AC_DEFINE(UPDATE_CHECKER_ACCEPT_TAGS, "unix source", [Do not change these from the default.])
fi


####################
# Check for programs
####################
CHECK_GNU_MAKE
AC_PROG_CC
AC_PROG_CXX
AC_LANG(C++)
AM_PROG_CC_C_O
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])
AC_PROG_LIBTOOL
AC_PROG_INSTALL
PKG_PROG_PKG_CONFIG([pkgconfig_required_version])


#################
# Developers only
#################
AM_MAINTAINER_MODE

# XXX: This needs to be fixed to handle mixed revisions properly
#      There is probably a better way to handle it as well...
AC_MSG_CHECKING([for svn version])
if test -d "$srcdir/.svn"; then
  SVN_REVISION=`svnversion $srcdir | sed "s/\(^@<:@0-9@:>@*\).*/\1/"`
  `echo $SVN_REVISION > $srcdir/svn_revision`
  AC_MSG_RESULT([$SVN_REVISION from "svnversion $srcdir"])
elif test -f "$srcdir/svn_revision"; then
  SVN_REVISION=`cat $srcdir/svn_revision`
  AC_MSG_RESULT([$SVN_REVISION from "$srcdir/svn_revision"])
else
  AC_MSG_RESULT([not found])
  AC_MSG_FAILURE([unable to get SVN Revision from $srcdir/svn_revision or 'svnversion $srcdir'])
fi

# This is required in order for the config file to work correctly.
AC_DEFINE_UNQUOTED([BUILD_SVN_REVISION], [$SVN_REVISION], [SVN Revision number, used for config.dat and version.cpp])


# Release information.
if test "aegisub_FINAL_RELEASE" = "1"; then
  AC_DEFINE([FINAL_RELEASE], [aegisub_FINAL_RELEASE], [This is only set to 1 for a RELEASE VERSION.])
  BUNDLE_STRING="Aegisub"
  DMG_STRING="Aegisub-${PACKAGE_VERSION}-${DARWIN_ARCH}"
else
  PACKAGE_STRING="${PACKAGE_STRING}-dev-r${SVN_REVISION}"
  PACKAGE_VERSION="${PACKAGE_VERSION}-dev-r${SVN_REVISION}"
  VERSION="${VERSION}-dev-r${SVN_REVISION}"

  BUNDLE_STRING="Aegisub-${PACKAGE_VERSION}-${DARWIN_ARCH}"
  DMG_STRING="Aegisub-${PACKAGE_VERSION}-${DARWIN_ARCH}"
fi


# Used in version.cpp
AC_MSG_CHECKING([for build date])
BUILD_DATE=`date "+%Y-%m-%d %H:%M %Z"`
AC_MSG_RESULT($BUILD_DATE)

AC_SUBST(SVN_REVISION)
AC_SUBST(BUILD_DATE)
AC_SUBST(BUNDLE_STRING)
AC_SUBST(DMG_STRING)



###################################################
# Check for pthreads and setup variables / compiler
###################################################
ACX_PTHREAD([], [AC_MSG_FAILURE([aegisub requires pthreads])])
#LIBS="$PTHREAD_LIBS $LIBS";
#CFLAGS="$CFLAGS $PTHREAD_CFLAGS";
CC="$PTHREAD_CC";


######################
# Check compiler flags
######################
AC_ARG_ENABLE(compiler-flags, [  --disable-compiler-flags
                          Disable *all* additional compiler flags. (default=no)])

if test "$enable_compiler_flags" != "no"; then
  AC_C_FLAG([-Wall])
  AC_C_FLAG([-Wextra],[AC_C_FLAG([-W])])
  AC_C_FLAG([-Wno-unused-parameter])
  AC_C_FLAG([-std=gnu99])
  AC_C_FLAG([-pipe])
  AC_CXX_FLAG([-Wall])
  AC_CXX_FLAG([-Wextra],[AC_CXX_FLAG([-W])])
  AC_CXX_FLAG([-Wno-unused-parameter])
  AC_CXX_FLAG([-Wno-long-long])
  AC_CXX_FLAG([-fpermissive])
  AC_CXX_FLAG([-fno-strict-aliasing])
  AC_CXX_FLAG([-std=c++98])
  AC_CXX_FLAG([-pipe])

  # -O* messes with debugging.
  if test "$enable_debug" = "yes"; then
    opt_flag="-O0"
  else
    opt_flag="-O2"
  fi

  AC_C_FLAG([$opt_flag])
  AC_CXX_FLAG([$opt_flag])
fi

######################################
# Check Headers / Features / Libraries
######################################
AC_PATH_XTRA
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_CHECK_LIB([m], [main])

AC_CHECK_FUNC([strlcpy], [
	AC_DEFINE([HAVE_STRLCPY], [1], [strlcpy() exists in the c library.])
], [])

AC_LIBTOOL_DLOPEN_SELF
AC_MSG_CHECKING([[whether preprocessor supports #pragma once]])
AC_PREPROC_IFELSE(
  [AC_LANG_PROGRAM([[#pragma once]])],
  [
    AC_MSG_RESULT([yes])
    AC_DEFINE([HAVE_PRAGMA_ONCE], [1], [Preprocessor support for #pragma once])
  ],
[AC_MSG_RESULT([no])])

AX_OPENMP([], [with_openmp="no"])
AM_CONDITIONAL([HAVE_OPENMP], [test "$with_openmp" != "no"])
AC_SUBST(OPENMP_CXXFLAGS)



##############################
# Program Support and Features
##############################
#################
## Wide Character
#################
AC_CHECK_HEADER([wchar.h],,[AC_MSG_FAILURE([aegisub requires wide character support])])


#########
## OpenGL
#########
AX_CHECK_GL
if test "x$GL_LIBS" = "x"; then
	AC_MSG_FAILURE([aegisub requires GL support.])
fi
AC_SUBST(GL_CFLAGS)
AC_SUBST(GL_LIBS)


#XXX: This needs to be fixed for OSX.
AC_AGI_COMPILE([OpenGL], [opengl], [$GL_CFLAGS], [$GL_LIBS],[
int main(void) {
  return 0;
}])

if test "$agi_cv_with_opengl" = "no"; then
	AC_MSG_FAILURE([Please install a working OpenGL library.])
fi

AC_AGI_COMPILE([OpenGLU], [openglu], [$GL_CFLAGS], [$GL_LIBS -lGLU],[
#include <GL/glu.h>
int main(void) {
  return 0;
}])

if test "$agi_cv_with_openglu" = "no" && test "$build_darwin" != "yes"; then
	AC_MSG_FAILURE([Please install a working OpenGL GLU library.])
fi


###########
## Freetype
###########
PKG_CHECK_MODULES(FREETYPE, freetype2 >= freetype_required_version,
  AC_DEFINE(WITH_FREETYPE2, 1, [Enable FreeType 2 support.]),
  [AC_MSG_FAILURE([aegisub requires >= FreeType2 freetype_required_version])])

AC_AGI_COMPILE([Freetype], [freetype], [$FREETYPE_CFLAGS], [$FREETYPE_LIBS],[
#include <ft2build.h>
#include FT_FREETYPE_H
int main(void) {
  FT_Library ft;
  if (FT_Init_FreeType(&ft)) { return 1; }
  return 0;
}])

if test "$agi_cv_with_freetype" = "no"; then
    AC_MSG_FAILURE([Please install a working Freetype library.])
fi


#############
## Fontconfig
#############
PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= fontconfig_required_version)

AC_AGI_COMPILE([FontConfig], [fontconfig], [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS],[
#include <fontconfig/fontconfig.h>
int main(void) {
  int fc = FcInit();
  FcConfig* config;
  config = FcConfigGetCurrent();
  if ((!config) || (!fc)) { return 1;}
  return 0;
}])

if test "$agi_cv_with_fontconfig" = "no"; then
    AC_MSG_FAILURE([Please install a working Fontconfig library.])
fi

AC_DEFINE(WITH_FONTCONFIG, 1, [Enable FontConfig support.])
AC_SUBST(FONTCONFIG_CFLAGS)
AC_SUBST(FONTCONFIG_LIBS)



########
## iconv
########
AC_ARG_VAR([ICONV_CFLAGS], [CFLAGS to use for iconv (default: CPPFLAGS)])
AC_ARG_VAR([ICONV_LIBS], [LIBS to use for iconv (default: LIBS -liconv)])

if test -z "$ICONV_LIBS"; then
  if test "$build_linux" = "yes"; then
    ICONV_LIBS="$LIBS"
  else
    ICONV_LIBS="$LIBS -liconv";
  fi
fi

if test -z "$ICONV_CFLAGS"; then
  ICONV_CFLAGS="$CPPFLAGS"; # I don't get this. Why CPPFLAGS? I would understand CFLAGS and even CXXFLAGS, but why CPPFLAGS? -Fluff
fi

  AC_AGI_COMPILE([iconv], [iconv], [$ICONV_CFLAGS], [$ICONV_LIBS],[
#include <iconv.h>
int main(void) {
  iconv_t ic;
  ic = iconv_open ("UTF-8", "UTF-8");
  if (!ic) return 1;
  return 0;
} ])

AC_SUBST(ICONV_LIBS)
AC_SUBST(ICONV_CFLAGS)



###############
# Audio Players
###############
#######
## ALSA
#######
AC_ARG_WITH(alsa, [  --without-alsa          build without ALSA audio provider. (default: auto)],[],[with_alsa="auto";alsa_disabled="(autodetected)"])

AC_ARG_VAR([ALSA_CFLAGS], [CFLAGS to use for ALSA (default: CPPFLAGS)])
AC_ARG_VAR([ALSA_LIBS], [LIBS to use for ALSA (default: -lasound -lrt)])

AS_IF([test "x$with_alsa" != "xno"],[
  if test -z "$ALSA_LIBS"; then
    ALSA_LIBS="-lasound -lrt";
  fi

  if test -z "$ALSA_CFLAGS"; then
    ALSA_CFLAGS="$CPPFLAGS"; # I don't get this. Why CPPFLAGS? I would understand CFLAGS and even CXXFLAGS, but why CPPFLAGS? -Fluff
  fi

  aegisub_save_LIBS="$LDFLAGS"
  LIBS="$ALSA_LIBS"
  AC_CHECK_LIB([asound], [snd_pcm_open], [
    ALSA_LIBS="-lasound -lrt"
    with_alsa="yes"
  ], [
    AS_IF([test "x$with_alsa" != "xauto"],[
      AC_MSG_FAILURE([ALSA was specified as required, but was not detected.])
    ],[])
    with_alsa="no"
  ])
  LIBS="$aegisub_save_LIBS"
],[
  alsa_disabled="(disabled)"
])

AS_IF([test "x$with_alsa" = "xyes"],[
  AC_DEFINE(WITH_ALSA, 1, [Enable ALSA Support])
  found_audio_player="yes"
],[])

AM_CONDITIONAL([HAVE_ALSA], [test "$with_alsa" != "no"])
AC_SUBST(ALSA_LIBS)


############
## PortAudio
############

AC_ARG_WITH(portaudio,[  --without-portaudio     build without PortAudio v19 audio provider.
                          (default: auto)],[],[with_portaudio="auto";portaudio_disabled="(autodetected)"])

AS_IF([test "x$with_portaudio" != "xno"],[
  PKG_CHECK_MODULES(PORTAUDIO, portaudio-2.0 >= portaudio_required_version, [
    with_portaudio="yes"
  ], [
    AS_IF([test "x$with_portaudio" != "xauto"],[
      AC_MSG_FAILURE([PortAudio was specified as required, but was not detected.])
    ],[])
    with_portaudio="no"
  ])
],[
  portaudio_disabled="(disabled)"
])

AS_IF([test "$with_portaudio" = "yes"],[
  AC_DEFINE(WITH_PORTAUDIO, 1, [Enable PortAudio v19 support])
  found_audio_player="yes"
],[])

AM_CONDITIONAL([HAVE_PORTAUDIO], [test "$with_portaudio" != "no"])


#############
## PulseAudio
#############

AC_ARG_WITH(pulseaudio,[  --with-pulseaudio       build with PulseAudio audio provider.
                          (default: auto)],[],[with_pulseaudio="auto";pulseaudio_disabled="(autodetected)"])

AS_IF([test "x$with_pulseaudio" != "xno"],[
  PKG_CHECK_MODULES(LIBPULSE, libpulse >= pulseaudio_required_version, [
    with_pulseaudio="yes"
  ], [
    AS_IF([test "x$with_pulseaudio" != "xauto"],[
      AC_MSG_FAILURE([PulseAudio was specified as required, but was not detected.])
    ],[])
    with_pulseaudio="no"
  ])
],[
  pulseaudio_disabled="(disabled)"
])

AS_IF([test "x$with_pulseaudio" = "xyes"],[
  AC_DEFINE(WITH_PULSEAUDIO, 1, [Enable PulseAudio support])
  found_audio_player="yes"
],[])

AM_CONDITIONAL([HAVE_PULSEAUDIO], [test "$with_pulseaudio" != "no"])


#########
## OpenAL
#########
AC_ARG_WITH(openal,[  --without-openal        build without OpenAL audio provider.
                          (default: auto)],[],[with_openal="auto";openal_disabled="(autodetected)"])

AS_IF([test "x$with_openal" != "xno"],[
  PKG_CHECK_MODULES(OPENAL, openal >= 0.0.8, [
    with_openal=yes
  ], [
    AS_IF([test "x$with_openal" != "xauto"],[
      AC_MSG_FAILURE([OpenAL was specified as required, but was not detected.])
    ],[])
    with_openal=no
  ])
],[
  openal_disabled="(disabled)"
])

AS_IF([test "x$with_openal" = "xyes"],[
  AC_DEFINE(WITH_OPENAL, 1, [Enable OpenAL support])
  found_audio_player="yes"
],[])

AM_CONDITIONAL([HAVE_OPENAL], [test "$with_openal" != "no"])


######
## OSS
######
AC_ARG_WITH(oss,[  --without-oss           build without OSS audio provider.
                          (default: auto)],[],[with_oss="auto";oss_disabled="(autodetected)"])

found_oss="no"
AS_IF([test "x$with_oss" != "xno"],[
  AS_IF([test -f "/etc/oss.conf"],[
    . /etc/oss.conf
    CPPFLAGS="$CPPFLAGS -I${OSSLIBDIR}/include/sys"
  ],[])
  AC_CHECK_HEADERS([soundcard.h sys/soundcard.h], [
    found_oss="yes"
  ])
],[
  oss_disabled="(disabled)"
])

AS_IF([test "x$found_oss" != "xyes" && test "x$with_oss" = "xyes"],[
  AC_MSG_FAILURE([OSS support was specified as required, but was not detected.])
],[])
with_oss="$found_oss"

AS_IF([test "x$with_oss" != "xno"],[
  AC_DEFINE(WITH_OSS, 1, [Enable OSS support])
  found_audio_player="yes"
],[])

AM_CONDITIONAL([HAVE_OSS], [test "$with_oss" != "no"])


#########################
# Video / Audio Providers
#########################


AC_ARG_WITH(ffms,[  --without-ffms          disable FFmpegSource support (default: auto)],[],[with_ffms="auto";ffms_provider_disabled="(autodetected)"])

AS_IF([test "x$with_ffms" != "xno"],[
  PKG_CHECK_MODULES(FFMS, ffms2 >= ffms_required_version, [
    with_ffms="yes"
  ], [
    AS_IF([test "x$with_ffms" != "xauto"],[
      AC_MSG_FAILURE([FFmpegSource was specified as required, but was not detected.])
    ],[])
    with_ffms="no"
  ])
],[
  ffms_provider_disabled="(disabled)"
])

AS_IF([test "x$with_ffms" = "xyes"],[
  AC_DEFINE(WITH_FFMPEGSOURCE, 1, [Enable FFmpegSource2 video provider])
  found_video_provider="yes"
],[
  with_ffms="no"
])

AM_CONDITIONAL([HAVE_PROVIDER_FFMPEGSOURCE], [test "$with_ffms" = "yes"])

AC_SUBST(FFMS_CFLAGS)


###################
# Subtitle Provider
###################

AC_ARG_WITH(libass, [  --without-libass        disable libass support (default=auto)],[],[with_libass="auto";libass_disabled="(autodetected)"])

AS_IF([test "x$with_libass" != "xno"],[
  PKG_CHECK_MODULES(LIBASS, libass >= libass_required_version, [
    with_libass="yes"
  ], [
    AS_IF([test "x$with_libass" != "xauto"],[
      AC_MSG_FAILURE([libass was specified as required, but was not detected.])
    ],[])
    with_libass="no"
  ])
],[
  libass_disabled="(disabled)"
])

AS_IF([test "x$with_libass" = "xyes"],[
  AC_DEFINE(WITH_LIBASS, 1, [Enable libass Subtitle Provider])
],[
  with_libass="no"
])

AM_CONDITIONAL([WITH_LIBASS], [test "$with_libass" = "yes"])
AC_SUBST(LIBASS_LIBS)
AC_SUBST(LIBASS_CFLAGS)



###########
## Hunspell
###########
AC_ARG_WITH(hunspell, [  --without-hunspell      build without hunspell support (default: auto)],[],[with_hunspell="auto";hunspell_disabled="(autodetected)"])

AS_IF([test "x$with_hunspell" != "xno"],[
  PKG_CHECK_MODULES(HUNSPELL, hunspell >= 1.2.0, [
    with_hunspell="yes"
  ], [
    AS_IF([test "x$with_hunspell" != "xauto"],[
      AC_MSG_FAILURE([hunspell was specified as required, but was not detected.])
    ],[])
    with_hunspell="no"
  ])
],[
  hunspell_disabled="(disabled)"
])

AS_IF([test "x$with_hunspell" = "xyes"],[
  AC_DEFINE(WITH_HUNSPELL, 1, [Enable Hunspell support.])
],[])

AM_CONDITIONAL([HAVE_HUNSPELL], [test "$with_hunspell" != "no"])



######################
## universalchardetect
######################
AC_ARG_ENABLE(univchardet, [  --disable-univchardet   disble universalchardet support.],[],[univchardet_disabled="(default)"])
if test "$enable_univchardet" != "no"; then
  with_univchardet="yes"
  AC_DEFINE(WITH_UNIVCHARDET, 1, [Enable universalchardet support])
else
  with_univchardet="no"
  univchardet_disabled="(disabled)"
fi
AM_CONDITIONAL([HAVE_UNIVCHARDET], [test "$with_univchardet" != "no"])




############
# Automation
############

############
## Auto4 LUA
############

AC_ARG_WITH(lua,
[  --without-lua           build without lua 5.1 (auto4)],[],[with_lua="auto";lua51_disabled="(autodetected)"])

AC_ARG_VAR([LUA_CFLAGS], [CFLAGS to use for LUA 5.1 (default: autodetect)])
AC_ARG_VAR([LUA_LDFLAGS], [LDFLAGS to use for LUA 5.1 (default: autodetect)])
AC_ARG_VAR([LUA_LIBDIR], [Location of LUA 5.1 library. (default: none)])

AS_IF([test "x$with_lua" != "xno"],[
  if test -z "$LUA_CFLAGS"; then
    AGI_FIND_HEADER([LUA], [lua.hpp], [/usr/include/lua5.1 /usr/include/lua51 /usr/local/include/lua51 /usr/local/include/lua5.1 /usr/include /usr/local/include])
  fi

  if test -z "$LUA_LDFLAGS"; then
    AGI_FIND_LIB([LUA], [lua51 lua-5.1 lua5.1 lua], [$LUA_LIBDIR])
  fi

  aegisub_save_LIBS="$LIBS"
  LIBS="$LUA_LDFLAGS"
  AC_AGI_COMPILE([Lua 5.1 (auto4)], [lua], [$LUA_CFLAGS], [$LUA_LDFLAGS],[
#include <lua.hpp>

int main () {
  lua_State *L = luaL_newstate();
  lua_pushstring(L, "test");
  int res = lua_objlen(L, -1) == 4;
  lua_close(L);
  return !res;
}])
  LIBS="$aegisub_save_LIBS"

  AS_IF([test "x$agi_cv_with_lua" = "xyes"],[
    with_auto4="yes"
    with_automation="yes"
    AC_DEFINE(WITH_AUTO4_LUA, 1, [Enable Automation (auto4), requires Lua 5.1])
  ],[
    AS_IF([test "x$with_lua" != "xauto"],[
      AC_MSG_FAILURE([Lua 5.1 support was specified as required, but was not detected.])
    ],[])
    with_auto4="no"
  ])
],[
  lua51_disabled="(disabled)"
])

AM_CONDITIONAL([HAVE_AUTO4_LUA], [test "$with_auto4" != "no"])
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_LDFLAGS)


##################
## Auto3 (LUA 5.0)
##################

AC_ARG_WITH(lua50,
[  --without-lua50         build without lua 5.0 (auto3)],[],[with_lua50="auto";lua50_disabled="(autodetected)"])

AC_ARG_VAR([LUA50_CFLAGS], [CFLAGS to use for LUA 5.1 (default: autodetect)])
AC_ARG_VAR([LUA50_LDFLAGS], [LDFLAGS to use for LUA 5.1 (default: autodetect)])
AC_ARG_VAR([LUA50_LIBDIR], [Location of LUA 5.1 library. (default: none)])

AS_IF([test "x$with_lua50" != "xno"],[
  if test -z "$LUA50_CFLAGS"; then
    AGI_FIND_HEADER([LUA50], [lua.h], [/usr/include/lua5.0 /usr/include/lua50 /usr/local/include/lua50 /usr/local/include/lua5.0 /usr/include /usr/local/include])
  fi

  if test -z "$LUA50_LDFLAGS"; then
    AGI_FIND_LIB([LUA50], [lua50 lua-5.0 lua5.0 lua], [$LUA50_LIBDIR])
    AGI_FIND_LIB([LUALIB50], [lualib50 lualib-5.0 lualib5.0 lualib], [$LUA50_LIBDIR], [$LUA50_LDFLAGS])
  fi

  AC_AGI_COMPILE([Lua 5.0 (auto3)], [lua50], [$LUA50_CFLAGS], [$LUA50_LDFLAGS $LUALIB50_LDFLAGS],[
extern "C" {
#include "lua.h"
#include "lauxlib.h"
}
#ifdef lua_open
#error This is not Lua 5.0
#endif
int main() {
  lua_State *L = lua_open();
  if (!L) return 1;
  luaL_newmetatable(L, "test");
  lua_close(L);
}])

  AS_IF([test "x$agi_cv_with_lua50" = "xyes"],[
    with_auto3="yes"
    with_automation="yes"
    AC_DEFINE(WITH_AUTO3, 1, [Enable Automation (auto3, DEPRECATED!), requires lua 5.0])
  ],[
    AS_IF([test "x$with_lua50" != "xauto"],[
      AC_MSG_FAILURE([Lua 5.0 support was specified as required, but was not detected.])
    ],[])
    with_auto3="no"
  ])
],[
  lua50_disabled="(disabled)"
])

AM_CONDITIONAL([HAVE_AUTO3_LUA], [test "$with_auto3" != "no"])
AC_SUBST(LUA50_CFLAGS)
AC_SUBST(LUA50_LDFLAGS)
AC_SUBST(LUALIB50_LDFLAGS)



#############
## Auto4 PERL
#############
AC_ARG_WITH(perl, [  --with-perl             build with PERL Automation. (default: no)],[],[with_perl="auto";perl_disabled="(default)"])
AC_ARG_WITH(perl-bin, [  --with-perl-bin=PATH    location of PERL binary. (default: $PATH)], [WITH_PERL_BIN="$withval"])

AC_ARG_VAR([PERL_CFLAGS], [CFLAGS to use for Perl (default: -MExtUtils::Embed -eccflags -eperl_inc)])
AC_ARG_VAR([PERL_LDFLAGS], [LDFLAGS to use for Perl (default: -MExtUtils::Embed -eldopts)])

if test "$with_perl" = "yes"; then
  if test -z "$WITH_PERL_BIN"; then
    AC_PATH_PROG([PERL_BIN],perl,no)
  else
    PERL_BIN="$WITH_PERL_BIN"
  fi

  if test "$PERL_BIN" != "no"; then
    AC_CACHE_CHECK(
      [checking for perl version >= perl_required_version], [with_cv_perl],
      [if $PERL_BIN -e 'require perl_required_version'; then with_cv_perl="yes"; else with_cv_perl="no"; fi])

    if test "$with_cv_perl" = "yes"; then
      AC_MSG_CHECKING([$PERL_BIN cflags])
      if test -z "$PERL_CFLAGS"; then
        PERL_CFLAGS=`$PERL_BIN -MExtUtils::Embed -eccflags -eperl_inc`
      fi
      AC_MSG_RESULT([$PERL_CFLAGS])

      AC_MSG_CHECKING([$PERL_BIN libs])
      if test -z "$PERL_LDFLAGS"; then
        PERL_LDFLAGS=`$PERL_BIN -MExtUtils::Embed -eldopts`
      fi
      AC_MSG_RESULT([$PERL_LDFLAGS])

      AC_AGI_COMPILE([Perl], [perl], [$PERL_CFLAGS], [$PERL_LDFLAGS],[
#include <EXTERN.h>
#include <perl.h>
int main(int argc, char **argv, char **env) {
  static PerlInterpreter *my_perl;
  PERL_SYS_INIT3(&argc,&argv,&env);
  my_perl = perl_alloc();
  if (!my_perl) return 1;
  return 0;
}])
    fi
  fi
elif test "x$with_perl" = "xno"; then
  perl_disabled="(disabled)"
fi

if test "$agi_cv_with_perl" = "no" && test "$with_cv_perl" = "yes"; then
  AC_MSG_FAILURE([Perl detected, but it doesn't work...])
fi

if test "$agi_cv_with_perl" = "yes" && test "$with_cv_perl" = "yes"; then
  with_automation="yes"
  AC_DEFINE(WITH_PERL, 1, [Enable PERL support.])
else
  with_cv_perl="no"
fi

AM_CONDITIONAL([HAVE_AUTO4_PERL], [test "$with_cv_perl" = "yes"])
AC_SUBST(PERL_CFLAGS)
AC_SUBST(PERL_LDFLAGS)

AC_ARG_ENABLE(perl-console, [  --disable-perl-console  disable PERL console (default=enabled)],perlconsole_disabled="(disabled)")
  
if test "$with_cv_perl" = "yes" && test "$enable_perlconsole" != "no"; then
  AC_DEFINE(WITH_PERLCONSOLE, 1, [Enable PERL Console support (for debugging purposes)])
fi



#############
## Auto4 Ruby
#############
AC_ARG_WITH(ruby, [  --with-ruby             build with Ruby Automation. (default: no)],[],[with_ruby="auto";ruby_disabled="(default)"])
AC_ARG_WITH(ruby-bin, [  --with-ruby-bin=PATH    location of RUBY binary. (default: $PATH)], [WITH_RUBY_BIN="$withval"])

AC_ARG_VAR([RUBY_CFLAGS], [CFLAGS to use for Ruby (default: Config::CONFIG archdir + CFLAGS)])
AC_ARG_VAR([RUBY_LDFLAGS], [LDFLAGS to use for Ruby (default: Cofig::CONFIG LIBRUBYARG)])

if test "$with_ruby" = "yes"; then
  if test -z "$WITH_RUBY_BIN"; then
    AC_PATH_PROG([RUBY_BIN],ruby,no)
  else
    RUBY_BIN="$WITH_RUBY_BIN"
  fi


  if test "$RUBY_BIN" != "no"; then
    AC_CACHE_CHECK(
      [checking for ruby version >= ruby_required_version], [with_cv_ruby],
      [if $RUBY_BIN -r rbconfig -e 'if Config::CONFIG@<:@"ruby_version"@:>@.to_f >= ruby_required_version  then exit(0) else exit(1) end'; then
        with_cv_ruby="yes"; else with_cv_ruby="no"; fi])

    if test "$with_cv_ruby" = "yes"; then
      AC_MSG_CHECKING([checking $RUBY_BIN -r rbconfig archdir, cflags])
      if test -z "$RUBY_CFLAGS"; then
        RUBY_CFLAGS=`$RUBY_BIN -r rbconfig -e "printf(\"-I%s %s\", Config::CONFIG@<:@'archdir'@:>@, Config::CONFIG@<:@'CFLAGS'@:>@)"`
      fi
      AC_MSG_RESULT([$RUBY_CFLAGS])

      AC_MSG_CHECKING([checking $RUBY_BIN rbconfig libs])
      if test -z "$RUBY_LDFLAGS"; then
        RUBY_LDFLAGS=`$RUBY_BIN -r rbconfig -e "print Config::CONFIG@<:@'LIBRUBYARG'@:>@"`
      fi
      AC_MSG_RESULT([$RUBY_LDFLAGS])

      AC_AGI_COMPILE([Ruby], [ruby], [$RUBY_CFLAGS], [$RUBY_LDFLAGS],[
#include <ruby.h>
int main(void) {
  /* These supposidly call exit if they fail. */   
  ruby_init();
  ruby_init_loadpath();
  return 0;
}])
    fi
  fi
elif test "x$with_ruby" = "xno"; then
  ruby_disabled="(disabled)"
fi

if test "$agi_cv_with_ruby" = "no" && test "$with_cv_ruby" = "yes"; then
  AC_MSG_FAILURE([Ruby detected, but it doesn't work...])
  with_cv_ruby="no"
fi

if test "$agi_cv_with_ruby" = "yes" && test "$with_cv_ruby" = "yes"; then
  with_automation="yes"
  AC_DEFINE(WITH_RUBY, 1, [Enable RUBY Automation.])
else
  with_cv_ruby="no"
fi

AM_CONDITIONAL([HAVE_AUTO4_RUBY], [test "$with_cv_ruby" != "no"])
AC_SUBST(RUBY_CFLAGS)
AC_SUBST(RUBY_LDFLAGS)


# Automation setup
if test "$with_automation" = "yes"; then
  AC_DEFINE(WITH_AUTOMATION, 1, [Enable Automation support, requires any automation language.])
fi  
AM_CONDITIONAL([HAVE_AUTOMATION], [test "$with_automation" = "yes"])



################
# Widget support
################
AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(wx_required_version, [have_wxconfig="yes"], [have_wxconfig="no"], [std,gl,stc], [--unicode])

if test "$have_wxconfig" = "no"; then
  AC_MSG_FAILURE([wxWidgets detection failed, please set --with-wx* or add the libraries to your LDFLAGS, CXX/CFLAGS.])
fi

AC_ARG_ENABLE(check-wx-opengl, [  --disable-check-wx-opengl
                          Force wxwidgets OpenGL support. ])

if test "$enable_check_wx_opengl" != "no"; then
  AC_AGI_LINK([wxWidgets OpenGL support], [wxopengl], [wx/glcanvas.h], [$GL_CFLAGS $WX_CFLAGS], [$GL_LIBS $WX_LIBS],[
#include <wx/glcanvas.h>
int main(void) {
  wxGLCanvas *canvas;
  wxGLContext *context;
  return 0;
} ])
fi

if test "$with_agi_cv_wxopengl" = "no" || test "$enable_check_wx_opengl" = "yes"; then
  AC_MSG_FAILURE([wxWidgets OpenGL support missing])
fi


AC_ARG_ENABLE(check-wx-stc, [  --disable-check-wx-stc  Force wxwidgets StyledTextCtrl support.])

if test "$enable_check_wx_stc" != "no"; then
  AC_AGI_LINK([wxWidgets StyledTextCtrl support], [wxstc], [wx/stc/stc.h], [$WX_CFLAGS], [$WX_LIBS],[
#include <wx/stc/stc.h>
int main(void) {
  wxStyledTextCtrl *canvas;
  return 0;
} ])
fi

if test "$with_agi_cv_wxstc" = "no" || test "$enable_check_wx_stc:" = "yes"; then
  AC_MSG_FAILURE([wxWidgets StyledTextCtrl support missing])
fi


############################
# Precompiled Header Support
# Only works with gcc!
############################

AC_MSG_CHECKING([whether to use precompiled headers])
AC_ARG_ENABLE(gcc-prec, [  --enable-gcc-prec       enable GCC precompiled headers (default=auto)],[],[enable_gcc_prec="auto"])
if test "x$enable_gcc_prec" != "xno"; then
  enable_gcc_prec="yes"
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
fi
AM_CONDITIONAL([PRECOMPILED_HEADER], [test "$enable_gcc_prec" = "yes"])


######################################################
# Debugging support
# This is added last so it doesn't slow down configure
# If you want it earlier add it to your CXXFLAGS.
######################################################

AC_ARG_VAR([DEBUG_FLAGS], [Debug flag to use with --enable-debug (default: -g)])

AC_MSG_CHECKING([whether to turn on debugging])
AC_ARG_ENABLE(debug, [  --enable-debug          enable debugging (default=no)])
if test "$enable_debug" = "yes"; then
  if test -z "$DEBUG_FLAGS"; then
    DEBUG_FLAGS="-g";
  fi

  AC_MSG_RESULT([yes ($DEBUG_FLAGS)])
  CPPFLAGS="$DEBUG_FLAGS $CPPFLAGS"
  msg_debug="($DEBUG_FLAGS)"

  # This turns on some internal (to aegisub) debugging features.
  # A debug version of wxWidgets is required.
  if $WX_CONFIG_PATH --debug; then
    AC_CXX_FLAG([-D_DEBUG])
  fi
else
  enable_debug="no"
  AC_MSG_RESULT([no])
fi
AC_SUBST(DEBUG_FLAGS)

if test "$enable_debug" = "yes"; then
  PACKAGE_DEBUG="-debug"
fi
AC_SUBST(PACKAGE_DEBUG)


AC_MSG_CHECKING([whether to use exception handling in debug mode])
AC_ARG_ENABLE(debug-exceptions, [  --enable-debug-exceptions
                          enable exception handling in debug mode (default=no)])
if test "$enable_debug_exceptions" = "yes"; then
  AC_DEFINE(WITH_EXCEPTIONS, 1, [Enable exception handling in debug mode. (--enable-debug)  This is always enabled when debug mode is off.])
  AC_MSG_RESULT([yes])
else
  AC_MSG_RESULT([no])
fi


###########
# Profiling
###########

AC_ARG_VAR([PROFILE_FLAGS], [Profile flag(s) to use with --enable-profile (default: -pg)])

AC_MSG_CHECKING([whether to turn on profiling])
AC_ARG_ENABLE(profile, [  --enable-profile        enable profiling (default=no)])
if test "$enable_profile" = "yes"; then
  if test -z "$PROFILE_FLAGS"; then
    PROFILE_FLAGS="-pg";
  fi
  AC_MSG_RESULT([yes ($PROFILE_FLAGS)])
  CPPFLAGS="$PROFILE_FLAGS $CPPFLAGS"
else
  enable_profile="no"
  AC_MSG_RESULT([no])
fi


######
# gcov
######

AC_ARG_VAR([GCOV_FLAGS], [gcov flag(s) to use with --enable-gcov (default: -ftest-coverage -fprofile-arcs)])

AC_MSG_CHECKING([whether to turn on gcov])
AC_ARG_ENABLE(gcov, [  --enable-gcov           enable gcov (default=no)])

if test "$enable_gcov" = "yes"; then
  if test -z "$GCOV_FLAGS"; then
    GCOV_FLAGS="-fprofile-arcs -ftest-coverage";
  fi
  AC_MSG_RESULT([yes ($GCOV_FLAGS)])
  CFLAGS="$CFLAGS $GCOV_FLAGS"
  CPPFLAGS="$CPPFLAGS $GCOV_FLAGS"
else
  enable_gcov="no"
  AC_MSG_RESULT([no])
fi



################
# Electric Fence
################

AC_ARG_VAR([EFENCE_LDFLAGS], [Electric Fence ldflag(s) to use with --enable-profile (default: -lefence)])

AC_MSG_CHECKING([whether to turn on Electric Fence])
AC_ARG_ENABLE(efence, [  --enable-efence         enable Electric Fence (default=no)])
if test "$enable_efence" = "yes"; then
  if test -z "$EFENCE_LDFLAGS"; then
    EFENCE_LDFLAGS="-lefence";
  fi
  AC_MSG_RESULT([yes ($EFENCE_LDFLAGS)])
else
  enable_efence="no"
  AC_MSG_RESULT([no])
fi
AC_SUBST(EFENCE_LDFLAGS)

##########
# ccmalloc
##########

AC_ARG_VAR([CCMALLOC_LIBS], [ccmalloc libs(s) to use with --enable-ccmalloc (default: $prefix/lib/ccmalloc-c++.o)])
AC_ARG_VAR([CCMALLOC_LDFLAGS], [ccmalloc ldflag(s) to use with --enable-ccmalloc (default: -lccmalloc)])

AC_MSG_CHECKING([whether to turn on ccmalloc])
AC_ARG_ENABLE(ccmalloc, [  --enable-ccmalloc       enable ccmalloc (default=no)])
if test "$enable_ccmalloc" = "yes"; then
  if test -z "$CCMALLOC_LIBS"; then
    CCMALLOC_LIBS="$prefix/lib/ccmalloc-c++.o";
  fi

  if test -z "$CCMALLOC_LDFLAGS"; then
    CCMALLOC_LDFLAGS="-lccmalloc";
  fi
  AC_MSG_RESULT([yes ($CCMALLOC_LIBS $CCMALLOC_LDFLAGS)])
else
  enable_ccmalloc="no"
  AC_MSG_RESULT([no])
fi
AC_SUBST(CCMALLOC_LDFLAGS)
AC_SUBST(CCMALLOC_LIBS)

if test "$enable_efence" = "yes" && test "$enable_ccmalloc" = "yes"; then
  AC_MSG_FAILURE([Please enable Electric Fence _or_ ccmalloc otherwise strange things will happen.])
fi  


##############################
# Internationalisation support
##############################
AC_PROG_INTLTOOL
AM_GLIB_GNU_GETTEXT

if test "$build_darwin" = "yes"; then
  GETTEXT_PACKAGE="aegisub"
else
  GETTEXT_PACKAGE="aegisub${AEGISUB_VERSION_MAJOR}${AEGISUB_VERSION_MINOR}"
fi

AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
                   [The basename for our gettext translation domains.])


####################################################################
# Default settings for Providers/Players
# * This is done at the end to preserve sanity rather than littering
#   it above.
####################################################################

AC_ARG_WITH(provider-video, [  --with-provider-video=(ffmpegsource)
                          Default Video Provider. (default: ffmpegsource)])
AC_ARG_WITH(provider-audio, [  --with-provider-audio=(ffmpegsource)
                          Default Audio Provider. (default: ffmpegsource)])
AC_ARG_WITH(player-audio, [  --with-player-audio=(alsa|openal|portaudio|pulseaudio)
                          Default Audio Player (default: Linux/ALSA,
                          Darwin/OpenAL, */PortAudio.])

# Default Video Provider.
if ! test -z "$with_provider_video"; then
    default_provider_video="$with_provider_video"
else
  if test "$with_ffms" = "yes"; then
    default_provider_video="ffmpegsource"
  fi
fi
AC_DEFINE_UNQUOTED([DEFAULT_PROVIDER_VIDEO], ["$default_provider_video"], [Default Video Provider.])

# Default Audio Provider.
if ! test -z "$with_provider_audio"; then
    default_provider_audio="$with_provider_audio"
else
  if test "$with_ffms" = "yes"; then
    default_provider_audio="ffmpegsource"
  fi
fi
AC_DEFINE_UNQUOTED([DEFAULT_PROVIDER_AUDIO], ["$default_provider_audio"], [Default Video Provider.])

# Default Subtitle Provider.
if ! test -z "$with_provider_subtitle"; then
    default_provider_subtitle="$with_provider_subtitle"
else
  if test "$with_libass" = "yes"; then
    default_provider_subtitle="libass"
  fi
fi
AC_DEFINE_UNQUOTED([DEFAULT_PROVIDER_SUBTITLE], ["$default_provider_subtitle"], [Default Subtitle Provider.])

# Default audio player.
if ! test -z "$with_player_audio"; then
    default_player_audio="$with_player_audio"
else
  if test "$with_alsa" = "yes"; then
    default_player_audio="alsa"
  elif test "$with_pulseaudio" = "yes"; then
    default_player_audio="pulseaudio"
  elif test "$with_openal" = "yes"; then
    default_player_audio="openal"
  elif test "$with_oss" = "yes"; then
    default_player_audio="oss"
  elif test "$with_portaudio" = "yes"; then
    default_player_audio="portaudio"
  fi
fi
AC_DEFINE_UNQUOTED([DEFAULT_PLAYER_AUDIO], ["$default_player_audio"], [Default audio player.])


# Set some friendly strings if some of the above aren't detected.
if test -z "$default_provider_video"; then
  default_provider_video="NONE"
fi

if test -z "$default_provider_audio"; then
  default_provider_audio="NONE"
fi

if test -z "$default_provider_subtitle"; then
  default_provider_subtitle="NONE"
fi

if test -z "$default_player_audio"; then
  default_player_audio="NONE"
fi




###############
# Misc settings 
###############
AM_CONDITIONAL([FOUND_AUDIO_PLAYER], [test "$found_audio_player" = "yes"])
AM_CONDITIONAL([FOUND_VIDEO_PROVIDER], [test "$found_video_provider" = "yes"])


# Makefiles
AC_CONFIG_FILES([
Makefile
src/Makefile
src/bitmaps/Makefile
src/libresrc/Makefile
src/libauto3/Makefile
src/libosxutil/Makefile
universalchardet/Makefile
automation/Makefile
po/Makefile.in
desktop/Makefile
])

# Files that need substitution.
AC_CONFIG_FILES([
desktop/aegisub.desktop
scripts/osx-bundle.sed
])

AC_OUTPUT

if test -z "$found_audio_player"; then
  AC_MSG_NOTICE([

***********************************************************************
* No supported audio player interface was found on your system.
* If you want audio support in Aegisub you need to install one of
* these libraries:
*  - PulseAudio
*    * http://pulseaudio.org/
*  - ALSA (Linux only) (Currently broken)
*    * http://www.alsa-project.org/
*  - PortAudio (version 18 only, version 19 is not compatible)
*    * http://www.portaudio.com/
***********************************************************************
  ])
fi

if test -z "$found_video_provider"; then
  AC_MSG_NOTICE([

***********************************************************************
* No supported video/audio reader interface was found on your system.
* You will not be able to open any video or audio files in Aegisub
* unless you install a supported video/audio provider.
* You will however still be able to open "dummy" video, ie. a blank,
* virtual video clip with subtitles overlaid.
* Currently we only support one video/audio provider on non-Windows
* systems:
*  - FFmpegSource
*    * http://code.google.com/p/ffmpegsource/
***********************************************************************
  ])
fi

AC_MSG_RESULT([
Configure settings
  Install prefix:        $prefix
  SVN Revision:          $SVN_REVISION
  Debug                  $enable_debug $msg_debug
  CXXFLAGS               $CXXFLAGS
  CPPFLAGS               $CPPFLAGS
  LDFLAGS                $LDFLAGS

Default Settings
  Video Provider:        $default_provider_video
  Audio Provider:        $default_provider_audio
  Subtitle Provider:     $default_provider_subtitle
  Audio Player:          $default_player_audio

Scripting Engines
  auto3 Lua:             $with_auto3 $lua50_disabled
  auto4 Lua:             $with_auto4 $lua51_disabled
  auto4 Perl:            $with_cv_perl $perl_disabled
  auto4 Ruby:            $with_cv_ruby $ruby_disabled

Audio Players
  ALSA:                  $with_alsa $alsa_disabled
  OpenAL:                $with_openal $openal_disabled
  OSS:                   $with_oss $oss_disabled
  PortAudio:             $with_portaudio $portaudio_disabled
  PulseAudio:            $with_pulseaudio $pulseaudio_disabled

A/V Providers
  FFmpegSource:          $with_ffms $ffms_provider_disabled

Subtitle Providers:
  libASS                 $with_libass $libass_disabled $libass_default

Misc Packages
  Hunspell:              $with_hunspell $hunspell_disabled
  universalchardet:      $with_univchardet $univchardet_disabled
]);
