Steam Boiler / configure

#! /bin/sh

# waf configure wrapper

# Fancy colors used to beautify the output a bit.
#
if [ "$NOCOLOR" ] ; then
    NORMAL=""
    BOLD=""
    RED=""
    YELLOW=""
    GREEN=""
else
    NORMAL='\033[0m'
    BOLD='\033[01;1m'
    RED='\033[01;91m'
    YELLOW='\033[00;33m'
    GREEN='\033[01;92m'
fi

EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_ERROR=2
EXIT_BUG=10

CUR_DIR=$PWD

#possible relative path
WORKINGDIR=`dirname $0`
cd $WORKINGDIR
#abs path
WORKINGDIR=`pwd`
cd $CUR_DIR


# Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
#
checkWAF()
{
	printf "Checking for WAF\t\t\t : "
	#installed miniwaf in sourcedir
	if [ -z "$WAF" ] ; then
	    if [ -f "${WORKINGDIR}/waf" ] ; then
		WAF="${WORKINGDIR}/waf"
		if [ ! -x "$WAF" ] ; then
		    chmod +x $WAF
		fi
	    fi
	fi
	if [ -z "$WAF" ] ; then
	    if [ -f "${WORKINGDIR}/waf-light" ] ; then
		${WORKINGDIR}/waf-light --make-waf
		[ $? -ne 0 ] && exit $EXIT_ERROR
	        WAF="${WORKINGDIR}/waf"
	    fi
	fi
	#global installed waf with waf->waf.py link
	if [ -z "$WAF" ] ; then
	    WAF=`which waf 2>/dev/null`
	fi
	# neither waf nor miniwaf could be found
	if [ ! -x "$WAF" ] ; then
	    printf "$RED""not found""$NORMAL""\n"
	    echo "Go to http://code.google.com/p/waf/"
	    echo "and download a waf version"
	    exit $EXIT_FAILURE
	else
	  printf "$GREEN""$WAF""$NORMAL""\n"
	fi
}

# Generates a Makefile. Requires that $WAF is set.
#
generateMakefile()
{
	cat > Makefile << EOF
#!/usr/bin/make -f
# Waf Makefile wrapper
WAF_HOME=$CUR_DIR

all:
	@$WAF build

all-debug:
	@$WAF -v build

all-progress:
	@$WAF -p build

install:
	$WAF install

uninstall:
	$WAF uninstall

clean:
	@$WAF clean

distclean:
	@$WAF distclean
	@-rm -f Makefile

distcheck:
	@$WAF distcheck

dist:
	@$WAF dist

.PHONY: clean dist distclean distcheck uninstall install all

EOF
}

checkWAF
generateMakefile

"${WAF}" configure $*
exit $?
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.