#! /bin/sh
# configure - configuration script for itchconfig 0.0.4
#
# This configuration script file has been auto-generated by
# itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
# Copyright (C) 2002 Arne Thomassen <arne@arne-thomassen.de>
# This configuration script file is free software WITHOUT ANY WARRANTY;
# you are given unlimited permission to copy, distribute and modify this file,
# as long as this notice is kept intact and you indicate file modifications.

exec 5>/dev/null
if test -n "${ZSH_VERSION+set}" && (emulate sh) >&5 2>&1; then
  emulate sh
  NULLCMD=:
elif test -n "${BASH_VERSION+set}" && (set -o posix) >&5 2>&1; then
  set -o posix
fi

ic_nl='
'
IFS=" 	$ic_nl"
export IFS

if (FOO=FOO; unset FOO) >&5 2>&1; then
  ic_unset=unset
else
  ic_unset=false
fi

$ic_unset ENV MAIL MAILPATH
PS1='$ '
PS2='> '
PS4='+ '

for i_x in LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME
do
  if (set +x; test -n "`(eval $i_x=C; export $i_x) 2>&1`"); then
    eval $i_x=C; export $i_x
  else
    $ic_unset $i_x
  fi
done

ic_me=`echo "$0" | sed 's,.*[/],,'`
ic_version='0.0.4'
ic_package_name='itchconfig'
ic_package_version='0.0.4'
ic_fatal_error=echo
ic_show_message=echo
ic_show_info=false

ic_site_file=
ic_site_next=
i_site="${ITCHCONFIG_SITE-}"
if test -n "$i_site"; then
  for i_x in '-itchconfig' ''
  do
    i_s=`echo "$i_site" | sed "s,%P%,$i_x,g"`
    if test -n "$i_s" && test -f "$i_s"; then
      ic_site_file="$i_s"
      ic_site_next=init1
      break
    fi
  done
fi

if test -n "$ic_site_file" && test "x$ic_site_next" = xinit1; then
  ic_site_stage=init1
  ic_site_next=
  . "$ic_site_file"
fi

ic_AZ=ABCDEFGHIJKLMNOPQRSTUVWXYZ
ic_az=abcdefghijklmnopqrstuvwxyz
ic_Az=$ic_AZ$ic_az
ic_Az09=${ic_Az}0123456789

# Override env vars?
for i_arg
do
  case $i_arg in
  [_$ic_Az]*=*)
  i_var=`expr "x$i_arg" : 'x\([^=]*\)='`
  i_val=`expr "x$i_arg" : 'x[^=]*=\(.*\)' | sed "s/'/'\\\\\\\\''/g"`
  eval "$i_var='$i_val'"; export $i_var
  ;;
  esac
done

SHELL="${ITCHCONFIG_SHELL-/bin/sh}"
export SHELL
ic_makedir="${MKDIRPROG-mkdir}"
if test "${PATH_SEPARATOR+set}" != set; then
  PATH_SEPARATOR=:
fi
$ic_unset CDPATH

case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  *c*,-n*) ic_ECHO_N= ic_ECHO_C='
' ic_ECHO_T='	' ;;
  *c*,*  ) ic_ECHO_N=-n ic_ECHO_C= ic_ECHO_T= ;;
  *)      ic_ECHO_N= ic_ECHO_C='\c' ic_ECHO_T= ;;
esac

ic_path_archprefix='${ic_path_prefix}'
ic_path_prefix=/usr/local
ic_path_bin='${ic_path_archprefix}/bin'
ic_path_perllib=''
ic_path_itchshare='${ic_path_prefix}/share/itchconfig'
ic_path_man='${ic_path_prefix}/man'
ic_path_info='${ic_path_prefix}/info'
ic_installs=
ic_program_prefix=
ic_program_suffix=
ic_infiles=


if test -n "$ic_site_file" && test "x$ic_site_next" = xinit2; then
  ic_site_stage=init2
  ic_site_next=
  . "$ic_site_file"
fi

# Parse args
i_premature_exit=a
for i_arg
do

i_aval=`expr "x$i_arg" : 'x[^=]*=\(.*\)'`

