diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 83a37c366cbc31e02cd62afcbe29af530982bf1f..c273db80641c61e336f7d8421e16e6b68344d391 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.647 2008/01/07 21:37:57 chrfranke Exp $
+$Id: CHANGELOG,v 1.648 2008/01/23 13:43:24 ballen4705 Exp $
 
 The most recent version of this file is:
 http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup
@@ -34,6 +34,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [BA] Fixed autogen.sh script so that it uses 'grep -n 1' if 'grep -1'
+       fails.  Needed for Mac OS X 10.4. Uck.
+ 
   [CF] Windows: Added IOCTL_STORAGE_PREDICT_FAILURE. This allows access
        to ATA SMART status and data if other calls do not work.
        Thanks to Jaroslaw Kowalski for pointing this out.
diff --git a/sm5/autogen.sh b/sm5/autogen.sh
index 651704cffa34ad63d7a91446eecb68d3e5cf815e..3dacf0c80980b5ddb36366fabd6f2756d2cd9ed7 100755
--- a/sm5/autogen.sh
+++ b/sm5/autogen.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: autogen.sh,v 1.16 2008/01/02 19:34:55 bkorb Exp $
+# $Id: autogen.sh,v 1.17 2008/01/23 13:43:24 ballen4705 Exp $
 #
 # Generate ./configure from config.in and Makefile.in from Makefile.am.
 # This also adds files like missing,depcomp,install-sh to the source
@@ -68,7 +68,14 @@ case "$AUTOMAKE" in
   *automake-1.[78]|*automake17)
     ;;
   *)
-    ver="`$AUTOMAKE --version | head -1 | sed -n 's,^.*\([12]\.[.0-9]*[-pl0-9]*\).*$,\1,p'`"
+    # first see if we need 'head -1' or 'head -n 1'
+    echo hello | head -1 > /dev/null 2> /dev/null
+    if [ $? ] ; then 
+        ver="`$AUTOMAKE --version | head -n 1 | sed -n 's,^.*\([12]\.[.0-9]*[-pl0-9]*\).*$,\1,p'`"
+    else
+        ver="`$AUTOMAKE --version | head -1 | sed -n 's,^.*\([12]\.[.0-9]*[-pl0-9]*\).*$,\1,p'`"
+    fi
+
     ver="${ver:-?.?.?}"
     case "$ver" in
       1.[78]*|1.9.[1-6]|1.10) ver= ;;