diff --git a/bin/mklib b/bin/mklib
index 9bac29e..70982d6 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -49,8 +49,8 @@ expand_archives() {
                     /*) ;;
                     *)  FILE="$ORIG_DIR/$FILE" ;;
                 esac
-                MEMBERS=`ar t $FILE`
-                ar x $FILE
+                MEMBERS=`$AR t $FILE`
+                $AR x $FILE
                 for MEMBER in $MEMBERS ; do
                     NEWFILES="$NEWFILES $DIR/$MEMBER"
                 done
@@ -77,7 +77,7 @@ expand_archives() {
 make_ar_static_lib() {
     OPTS=$1
     shift;
-    RANLIB=$1
+    _RANLIB=$1
     shift;
     LIBNAME=$1
     shift;
@@ -87,11 +87,11 @@ make_ar_static_lib() {
     rm -f ${LIBNAME}

     # make static lib
-    ar ${OPTS} ${LIBNAME} ${OBJECTS}
+    $AR ${OPTS} ${LIBNAME} ${OBJECTS}

     # run ranlib
-    if [ ${RANLIB} = 1 ] ; then
-        ranlib ${LIBNAME}
+    if [ ${_RANLIB} = 1 ] ; then
+        $RANLIB ${LIBNAME}
     fi

     echo ${LIBNAME}
@@ -313,9 +313,9 @@ case $ARCH in
        if [ "x$LINK" = "x" ] ; then
            # -linker was not specified so set default link command now
             if [ $CPLUSPLUS = 1 ] ; then
-                LINK=g++
+                LINK=$CXX
             else
-                LINK=gcc
+                LINK=$CC
             fi
        fi
