#!/usr/bin/env bash name=$(basename $0) if [ -z "$1" ] ; then echo $name: usage $name dir exit 1 fi if [ "$(echo $1 | grep / | grep -v grep)" ] ; then echo $name: use the script from the parent directory of the thing to build exit 1; fi build=/tmp/$$.build cp -r $1 $build cd $build make cd - cp $build/$1 $1 rm -rf $build