dnl ####################################################################
dnl #   Copyright (c) 1998                                             #
dnl #                                                                  #
dnl #   You may copy, distribute, and modify it freely as long as you  #
dnl #   preserve this copyright and permission notice.                 #
dnl #                                                                  #
dnl #                                                                  #           
dnl ####################################################################
dnl 
dnl 
dnl #########################################################
dnl #/*                                                     #
dnl # * File         : configure.in                         #
dnl # * Author       : Guansong Zhang                       #
dnl # * Created      : Fri Jun 19 11:44:00 1998             #
dnl # * Revision     : $Revision: 1.6 $                     #
dnl # * Updated      : $Date: 1999/03/01 21:32:32 $         #
dnl # */                                                    #
dnl #########################################################

AC_INIT(./configure)

AC_PREFIX_DEFAULT(`pwd`)
AC_CONFIG_AUX_DIR(./config)

dnl cwd

CWD=`pwd`
AC_SUBST(CWD)


dnl an inline which function

which () {
  oldIFS=$IFS

  IFS=:
  for dir in $PATH
  do
    if test -x $dir/$1; then
       found="$dir/$1"; 
       echo $found; 
       break ;
    fi
  done;

  if test -z "$found" ; then
    echo $1; # echo input if not found.
  fi 

  IFS=$oldIFS 
}


AC_MSG_CHECKING(prunjava)

AC_CACHE_VAL(hpjdk_cv_adlib, 
  ADLIB=`which prunjava | sed 's%/bin/prunjava%%'`

  if test ! -f $ADLIB/bin/prunjava ; then
    echo "Please input Adlib install prefix:"
    read ADLIB
  fi;

  hpjdk_cv_adlib=$ADLIB
) 

AC_MSG_RESULT($hpjdk_cv_adlib)

ADLIB=$hpjdk_cv_adlib

AC_SUBST(ADLIB)

AC_OUTPUT(
src/tools/gen:src/tools/gen.in
src/tools/parse:src/tools/parse.in
src/tools/unparse:src/tools/unparse.in
src/tools/iunparse:src/tools/iunparse.in
src/tools/prettify:src/tools/prettify.in
src/tools/iprettify:src/tools/iprettify.in
src/tools/hpj2j:src/tools/hpj2j.in
src/tools/mjava:src/tools/mjava.in
)

chmod a+x src/tools/gen
chmod a+x src/tools/parse
chmod a+x src/tools/unparse
chmod a+x src/tools/iunparse
chmod a+x src/tools/prettify
chmod a+x src/tools/iprettify
chmod a+x src/tools/hpj2j
chmod a+x src/tools/mjava

echo Done!

