dnl 
dnl template file to create configure script for DCL
dnl

#
# === STARTUP ===
#

AC_CHECK_CANONICAL_HOST
AC_INIT(src/f77/hex_interface.f90)
sh ./chkfort.sh || exit
. ./chkfort.cfg
AC_SUBST(FC)
AC_SUBST(MOD)
AC_SUBST(F90MODTYPE)
: ${IFCCEM:=:}
AC_SUBST(IFCCEM)

AC_PREFIX_DEFAULT(/usr/local/dcl-f90)

#
# === PROGRAM CHECK ===
#


AC_CHECK_PROG(SJISTOEUC, nkf, nkf -xe)
AC_CHECK_PROG(SJISTOEUC, iconv, iconv -f SHIFT_JIS -t EUC-JP)
AC_CHECK_PROG(EUCTOSJIS, nkf, nkf -xs)
AC_CHECK_PROG(EUCTOSJIS, iconv, iconv -f EUC-JP -t SHIFT_JIS)

AC_ARG_WITH(charset, [charset: of source and resource (shift_jis or euc-jp)], [
	ac_cv_sys_charset=$withval
], [
AC_CACHE_CHECK([charset for source/resource], ac_cv_sys_charset, [
	case $SYSTYPE in
	*BSD*|Linux*|SunOS-4.*)
		ac_cv_sys_charset=euc-jp
		;;
	*)
		ac_cv_sys_charset=shift_jis
		;;
	esac
])
])
CHARSET=$ac_cv_sys_charset
AC_SUBST(CHARSET)

#
# === DCL ===
#

AC_ARG_WITH(dclconfig, [dclconfig: dcl utility after dcl 5.1], [
	ac_cv_lib_dclconfig=$withval
], [
	AC_CACHE_CHECK([dclconfig command], ac_cv_lib_dclconfig, [
		ac_cv_lib_dclconfig=`which dclconfig 2> /dev/null`
		if test ! -x "$ac_cv_lib_dclconfig"; then
			AC_MSG_ERROR(dclconfig not found)
		fi
	])
])

dclconfig=$ac_cv_lib_dclconfig
SYSLDFLAGS="`$dclconfig --ldflags`"
SYSLDLIBS="`$dclconfig --ldlibs` $SYSFLIBS"
SYSFLIBS="`$dclconfig --ldflags` `$dclconfig --ldlibs` $SYSFLIBS"
SYSFFLAGS="`$dclconfig --fflags` $SYSFFLAGS"

AC_SUBST(dclconfig)
AC_SUBST(SYSFLIBS)
AC_SUBST(SYSFFLAGS)
AC_SUBST(SYSLDFLAGS)
AC_SUBST(SYSLDLIBS)

#
# === output ===
#

AC_OUTPUT(Mkinclude)

test -d tmp || mkdir tmp

${MAKE:-make} ${CHARSET}
