##############################################################################
#
# FILE:		configure.in
# DESCRIPTION:	WKF: Configuration script
# DATE:		Tue, Jun 11 2000
# UPDATED:	Wed, Aug 31 2005
# AUTHOR:	Kouichi ABE (WALL) / 阿部康一
# E-MAIL:	kouichi@MysticWALL.COM
# URL:		http://www.MysticWALL.COM/
# COPYRIGHT:	(c) 2000-2005 阿部康一／Kouichi ABE (WALL), All rights reserved.
# LICENSE:
#
#  Copyright (c) 2000-2005 Kouichi ABE (WALL) <kouichi@MysticWALL.COM>,
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#
#   1. Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#
#   2. Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
#
#   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
#   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#   INTERRUPTION)  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
#   THE POSSIBILITY OF SUCH DAMAGE.
#
# $Id: configure.in,v 1.10 2005/08/31 07:58:05 kouichi Exp $
#
##############################################################################

AC_PREREQ(2.59)
AC_INIT([WKF], [1.3.9], [kouichi@MysticWALL.COM])
AC_CONFIG_SRCDIR([wkf.h])
AC_CONFIG_HEADER(config.h)

AC_CANONICAL_HOST

dnl Checks for programs.
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_SUBST(LD)
AC_PATH_PROGS([LD], [ld])
AC_SUBST(RM)
AC_PATH_PROGS([RM], [rm])
AC_SUBST(MV)
AC_PATH_PROGS([MV], [mv])
AC_SUBST(CP)
AC_PATH_PROGS([CP], [cp])
AC_SUBST(GNROFF)
AC_PATH_PROGS([GNROFF], [gnroff])
AC_SUBST(MKDIR)
AC_PATH_PROGS([MKDIR], [mkdir])
AC_SUBST(CTAGS)
AC_PATH_PROGS([CTAGS], [exctags ctags])
AC_SUBST(VI)
AC_PATH_PROGS([VI], [vim nvi jvim vi])

dnl Checks for debugging
AC_ARG_ENABLE([debug],
  AS_HELP_STRING([--enable-debug],
		 [build debugable code (for only developers)]),
  [ac_cv_debug="yes"], [ac_cv_debug="no"])
AC_MSG_RESULT([$ac_cv_debug])
if test "x$ac_cv_debug" = "xyes"; then
  if test "x$GCC" = "xyes"; then
    CFLAGS="-O -g -DDEBUG -Wall -Wconversion -Wpointer-arith -Wstrict-prototypes"
  else
    CFLAGS="-g -DDEBUG"
  fi
else
  if test "x$GCC" = "xyes"; then
    CFLAGS="-O2"
  else
    CFLAGS="-O"
  fi
fi


dnl Checks for default guessed kanji code
AC_SUBST(DEF_CODE)
def_code=no
AC_ARG_ENABLE([default_euc_jp],
  AS_HELP_STRING([--enable-default-euc-jp],
		 [guess unknown kanji code as EUC-JP]),
  [if test "x$enableval" = "xyes" ; then
    DEF_CODE=-DCODE_EUC_JP
    def_code=yes
  fi])

AC_ARG_ENABLE([default_sjis],
  AS_HELP_STRING([--enable-default-sjis],
		 [guess unknown kanji code as Shift-JIS (default)]),
  [if test "x$enableval" = "xyes" ; then
    DEF_CODE=-DCODE_SJIS
    def_code=yes
  fi])

if test "$def_code" = "no" ; then
  DEF_CODE=-DCODE_SJIS
  def_code=yes
fi

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h utime.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T

dnl Checks for library functions.
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS([memset strdup strncasecmp strstr utime])

AC_SUBST(MISSING_OBJ)
AC_SUBST(LTMISSING_OBJ)
AC_CHECK_FUNCS([strlcpy],,[needstrlcpy=yes])
if test "x$needstrlcpy" = "xyes"; then
  MISSING_OBJ="strlcpy.o"
  LTMISSING_OBJ="strlcpy.lo"
fi

AC_SUBST(LDSHARED)
case "$host_os" in
	freebsd*)	LDSHARED="ld -Bshareable";;
	netbsd*)	LDSHARED="ld -Bshareable";;
	openbsd*)	LDSHARED="ld -Bshareable";;
	linux*)		LDSHARED="ld -shared";;
	sunos*)		LDSHARED="ld -assert nodefinitions";;
	solaris*)	LDSHARED="ld -G";;
	hpux*)		DLDFLAGS="-E"
			LDSHARED="ld -b"
			LDFLAGS="-Wl,-E";;
	irix*)		LDSHARED="ld -ignore_unresolved";;
	sysv4*)		LDSHARED="ld -G";;
	esix*|uxpds*)	LDSHARED="ld -G";;
	osf*)		LDSHARED="ld -shared"
			if test "x$GCC" = "xno" ; then
				LDFLAGS="-call_shared"
			fi;;
	*)		LDSHARED="ld";;
esac


AC_OUTPUT(Makefile)
