Index: main/trunk/greenstone2/makegs2.sh
===================================================================
--- main/trunk/greenstone2/makegs2.sh	(revision 32007)
+++ main/trunk/greenstone2/makegs2.sh	(revision 32008)
@@ -39,5 +39,5 @@
 
 if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
-    echo "No recognised args provided"
+    echo "Launching with no args"
 fi
 
@@ -85,25 +85,49 @@
 echo "****************************************"    
 
+# Get the imagemagick precompiled binary for the OS system if compilation was successful
+if [[ "$status" == "0" && "x$getimagick" == "ximagemagick" ]]; then    
 
-imgpkg=
-if [ "x$getimagick" = "ximagemagick" ]; then
-   os=`uname`
+    imgpkg=
+    
+    os=`uname`
 
    if [ "x$os" = "xDarwin" ]; then
-       # by default, resort to the Mac Leopard (10.5) imagemagick binary
-       imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
+       # The imagemagick binary built on El Capitan (10.11) was made backwards compatible up to and including Mountain Lion (10.8) using the mmacosx-version-min flag.
+       # The kernel version of Mountain Lion is 12.6.0. For El Capitan it's 15.6.0
+       # So any kernel version less than 12, we'll use the Leopard (10.5) imagemagick binary, and for greater, we'll use the El Capitan imgmagick binary
+    
+       # by default on Macs, will resort to the MountainLion-and-later compatible ElCapitan binary
+       imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
 
        kernelVersion=`uname -r`
+       
+       # kernel version is something like 15.6.0, need the major version number to do integer (not float) comparisons
+
+       # https://stackoverflow.com/questions/20348097/bash-extract-string-before-a-colon
+       # doesn't work, even when put into backticks:
+       # majorKernelVersion=sed 's/\..*//'
+       
+       # Using pure bash solution to substring before first period mark
+       # NOTE: two percent signs gets chars up to the first occurrence of period mark. Single percent sign gets chars up to last period mark.
+       majorKernelVersion=${kernelVersion%%\.*}
+       echo "MacOS major kernel version: $majorKernelVersion"
+
+       # bash evaluates string as integer/vice-versa depending on context
+       # https://unix.stackexchange.com/questions/232384/argument-string-to-integer-in-bash
+       # http://tldp.org/LDP/abs/html/comparison-ops.html
+
        # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
-       if [ "x$kernelVersion" = "x15.6.0" ]; then
-	   echo "Getting imagemagick built for El Capitan"
-	   imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
+       # For MacOS versions older than Mountain Lion/10.8 (kernel 12.6.0) use the Mac Leopard (10.5) imagemagick binary
+       if [ "$majorKernelVersion" -lt "12" ]; then
+	   echo "Getting imagemagick built on Mac Leopard"
+	   imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
        else
-	   echo "Getting imagemagick built on Mac Leopard"
+	   echo "Getting imagemagick built for El Capitan 10.11 (15.6.0) that's compatible with Mountain Lion 10.8 (kernel v 12.6.0) and onwards"
        fi
 
        pushd ext
        curl $imgpkg > imagemagick.tar.gz
-       tar -xvzf imagemagick.tar.gz
+       tar -xzf imagemagick.tar.gz
+       rm -rf ../bin/darwin/imagemagick
        mv imagemagick/darwin ../bin/darwin/imagemagick
        popd
@@ -115,11 +139,12 @@
 	   echo "Getting 64 bit imagemagick precompiled binary"
 	   wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
-	   tar -xvzf imagemagick-linux-x64.tar.gz
+	   tar -xzf imagemagick-linux-x64.tar.gz
        else
 	   echo "Getting 32 bit imagemagick precompiled binary"
 	   wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
-	   tar -xvzf imagemagick-linux.tar.gz
+	   tar -xzf imagemagick-linux.tar.gz
        fi
-
+ 
+       rm -rf ../bin/linux/imagemagick
        mv imagemagick/linux ../bin/linux/imagemagick
        popd
