# configure.in - HTML TidyLib GNU autoconf input file
#
# Copyright (c) 2003-2004 World Wide Web Consortium
# (Massachusetts Institute of Technology, European Research 
# Consortium for Informatics and Mathematics, Keio University).
# All Rights Reserved.
#
# CVS Info :
#
#   $Author: arnaud02 $ 
#   $Date: 2008/03/24 21:08:16 $ 
#   $Revision: 1.4 $ 
#

AC_INIT([include/tidy.h])

# Making releases:
# 
#   TIDY_MICRO_VERSION += 1;
#   TIDY_INTERFACE_AGE += 1;
#   TIDY_BINARY_AGE += 1;
# 
# if any functions have been added, set TIDY_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set TIDY_BINARY_AGE and TIDY_INTERFACE_AGE to 0.
# 
TIDY_MAJOR_VERSION=0
TIDY_MINOR_VERSION=99
TIDY_MICRO_VERSION=0
TIDY_INTERFACE_AGE=0
TIDY_BINARY_AGE=0

LIBTIDY_VERSION=$TIDY_MAJOR_VERSION.$TIDY_MINOR_VERSION.$TIDY_MICRO_VERSION

AC_SUBST(LIBTIDY_VERSION)

# libtool versioning
# 
LT_RELEASE=$TIDY_MAJOR_VERSION.$TIDY_MINOR_VERSION
LT_CURRENT=`expr $TIDY_MICRO_VERSION - $TIDY_INTERFACE_AGE`
LT_REVISION=$TIDY_INTERFACE_AGE
LT_AGE=`expr $TIDY_BINARY_AGE - $TIDY_INTERFACE_AGE`

AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

AM_INIT_AUTOMAKE(tidy,$LIBTIDY_VERSION)

# Checks for programs.

# =============================================
# AC_PROG_CC has a habit of adding -g to CFLAGS
# 
save_cflags="$CFLAGS"

AC_PROG_CC
if test "x$GCC" = "xyes"; then
	WARNING_CFLAGS="-Wall"
else
	WARNING_CFLAGS=""
fi
AC_SUBST(WARNING_CFLAGS)

debug_build=no
AC_ARG_ENABLE(debug,[  --enable-debug          add -g (instead of -O2) to CFLAGS],[
	if test "x$enableval" = "xyes"; then
		debug_build=yes
	fi
])
if test $debug_build = yes; then
	CFLAGS="$save_cflags -g"
else
	CFLAGS="-O2 $save_cflags"
fi
# 
# =============================================

AC_PROG_CPP
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET

support_access=yes
AC_ARG_ENABLE(access,[  --enable-access         support accessibility checks],[
	if test "x$enableval" = "xno"; then
		support_access=no
	fi
])
if test $support_access = yes; then
	AC_DEFINE(SUPPORT_ACCESSIBILITY_CHECKS,1)
else
	AC_DEFINE(SUPPORT_ACCESSIBILITY_CHECKS,0)
fi

support_utf16=yes
AC_ARG_ENABLE(utf16,[  --enable-utf16          support UTF-16 encoding],[
	if test "x$enableval" = "xno"; then
		support_utf16=no
	fi
])
if test $support_utf16 = yes; then
	AC_DEFINE(SUPPORT_UTF16_ENCODINGS,1)
else
	AC_DEFINE(SUPPORT_UTF16_ENCODINGS,0)
fi

support_asian=yes
AC_ARG_ENABLE(asian,[  --enable-asian          support asian encodings],[
	if test "x$enableval" = "xno"; then
		support_asian=no
	fi
])
if test $support_asian = yes; then
	AC_DEFINE(SUPPORT_ASIAN_ENCODINGS,1)
else
	AC_DEFINE(SUPPORT_ASIAN_ENCODINGS,0)
fi

# TODO: this defines "WITH_DMALLOC" but tidy expects "DMALLOC"
#       need to do: #if defined(DMALLOC) || defined(WITH_DMALLOC)
# 
AM_WITH_DMALLOC

AC_OUTPUT([
	Makefile
	src/Makefile
	console/Makefile
	include/Makefile
])
