[doit] Switch to using args rather than env vars
Now to invoke doit rather than:
ARCHES='arm sh' FETCH=1 ./doit
you do:
./doit -a 'arm sh' -f
There are also flags for using CCACHE and make parallelization:
./doit -a 'arm' -f -j64 -c
diff --git a/doit b/doit
index be095be..718dddd 100755
--- a/doit
+++ b/doit
@@ -2,17 +2,10 @@
OS=`uname`
HOSTARCH=`uname -m`
-PARALLEL=-j8
+PARALLEL=
GNU_FTP=ftp://ftp.gnu.org/gnu
ARCHIVES=archives
-if [ -z "$ARCHES" ]; then
- echo need to specify architectures to build in the ARCHES environment variable
- echo ie. ARCHES=\"arm sh\"
- exit 1
-fi
-
-
if [ "$OS" = "Linux" ]; then
COUNT=`grep processor /proc/cpuinfo | wc -l`
PARALLEL=-j`expr $COUNT + $COUNT`
@@ -20,7 +13,7 @@
if [ "$OS" = "Darwin" ]; then
export CPPFLAGS=-I/opt/local/include
export LDFLAGS=-L/opt/local/lib
- export CXXFLAGS="-fbracket-depth=1024"
+ export CXXFLAGS="-fbracket-depth=1024"
fi
if [ "$OS" = "FreeBSD" ]; then
export CPPFLAGS=-I/usr/local/include
@@ -34,6 +27,37 @@
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 ccache"
+ echo " -f fetch source releases from upstream"
+ echo " -j<#> use <#> parallel workers to build [default: 8]"
+ exit 1
+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 "parse error :(" ; exit 1 ;;
+ esac
+done
+
+
+if [ -z "$ARCHES" ]; then
+ echo need to specify architectures to build
+ echo ie -a "arm sh"
+ exit 1
+fi
+
export CC="cc"
export CXX="c++"
@@ -45,9 +69,6 @@
# load GCCVER and BINVER
. toolvers
-if [ -z "$FETCH" ]; then
- FETCH=1
-fi
if [ "$FETCH" = "1" ]; then
if [ ! -f binutils-$BINVER.tar.bz2 ]; then
wget -P $ARCHIVES -N $GNU_FTP/binutils/binutils-$BINVER.tar.bz2