1#!/bin/sh
2# vim:set ts=8 sts=2 sw=2 tw=0:
3#
4# configure - Easy configuration script
5#
6# Last Change: 01-Oct-2005.
7# Author & Maintainer: MURAOKA Taro <koron@tka.att.ne.jp>
8
9config_out=config.mk
10config_in=compile/config.mk.in
11config_default=compile/config_default.mk
12
13CHECK_COMMAND() {
14  if test -e "`which $1 2>/dev/null`" ; then
15    return 0
16  else
17    return 1
18  fi
19}
20
21PATH_PREFIX=/usr/local
22# Check arguments
23for i in $*
24do
25  arg_value=`echo "$i" | sed 's/[-_a-zA-Z0-9]*=//'`
26  case $i in
27    --prefix=*) PATH_PREFIX=$arg_value;;
28  esac
29done
30
31# Check HTTP access tool
32if CHECK_COMMAND curl ; then
33  PROGRAM_HTTP="curl -O"
34elif CHECK_COMMAND wget ; then
35  PROGRAM_HTTP="wget"
36elif CHECK_COMMAND fetch ; then
37  PROGRAM_HTTP="fetch"
38else
39  echo "ERROR: Require one of HTTP access tools (curl, wget or fetch)."
40  exit 1
41fi
42
43# Check install program
44if test -x /usr/ucb/install ; then
45  PROGRAM_INSTALL="/usr/ucb/install"
46elif test -x /usr/bin/install ; then
47  PROGRAM_INSTALL="/usr/bin/install"
48else
49  PROGRAM_INSTALL="/usr/bin/install"
50  echo "WARNING: Can't find install program."
51  echo "         But set it \"/usr/bin/install\".  So need to make sure."
52fi
53
54# for Debug
55if test 0 != 0 ; then
56  echo "PATH_PREFIX=${PATH_PREFIX}" 1>&2
57  echo "PROGRAM_HTTP=${PROGRAM_HTTP}" 1>&2
58  echo "PROGRAM_ENCODEFILTER=${PROGRAM_ENCODEFILTER}" 1>&2
59  echo "PROGRAM_INSTALL=${PROGRAM_INSTALL}" 1>&2
60fi
61
62# Generate config.mk
63while read line ; do
64  case "$line" in
65    *\$\{*) eval "echo $line" ;;
66    *) echo $line
67  esac
68done < $config_in > $config_out
69