Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 92 lines (83 sloc) 2.24 KB
#!/bin/sh
VERSION="2.4.0"
# Parse options
while [ $# -gt 0 ]; do
optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
case "$1" in
--prefix=*)
PREFIX=$optarg
shift
;;
--packaging)
PACKAGING=1
shift
;;
*)
shift
;;
esac
done
# Verify presence of ruby
RUBY=`which ruby` # XXX: we're assuming which is in PATH
if [ $? -ne 0 ]; then
echo "ERROR: ruby not found" 1>&2
exit 1
else
echo "Ruby found at $RUBY"
fi
# Verify ruby version
RUBYMAJOR=`"$RUBY" -v | cut -d' ' -f2 | cut -b1`
RUBYMINOR=`"$RUBY" -v | cut -d' ' -f2 | cut -b3`
if [ $RUBYMAJOR -lt 1 -o $RUBYMINOR -lt 8 ]; then
echo "ERROR: ruby version $RUBYMAJOR.$RUBYMINOR.x too low, need at least 1.8.0" 1>&2
exit 1
else
echo "Ruby version $RUBYMAJOR.$RUBYMINOR.x"
fi
if [ "$PREFIX." = "." -o "$PREFIX" = "/usr/local" ]; then
LIBDIR=`echo "require 'rbconfig'; puts Config::CONFIG['sitedir'].sub(Regexp.new('^$PREFIX\/?'),'')" | "$RUBY"`
ARCHDIR=`echo "require 'rbconfig'; puts Config::CONFIG['sitearchdir'].sub(Regexp.new('^$PREFIX\/?'),'')" | "$RUBY"`
else
LIBDIR=`echo "require 'rbconfig'; puts Config::CONFIG['rubylibdir'].sub(Regexp.new('^$PREFIX\/?'),'')" | "$RUBY"`
ARCHDIR=`echo "require 'rbconfig'; puts Config::CONFIG['archdir'].sub(Regexp.new('^$PREFIX\/?'),'')" | "$RUBY"`
fi
# FIXME: Such a hack... really should translate Rakefile
RAKE=`which rake`
if [ "." = "$RAKE." ]; then
echo "ERROR: rake not found" 1>&2
exit 1
fi
GEMBUILD=""
GEMINSTALL=""
GEMREMOVE=""
GEM=`which gem` # XXX: we're assuming which is in PATH
if [ "." != "$GEM." ]; then
GEMBUILD="\"$RAKE\" gem"
GEMREMOVE="\"$GEM\" uninstall rubygame"
if [ "." = "$PACKAGING." ]; then
GEMINSTALL="\"$GEM\" install pkg/rubygame-$VERSION.gem"
else
#GEMINSTALL="cp xgame-$VERSION.gem '\$(prefix)/$INSTALLDIR/xgame.gem'"
#GEMINSTALL="mkdir -p '\$(prefix)/../tmp/'; cp pkg/rubygame-$VERSION.gem '\$(prefix)/../tmp/rubygame.gem'" # XXX: This assumes prefix is only one level deeper than we want... hmm...
GEMINSTALL=""
fi
fi
cat 1>Makefile <<EOT
prefix=$PREFIX
all: build gem
build:
"$RAKE" build
gem: build
$GEMBUILD
clean:
"$RAKE" clean
distclean: clean
rm -rf pkg/
rm -f Makefile
install:
RUBYLIBDIR=\$(prefix)/$LIBDIR RUBYARCHDIR=\$(prefix)/$ARCHDIR $RAKE install
$GEMINSTALL
uninstall:
"$RAKE" uninstall
$GEMREMOVE
EOT