#! /bin/sh # @WARNING@ # It is used to compile on remote hosts ### # Configuration ### # Where to install the stuff into (REMOTE_PREFIX gets fixed by the makefile) PREFIX=$REMOTE_PREFIX if echo $PREFIX | egrep '^/' > /dev/null ; then echo "Prefix is an absolute path. Good, it makes configure happy" else echo "Change prefix to an absolute path to keep configure happy" PREFIX="$HOME/$PREFIX" fi echo "(PREFIX=$PREFIX)" # Where extra libraries are installed (if any) LD_LIBRARY_PATH="$PREFIX/lib" # Extra environment to pass to configure CONFIGURE_ENV="" # Argument of configure CONFIGURE_ARGS="--prefix=$PREFIX/@PACKAGE@" # make target MAKE_ALL="all" MAKE_INSTALL=install MAKE_CHECK="-k check" echo "Launching $0" ### # Magic to search a working shell (from autobook) ### # Zsh is not Bourne compatible without the following: if test -n "$ZSH_VERSION"; then emulate sh NULLCMD=: fi # Bash is not POSIX compliant without the following: test -n "$BASH_VERSION" && set -o posix SHELL="${SHELL-/bin/sh}" if test x"$1" = x--re-executed; then # Functional shell was found. Remove option and continue shift elif "$SHELL" -c 'foo () { exit 0; }; foo' 2>/dev/null && "$SHELL" -c 'export toto=tutu' 2>/dev/null ; then # The current shell works already! echo "Current shell ($SHELL) working" else # Try alternative shells that (sometimes) support functions for cmd in bash sh ash bsh ksh zsh sh5 do for dir in `echo $PATH | sed -e 's/:/ /g'` /bin /usr/bin do shell="$dir/$cmd" if (test -f "$shell" || test -f "$shell.exe") && "$shell" -c 'foo () { exit 0; }; foo' 2>/dev/null && "$shell" -c 'export toto=tutu' 2>/dev/null then # Re-execute with discovered functional shell echo "Reexecute $0 $@ with shell $shell" SHELL="$shell" exec "$shell" "$0" --re-executed ${1+"$@"} fi done done echo "Unable to locate a shell interpreter with function support and export syntax" >&2 exit 1 fi ### # Real script ### if [ "x$CC" = x ] ; then echo "CC not set. Search for xlC" xlC=`which xlC` if [ "x$xlC" != x ] ; then echo "Found (in $xlC)" CONFIGURE_ARGS="$CONFIGURE_ARGS CC=xlC" else echo "Not found. Stick to the defaults" fi fi # expend the path for solaris PATH="$PATH:/usr/xpg4/bin" export PATH fail () { echo $1; echo CONFIG-LOG-DUMP-BEGIN cat config.log echo CONFIG-LOG-DUMP-END exit 1; } printenv; echo PATH=$PATH cd $PREFIX/src || fail "Cannot cd to $PREFIX/src" do_cmd() { echo "Do $1" eval `echo $1` 2>&1 || fail "$2" echo "Done $1" } if echo $@ | grep clean >/dev/null ; then for name in @PACKAGE@* ; do if test "$name" != "@PACKAGE@-@VERSION@.tar.gz" ; then echo "XXX Remove $name"; rm -rf $name; fi; done; echo "XXX Untar @PACKAGE@-@VERSION@" do_cmd "gunzip @PACKAGE@-@VERSION@.tar.gz" "Cannot gunzip" do_cmd "tar xf @PACKAGE@-@VERSION@.tar" "Cannot untar" fi if echo $@ | grep touch >/dev/null ; then echo "XXX Touch everything within the tarball" find @PACKAGE@-@VERSION@ -type f | while read f; do touch $f;done sleep 2 fi cd @PACKAGE@-@VERSION@ || fail "Cannot cd to @PACKAGE@-@VERSION@" if echo $@ | grep config >/dev/null ; then do_cmd "env $CONFIGURE_ENV \ ./configure $CONFIGURE_ARGS" "Cannot configure" fi if echo $@ | grep compile >/dev/null ; then do_cmd "make $MAKE_ALL" "Cannot make" fi if echo $@ | grep install >/dev/null ; then do_cmd "make $MAKE_INSTALL" "Cannot make install" fi if echo $@ | grep check >/dev/null ; then do_cmd "make $MAKE_CHECK 2>&1" || fail "Cannot make check" fi echo Remote compilation sucessful. echo echo echo CONFIG-LOG-DUMP-BEGIN cat config.log echo CONFIG-LOG-DUMP-END echo echo echo Remote compilation sucessful. exit 0