[doit] Use posix getopts for arg parsing
diff --git a/doit b/doit
index e4193a0..384aab9 100755
--- a/doit
+++ b/doit
@@ -8,7 +8,19 @@
 ARCHIVES=archives
 PATCHES=./patches/
 # Get absolute path, will spawn a subshell then exit so our pwd is retained
-SCRIPTROOT=$(cd "$(dirname $BASH_SOURCE[0])" && pwd)
+SCRIPTROOT=$(cd "$(dirname $0)" && pwd)
+
+function help()
+{
+    echo "Options"
+    echo " -a <arch list>               architectures to build"
+    echo "    example: -a 'arm x86'"
+    echo " -c                           use compilation cache (ccache must be installed)"
+    echo " -f                           fetch source releases from upstream"
+    echo " -h|-?                        display this help message"
+    echo " -j<#>                        use <#> parallel workers to build"
+    exit 1
+}
 
 function log()
 {
@@ -63,27 +75,20 @@
     HOSTARCH=x86_64
 fi
 
-ARGS=`getopt -o a:cfj: --long arch:,cache,fetch,parallel:  -- "$@"`
-
 if [ $# == "0" ]; then
-    echo "Options"
-    echo " -a <arch list>               architectures to build"
-    echo "    example: -a 'arm x86'"
-    echo " -c                           use compilation cache (ccache must be installed)"
-    echo " -f                           fetch source releases from upstream"
-    echo " -j<#>                        use <#> parallel workers to build [default: 8]"
-    exit 1
+    help
 fi
 
-eval set -- "$ARGS"
-while true; do
-    case "$1" in
-        -a|--arch ) ARCHES=$2 ; shift 2 ;;
-        -c|--cache ) CCACHE=1 ; shift ;;
-        -j|--parallel ) PARALLEL="-j$2" ; shift 2 ;;
-        -f|--fetch ) FETCH=1 ; shift ;;
-        -- ) shift ; break ;;
-        * ) echo "unrecognized option '$1'" ; exit 1 ;;
+while getopts a:cfhj:? arg
+do
+    case $arg in
+        a ) ARCHES=$OPTARG ;;
+        c ) CCACHE=1 ;;
+        j ) PARALLEL="-j$OPTARG" ;;
+        f ) FETCH=1 ;;
+        h ) help ;;
+        ? ) help ;;
+        * ) echo "unrecognized option '$arg'" ; exit 1 ;;
     esac
 done
 
@@ -102,6 +107,7 @@
 export CXX="ccache $CXX"
 fi
 
+log echo "ARCHES='$ARCHES' PARALLEL='$PARALLEL' FETCH='$FETCH' CCACHE='$CCACHE'"
 # load GCCVER and BINVER
 . toolvers