Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 312 lines (276 sloc) 9.951 kB
#!/bin/sh
#/ Usage: ./configure [OPTION]... [VAR=VALUE]...
#/ configure rpg for installation on this system.
#/
#/ Options
#/ --with-ruby[=RUBY] tie to specific ruby installation. RUBY is
#/ path to ruby executable.
#/ --development configure for local working copy development
#/
#/ Installation locations
#/ --prefix=PREFIX install files in PREFIX [/usr/local]
#/ --bindir=DIR user executables [PREFIX/bin]
#/ --libexecdir=DIR program executables [PREFIX/libexec]
#/ --sysconfdir=DIR system configuration files [PREFIX/etc]
#/ --datarootdir=DIR data file root [PREFIX/share]
#/ --datadir=DIR data files [DATAROOTDIR]
#/ --mandir=DIR man documentation [DATAROOTDIR/man]
#/ --rpgdir=DIR rpg package and db root [RUBYLIBDIR/rpg]
warn () { echo "$(basename $0):" "$@" 1>&2; }
longarg () { echo "$1" | sed "s/^$2=//"; }
# Argument Parsing
# ----------------
sourcedir="$(cd "$(dirname $0)" && pwd)"
develmode=false
tiedown=false
while test $# -gt 0
do
case "$1" in
# Options
--with-ruby) RUBY="ruby"
tiedown=true
specified_ruby=
shift;;
--with-ruby=*) RUBY=$(longarg "$1" --with-ruby)
tiedown=true
specified_ruby="$RUBY"
shift;;
--develop|--development)
prefix="$sourcedir/work"
bindir="$sourcedir"
libexecdir="$sourcedir"
localstatedir="$prefix"
sysconfdir="$sourcedir"
datarootdir="$sourcedir"
datadir="$sourcedir"
mandir="$sourcedir/man"
develmode=true
shift
;;
# Installation locations:
--prefix) prefix="$2";shift 2;;
--prefix=*) prefix="$(longarg "$1" --prefix)";shift;;
--bindir) bindir="$2";shift 2;;
--bindir=*) bindir="$(longarg "$1" --bindir)";shift;;
--libexecdir) libexecdir="$2";shift 2;;
--libexecdir=*) libexecdir="$(longarg "$1" --libexecdir)";shift;;
--localstatedir) localstatedir="$2";shift 2;;
--localstatedir=*) localstatedir="$(longarg "$1" --localstatedir)";shift;;
--sysconfdir) sysconfdir="$2";shift 2;;
--sysconfdir=*) sysconfdir="$(longarg "$1" --sysconfdir)";shift;;
--datarootdir) datarootdir="$2";shift 2;;
--datarootdir=*) datarootdir="$(longarg "$1" --datarootdir)";shift;;
--datadir) datadir="$2";shift 2;;
--datadir=*) datadir="$(longarg "$1" --datadir)";shift;;
--mandir) mandir="$2";shift 2;;
--mandir=*) mandir="$(longarg "$1" --mandir)";shift;;
--rpgdir) rpgdir="$2";shift 2;;
--rpgdir=*) rpgdir="$(longarg "$1" --rpgdir)";shift;;
# Environment variables passed on command line:
[A-Z]*=*) name="${1%%=*}"
value="${1#*=}"
shift
eval "${name}='${value}'";;
# Bail out with usage otherwise.
*) grep '^#/' < "$0" | cut -c4-
exit 2;;
esac
done
# Finding Stuff Functions
# -----------------------
looking () { printf "looking %s" "$*"; }
ok () { printf " OK\n"; }
missing () { printf " (missing)\n"; }
found () {
printf " (${1:-found})"
test -n "$2" && printf " $2"
printf "\n"
}
have () {
for f in "$@"
do
# if a whole command line was given, assume it exists
expr "$f" : '..* ' >/dev/null && {
echo "$f"
return 0
}
# look for the path with command(1)
_havepath=$(command -v "$f") || { continue; }
echo "$_havepath"
return 0
done
return 1
}
# Usage: stdutil <name> <variable> <path>...
stdutil () {
looking "for $1"; shift
_varname="$1"; shift
if _path=$(have "$@")
then found "$_path"
recordconfig $_varname "$_path"
else missing
recordconfig $_varname ""
fi
return 0
}
# Build up lists of config stuff to write to config.sh and config.mk
SHCONFIG=
SHALIAS=
MAKECONFIG=
recordconfig () {
SHCONFIG="$SHCONFIG
$1='$2'"
eval "$SHCONFIG"
SHALIAS="$SHALIAS
alias $1='$2'"
MAKECONFIG="$MAKECONFIG
$1 = $2"
}
# Usage: rbconfig <key> [<default>]
# Retrieve a rbconfig value for the currently active ruby interpreter. If
# an error occurs obtaining the value, return <default>.
rbconfig () {
${RUBY:-ruby} -r rbconfig -e "puts RbConfig::CONFIG['$1']" 2>/dev/null ||
echo "$2"
return 0
}
UNAME=$(uname 2>/dev/null)
HOST=$(hostname 2>/dev/null)
TIME=$(date 2>/dev/null)
echo "building for ${UNAME:-unknown} on ${HOST:-localhost} at ${TIME:-a time unknown}"
looking "for /bin/sh"
SH=$(have /bin/sh) && {
if expr "$("$SH" --version 2>/dev/null)" : '.*bash' >/dev/null
then
found '' "oh ick, it looks like bash"
else
found
fi
} || missing
recordconfig SHELL "$SH"
stdutil bash BASH /bin/bash /usr/bin/bash bash
stdutil dash DASH /bin/dash /usr/bin/dash dash
stdutil sed SED /bin/sed /usr/bin/sed sed gsed
stdutil perl PERL perl
if $tiedown && test -n "$specified_ruby"
then
stdutil ruby RUBY "$RUBY"
else
stdutil ruby RUBY "$RUBY" ruby ruby18
fi
stdutil install INSTALL "$(rbconfig INSTALL)" /usr/bin/install install ginstall
stdutil egrep EGREP "$(rbconfig EGREP)" egrep
stdutil ln LN /bin/ln ln gln
stdutil sort SORT /bin/sort /usr/bin/sort sort gsort
stdutil tr TR /usr/bin/tr tr gtr
stdutil cut CUT /usr/bin/cut cut gcut
stdutil mktemp MKTEMP /bin/mktemp mktemp gmktemp
stdutil readlink READLINK /bin/readlink readlink greadlink
stdutil diff DIFF diff
stdutil patch PATCH patch
stdutil tar TAR tar gtar
stdutil curl CURL curl
stdutil gem GEM "$(rbconfig bindir)/gem" gem
stdutil schocco SHOCCO shocco
stdutil rocco ROCCO rocco
stdutil ronn RONN ronn
recordconfig INSTALL_PROGRAM "$INSTALL"
set -e
# Load configuration
eval "$SHCONFIG"
test -z "$RUBY" && {
if $tiedown && test -n "$specified_ruby"
then
warn "fatal: specified ruby ($specified_ruby) not found."
warn "please fix: --with-ruby=/path/to/ruby."
else
warn "fatal: no ruby found on PATH."
warn "try: $0 --with-ruby=/path/to/ruby"
fi
exit 3
}
test -z "$CURL" && {
warn "fatal: no curl(1) found on PATH. install it and try again."
exit 3
}
test -z "$TAR" && {
warn "fatal: no tar(1) found on PATH. install it and try again."
exit 3
}
test -z "$DIFF" &&
warn "warn: no diff(1) found on PATH. some features will be disabled."
RUBYFRAMEWORK=false
if test "$UNAME" = "Darwin"
then
RUBYFRAMEWORKPATH="/System/Library/Frameworks/Ruby.framework"
printf "checking if ruby is system framework"
if expr -- "$(rbconfig prefix)" : "$RUBYFRAMEWORKPATH" >/dev/null
then printf " (yep)\n"
RUBYFRAMEWORK=true
else
printf " (nope)\n"
fi
fi
echo "okay, looks like you have everything we need. generating config files."
# Try to pick a default configuration
if $tiedown && ! $RUBYFRAMEWORK
then
: ${prefix:=$(rbconfig prefix "/usr/local")}
: ${exec_prefix:=$(rbconfig exec_prefix "$prefix")}
: ${bindir:=$(rbconfig bindir "$exec_prefix/bin")}
: ${libexecdir:=$(rbconfig libexecdir "$exec_prefix/libexec")}
: ${localstatedir:=$(rbconfig localstatedir "$prefix/var")}
: ${sysconfdir:=$(rbconfig sysconfdir "$prefix/etc")}
: ${datarootdir:=$(rbconfig datarootdir "$prefix/share")}
: ${datadir:=$(rbconfig datadir "$datarootdir")}
: ${mandir:=$(rbconfig mandir "$datadir/man")}
: ${docdir:=$(rbconfig docdir "$datadir/doc")}
: ${rpgdir:=$(rbconfig rubylibdir "/var/lib")/rpg}
else
: ${prefix:="/usr/local"}
: ${exec_prefix:="$prefix"}
: ${bindir:="$exec_prefix/bin"}
: ${libexecdir:="$exec_prefix/libexec"}
: ${localstatedir:="$prefix/var"}
: ${sysconfdir:="$prefix/etc"}
: ${datarootdir:="$prefix/share"}
: ${datadir:="$datarootdir"}
: ${mandir:="$datadir/man"}
: ${docdir:="$datadir/doc"}
fi
recordconfig prefix "$prefix"
recordconfig exec_prefix "$exec_prefix"
recordconfig bindir "$bindir"
recordconfig libexecdir "$libexecdir"
recordconfig localstatedir "$localstatedir"
recordconfig sysconfdir "$sysconfdir"
recordconfig datarootdir "$datarootdir"
recordconfig datadir "$datadir"
recordconfig mandir "$mandir"
recordconfig rpgdir "$rpgdir"
recordconfig develmode "$develmode"
echo writing config.mk...
cat <<EOF > config.mk
$MAKECONFIG
EOF
echo writing config.sh...
cat <<EOF > config.sh
# utility locations
$SHCONFIG
EOF
$develmode && {
echo "RPGSYSCONF=/dev/nothing" >> config.sh
echo "RPGUSERCONF=/dev/nothing" >> config.sh
echo "ready for development. run \`make' or \`make auto' to build."
echo "you may also want to put . on PATH; in your current shell:"
echo " PATH=$(pwd):\$PATH"
exit 0
}
echo "rpg configured to install at the following locations:"
printf " bindir: %-20s (%s)\n" "$bindir" "main rpg user executable"
printf " libexecdir: %-20s (%s)\n" "$libexecdir" "rpg program executables"
printf " sysconfdir: %-20s (%s)\n" "$sysconfdir" "rpgrc config file"
printf " localstatedir: %-20s (%s)\n" "$localstatedir" "package db, index, and gem cache"
printf " mandir: %-20s (%s)\n" "$mandir" "unix manpages"
printf " rpgdir: %-20s (%s)\n" "$rpgdir" "rpg files"
echo "run \`make' to build and then \`make install' to install."
Jump to Line
Something went wrong with that request. Please try again.