case $i_arg in

  --path-archprefix=*)
  ic_path_archprefix="$i_aval"
  ;;

  --path-prefix=*)
  ic_path_prefix="$i_aval"
  ;;

  --path-bin=*)
  ic_path_bin="$i_aval"
  ;;

  --path-perllib=*)
  ic_path_perllib="$i_aval"
  ;;

  --path-itchshare=*)
  ic_path_itchshare="$i_aval"
  ;;

  --path-man=*)
  ic_path_man="$i_aval"
  ;;

  --path-info=*)
  ic_path_info="$i_aval"
  ;;

  --program-prefix=*)
  ic_program_prefix="$i_aval"
  ;;

  --program-suffix=*)
  ic_program_suffix="$i_aval"
  ;;

  --verbose)
  ic_show_info=echo
  ;;

  --quiet)
  ic_fatal_error=false
  ic_show_message=false
  ;;

  --version | -V)
  i_premature_exit=b
  break
  ;;

  --report)
  i_premature_exit=c
  break
  ;;

  --help)
  i_premature_exit=d
  break
  ;;

  --site* | [_$ic_Az]*=*)
  ;;

  *)
  $ic_fatal_error "$ic_me: unrecognized option: $i_arg. Try \"./$ic_me --help\"!" >&2
  { (exit 1); exit 1; }
  ;;

esac
done

case $i_premature_exit in
a)
  ;;
b)
  cat <<EOF
$ic_me - configuration script for itchconfig 0.0.4
This configuration script file has been auto-generated by
itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
Copyright (C) 2002 Arne Thomassen <arne@arne-thomassen.de>
This configuration script file is free software WITHOUT ANY WARRANTY;
you are given unlimited permission to copy, distribute and modify this file,
as long as this notice is kept intact and you indicate file modifications.
EOF
  { :; exit 0; }
  ;;
c)
  echo "$ic_me report for itchconfig 0.0.4 (by itchconfig 0.0.4):"
  if test -f "./config.guess"; then
    i_xv="`./config.guess --version 2>&5 | sed 1q`"
    i_x="`./config.guess 2>&5`"
    echo "config.guess ($i_xv) says: $i_x"
  fi
  i_x="`uname -a 2>&5`"
  echo "uname -a says: $i_x"
  i_x="`make --version 2>&5 | sed 1q`"
  echo "make version: $i_x"
  { :; exit 0; }
  ;;
d)
  cat <<EOF
