diff --git a/buildconf b/buildconf
index bda598e..957e2a2 100755
--- a/buildconf
+++ b/buildconf
@@ -1,6 +1,22 @@
 #!/bin/sh
 
-${LIBTOOLIZE:-libtoolize} --copy --automake --force
+LIBTOOLIZE="libtoolize"
+
+if [ "x`which $LIBTOOLIZE`" == "x" ];
+then
+  LIBTOOLIZE="glibtoolize";
+fi
+
+if [ "x`which $LIBTOOLIZE`" == "x" ];
+then
+  echo "Neither libtoolize nor glibtoolize could be found!";
+  exit 1
+fi
+
+
+
+
+${LIBTOOLIZE} --copy --automake --force
 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS
 ${AUTOHEADER:-autoheader}
 # copy the private libssh2_config.h.in to the examples dir so that
