]> spindle.queued.net Git - midori/commitdiff
Add 'configure' like waf wrapper
authorChristian Dywan <christian@twotoasts.de>
Sun, 10 Aug 2008 12:38:47 +0000 (14:38 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 10 Aug 2008 12:38:47 +0000 (14:38 +0200)
.gitignore
configure [new file with mode: 0755]

index a033ed6b66dc1a2db1f0be43ebc0a3505d504fdf..f0d9bb197535eced633be6f8ec59ac12594c7842 100644 (file)
@@ -6,7 +6,6 @@
 aclocal.m4
 autom4te.cache
 config.*
-configure
 depcomp
 install-sh
 libtool
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..28e8a72
--- /dev/null
+++ b/configure
@@ -0,0 +1,151 @@
+#! /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[1m"
+    RED="\033[91m"
+    YELLOW="\033[01;93m"
+    GREEN="\033[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 Python interpreter. Honours $PYTHON if set. Stores path to
+# interpreter in $PYTHON.
+#
+checkPython()
+{
+       if [ -z "$PYTHON" ] ; then
+           PYTHON=`which python 2>/dev/null`
+       fi
+       printf "Checking for Python\t\t\t:  "
+       if [ ! -x "$PYTHON" ] ; then
+         printf $RED"not found!"$NORMAL"\n"
+         echo "Please make sure that the Python interpreter is available in your PATH"
+         echo "or invoke configure using the PYTHON flag, e.g."
+         echo "$ PYTHON=/usr/local/bin/python configure"
+         exit $EXIT_FAILURE
+       fi
+       printf $GREEN"$PYTHON"$NORMAL"\n"
+}
+
+# Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
+# Requires that $PYTHON is set.
+#
+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
+               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:
+       @if test -n "\$(DESTDIR)"; then \\
+           $WAF install --destdir="\$(DESTDIR)"; \\
+       else \\
+           $WAF install; \\
+       fi;
+
+uninstall:
+       @if test -n "\$(DESTDIR)"; then \\
+           $WAF uninstall --destdir="\$(DESTDIR)"; \\
+       else \\
+           $WAF uninstall; \\
+       fi;
+
+clean:
+       @$WAF clean
+
+distclean:
+       @$WAF distclean
+       @-rm -rf _build_
+       @-rm -f Makefile
+
+check:
+       @$WAF check
+
+dist:
+       @$WAF dist
+
+EOF
+}
+
+checkPython
+checkWAF
+
+echo "calling waf configure with parameters"
+$WAF configure $* || exit $EXIT_ERROR
+
+if [ -f "Makefile" ] ; then
+    echo ""
+else
+    generateMakefile
+fi
+
+exit $EXIT_SUCCESS