\`$ic_me' configures itchconfig 0.0.4 to adapt to your computer.
Script generated by itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
Usage: ./$ic_me [option] ...
Default values are shown in brackets below.

General Options:
--verbose      print more information about what happens
--quiet        don't print any messages
--version, -V  print the version information and exit
--report       print a little configuration report and exit
--help         print this help and exit

Installation Options:
--program-prefix=...  standard program prefix [NONE]
--program-suffix=...  standard program suffix [NONE]

Installation Paths:
--path-archprefix=PATH  path prefix for architecture-dependent files [PREFIX]
--path-prefix=PATH      path prefix for architecture-independent files
                        [/usr/local]
--path-bin=PATH         normal programs [ARCHPREFIX/bin]
--path-perllib=PATH     Perl libraries [(auto-detected)]
--path-itchshare=PATH   path to m4 macro file [PREFIX/share/itchconfig]
--path-man=PATH         manual documentation [PREFIX/man]
--path-info=PATH        info documentation [PREFIX/info]
EOF
  { :; exit 0; }
  ;;
esac

if test -f "itchlib.pm"; then :; else
  $ic_fatal_error "$ic_me: configuration script launched from wrong directory!" >&2
  { (exit 1); exit 1; }
fi


# Make sure that paths are absolute
for i_path in ic_path_archprefix ic_path_prefix ic_path_bin ic_path_itchshare \
              ic_path_man ic_path_info
do
eval ic_val=$`echo $i_path`
case $ic_val in
  [/$]*)
  ;;
  *)
  $ic_fatal_error "$ic_me: $i_path must be absolute, but is \"$ic_val\"" >&2
  { (exit 1); exit 1; }
  ;;
esac
done


# Create a temporary directory
{ trap 'exit_status=$?; rm -rf $ic_tempdir && exit $exit_status' 0
  trap '{ (exit 1); exit 1; }' 1 2 13 15
}
: ${TMPDIR=/tmp}
{ ic_tempdir=`(umask 077 && mktemp -d -q "$TMPDIR/icXXXXXX") 2>&5` &&
  test -n "$ic_tempdir" && test -d "$ic_tempdir"
} ||
{ ic_tempdir=$TMPDIR/ic$$-$RANDOM
  (umask 077 && $ic_makedir $ic_tempdir)
} ||
{
  $ic_fatal_error "$ic_me: cannot create a temporary directory in $TMPDIR" >&2
  { (exit 1); exit 1; }
}

$ic_show_info "Configuring itchconfig 0.0.4..."
ic_testfile=$ic_tempdir/test
ic_substfile=$ic_tempdir/subst
exec 8>$ic_substfile

ic_convpath=`echo "$PATH" | sed "s,$PATH_SEPARATOR, ,g"`

ic_makefile=$ic_tempdir/Makefile
exec 6>$ic_makefile
cat >&6 <<EOF
# This Makefile for itchconfig 0.0.4 has been auto-generated by  -*-Makefile-*-
# itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
# Copyright (C) 2002 Arne Thomassen <arne@arne-thomassen.de>
# This Makefile is free software WITHOUT ANY WARRANTY;
# you are given unlimited permission to copy, distribute and modify this file,
# as long as this notice is kept intact and you indicate file modifications.

all: default-target
SHELL=$SHELL

EOF

cat >&8 <<EOF
s,@VERSION@,0.0.4,g
EOF
if expr "$ic_infiles" : "itchconfig\.in" >&5 2>&1; then :; else
  ic_infiles="$ic_infiles itchconfig.in"
fi
if expr "$ic_infiles" : "itchscan\.in" >&5 2>&1; then :; else
  ic_infiles="$ic_infiles itchscan.in"
fi
if expr "$ic_infiles" : "itchconfig\.m4\.in" >&5 2>&1; then :; else
  ic_infiles="$ic_infiles itchconfig.m4.in"
fi

# Path of program "perl"
$ic_show_message $ic_ECHO_N "Checking the path of the program \"perl\"... $ic_ECHO_C"
i_pfinal=
for i_pp in $ic_convpath
do
  i_p0="$i_pp/perl"
  if test -f "$i_p0"; then
    i_pfinal="$i_p0"
    break
  fi
done
if test -n "$i_pfinal"; then
cat >&8 <<EOF
s,@PATH_PROGRAM_PERL@,$i_pfinal,g
EOF
else
  i_pfinal='(NOT FOUND!)'
fi
$ic_show_message "${ic_ECHO_T}$i_pfinal"

# Path of program "m4"
$ic_show_message $ic_ECHO_N "Checking the path of the program \"m4\"... $ic_ECHO_C"
i_pfinal=
for i_pp in $ic_convpath
do
  i_p0="$i_pp/m4"
  if test -f "$i_p0"; then
    i_pfinal="$i_p0"
    break
  fi
done
if test -n "$i_pfinal"; then
cat >&8 <<EOF
s,@PATH_PROGRAM_M4@,$i_pfinal,g
EOF
else
  i_pfinal='(NOT FOUND!)'
fi
$ic_show_message "${ic_ECHO_T}$i_pfinal"
ic_installs="$ic_installs bin"
ic_install_bin_files="itchconfig itchscan"
ic_install_bin_perm="u=rwx,g=rx,o=rx"
ic_install_bin_magic=m1
ic_installs="$ic_installs perllib"
ic_install_perllib_files="itchlib.pm itchcop.pm"
ic_install_perllib_perm="u=rw,g=r,o=r"
ic_install_perllib_magic=m0
ic_installs="$ic_installs itchshare"
ic_install_itchshare_files="itchconfig.m4"
ic_install_itchshare_perm="u=rw,g=r,o=r"
ic_install_itchshare_magic=m0
ic_installs="$ic_installs man"
ic_install_man_files="docu/itchconfig.1 docu/itchscan.1"
ic_install_man_perm="u=rw,g=r,o=r"
ic_install_man_magic=m2
ic_installs="$ic_installs info"
ic_install_info_files="docu/itchconfig.info"
ic_install_info_perm="u=rw,g=r,o=r"
ic_install_info_magic=m0
cat >&8 <<EOF
s,@OPTION_FROZEN@,0,g
EOF
if test -z "$ic_path_perllib"; then
$ic_show_message $ic_ECHO_N "Checking Perl library path... $ic_ECHO_C"

ICV_perllib=`perl -e "print join(' ', @INC)" 2>/dev/null`
if test -z "$ICV_perllib"; then
$ic_show_message "${ic_ECHO_T}none?"
{
$ic_fatal_error "$ic_me: cannot auto-detect any Perl library path; use option --path-perllib!" >&2
{ (exit 1); exit 1; }
:;
}
fi

ICV_found=0
for ICV_path in $ICV_perllib
do
  if test -d "$ICV_path"; then
ic_path_perllib="$ICV_path"
    ICV_found=1
    break
  fi
done
if test $ICV_found = 0; then
$ic_show_message "${ic_ECHO_T}none?"
{
$ic_fatal_error "$ic_me: cannot auto-detect a good Perl library path; use option --path-perllib!" >&2
{ (exit 1); exit 1; }
:;
}

fi
$ic_show_message "${ic_ECHO_T}$ICV_path"
fi
eval pfinal0="$ic_path_itchshare"
eval pfinal="$pfinal0"
cat >&8 <<EOF
s,@PATH_INSTALL_ITCHSHARE@,$pfinal,g
EOF

# Make sure that paths are absolute
for i_path in ic_path_perllib
do
eval ic_val=$`echo $i_path`
case $ic_val in
  [/$]*)
  ;;
  *)
  $ic_fatal_error "$ic_me: $i_path must be absolute, but is \"$ic_val\"" >&2
  { (exit 1); exit 1; }
  ;;
esac
done

cat >&6 <<EOF
all-binaries:
	@echo "Nothing to do!" >&2
EOF

if test -n "$ic_installs"; then
  allinst="install:"
  for inst in $ic_installs
  do
    eval ic_val=$`echo "ic_install_${inst}_files"`
    if test -n "$ic_val"; then
      eval path=$`echo "ic_path_${inst}" | sed "s,[^$ic_Az09],_,g"`
      eval pfinal0="$path"
      eval pfinal="$pfinal0"
      eval perm=$`echo "ic_install_${inst}_perm"`
      eval magic=$`echo "ic_install_${inst}_magic"`
      allinst="$allinst install-$inst"
      cat >&6 <<EOF
install-$inst:
	@./configure.act --int-install $perm $magic $pfinal "$ic_val"
EOF
    fi
  done
  echo "$allinst" >&6
fi

mf_mostlyclean=
cat >&6 <<EOF

mostlyclean:
$mf_mostlyclean
clean: mostlyclean

distclean: clean
	-@rm -f configure.act
	-@rm -f Makefile
	-@rm -f itchconfig itchconfig.m4 itchscan
maintainer-clean: distclean
	-@rm -rf *~

default-target: all-binaries
.PHONY: all all-binaries clean default-target distclean install install-bin \\\\
        install-info install-itchshare install-man install-perllib \\\\
        maintainer-clean mostlyclean
.SUFFIXES:
.DELETE_ON_ERROR:
.NOEXPORT:
EOF
exec 6>&5
exec 8>&5

$ic_show_info "Writing configure.act"
exec 6>configure.act
cat >&6 <<EOFACT
#! $SHELL
# configure.act - configured actions for itchconfig 0.0.4
#
# This configuration script file has been auto-generated by
# itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
# Copyright (C) 2002 Arne Thomassen <arne@arne-thomassen.de>
# This configuration script file is free software WITHOUT ANY WARRANTY;
# you are given unlimited permission to copy, distribute and modify this file,
# as long as this notice is kept intact and you indicate file modifications.

exec 5>/dev/null
if test -n "\${ZSH_VERSION+set}" && (emulate sh) >&5 2>&1; then
  emulate sh
  NULLCMD=:
elif test -n "\${BASH_VERSION+set}" && (set -o posix) >&5 2>&1; then
  set -o posix
fi

ic_nl='
'
IFS=" 	\$ic_nl"
export IFS

if (FOO=FOO; unset FOO) >&5 2>&1; then
  ic_unset=unset
else
  ic_unset=false
fi

\$ic_unset ENV MAIL MAILPATH
PS1='\$ '
PS2='> '
PS4='+ '

for i_x in LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_TIME
do
  if (set +x; test -n "\`(eval \$i_x=C; export \$i_x) 2>&1\`"); then
    eval \$i_x=C; export \$i_x
  else
    \$ic_unset \$i_x
  fi
done

ic_me=\`echo "\$0" | sed 's,.*[/],,'\`
ic_fatal_error=$ic_fatal_error
ic_show_info=$ic_show_info

if test -f "itchlib.pm"; then :; else
  \$ic_fatal_error "\$ic_me: configuration script launched from wrong directory!" >&2
  { (exit 1); exit 1; }
fi


case \$1 in
  --int-install)
  mode="\$2"
  magic="\$3"
  initial_path="\$4"
  files="\$5"
  act="\${ITCHCONFIG_ACT-}"
  ic_makedir="\${MKDIRPROG-mkdir}"
  ic_program_prefix="$ic_program_prefix"
  ic_program_suffix="$ic_program_suffix"
  checked_path=
  for one_file in \$files
  do
    path="\$initial_path"
    file=\`echo "\$one_file" | sed 's,.*[/],,'\`
    case \$magic in
    m0) ;;
    m1)
file="\$ic_program_prefix\$file\$ic_program_suffix"
    ;;
    m2)
num=\`echo "\$file" | sed 's,.*\\.\\([0123456789]\\).*,\\1,'\`
path="\$path/man\$num"
    ;;
    *)
    \$ic_fatal_error "\$ic_me: unknown installer magic \\"\$magic\\"" >&2
    { (exit 1); exit 1; }
    ;;
    esac
    if test "x\$checked_path" != "x\$path"; then
      checked_path="\$path"
      parts=\`echo "\$path" | sed 's,/, ,g'\`
      p=
      for part in \$parts
      do
        p="\$p/\$part"
        if test -d "\$p" || \$act \$ic_makedir "\$p"; then :; else
          \$ic_fatal_error "\$ic_me: cannot create directory \\"\$p\\"" >&2
          { (exit 1); exit 1; }
        fi
      done
    fi
    dest_file="\$path/\$file"
    if test -f "\$dest_file"; then
      temp_file=\$path/#itch.\$\$#
      \$act trap "mv -f \$temp_file \$dest_file" 1 2 13 15
      \$act mv -f \$dest_file \$temp_file
      \$act cp \$one_file \$dest_file
      \$act rm -f \$temp_file
    else
      \$act cp \$one_file \$dest_file
    fi
    \$act chmod \$mode \$dest_file
  done
  { :; exit 0; }
  ;;
esac


# Parse args
i_premature_exit=a
for i_arg
do

case \$i_arg in

  --version | -V)
  i_premature_exit=b
  break
  ;;

  --help)
  i_premature_exit=c
  break
  ;;

  *)
  \$ic_fatal_error "\$ic_me: unrecognized option: \$i_arg. Try \\"./\$ic_me --help\\"!" >&2
  { (exit 1); exit 1; }
  ;;

esac
done

case \$i_premature_exit in
a)
  ;;
b)
  cat <<EOF
\$ic_me - configured actions for itchconfig 0.0.4
This configuration script file has been auto-generated by
itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
Copyright (C) 2002 Arne Thomassen <arne@arne-thomassen.de>
This configuration script file is free software WITHOUT ANY WARRANTY;
you are given unlimited permission to copy, distribute and modify this file,
as long as this notice is kept intact and you indicate file modifications.
EOF
  { :; exit 0; }
  ;;
c)
  cat <<EOF
\\\`\$ic_me' performs configured actions for itchconfig 0.0.4.
Script generated by itchconfig 0.0.4 <http://itchconfig.sourceforge.net/>.
Usage: ./\$ic_me [option] ...

General Options:
--version, -V  print the version information and exit
--help         print this help and exit
EOF
  { :; exit 0; }
  ;;
esac

EOFACT

cat >&6 <<EOFACT
\$ic_show_info "Writing the Makefile"
EOFACT
echo "cat >Makefile <<EOFINACT" >&6
cat >&6 <$ic_makefile
echo "EOFINACT" >&6

if test -n "$ic_infiles"; then
  echo >&6
  echo "cat >configure.subst <<EOFINACT" >&6
  cat >&6 <$ic_substfile
  cat >&6 <<EOFACT
EOFINACT
further_infiles="$ic_infiles"
while test -n "\$further_infiles"
do
  infiles="\$further_infiles"
  further_infiles=
  for infile in \$infiles
  do
    file=\`echo "\$infile" | sed 's,\\.in\$,,'\`
    \$ic_show_info "Creating \$file from \$infile"
    sed -f configure.subst \$infile >\$file 2>&5
    if expr "\$file" : '\\.in\$' >&5 2>&1; then
      further_infiles="\$further_infiles \$file"
    fi
  done
done
rm -f configure.subst >&5 2>&1
EOFACT
fi

echo "{ :; exit 0; }" >&6
exec 6>&5

$ic_show_info "Executing configure.act"
chmod u+rx configure.act
$SHELL configure.act

{ :; exit 0; }
