--- a/storage/innodb_plugin/plug.in
+++ b/storage/innodb_plugin/plug.in
@@ -56,10 +56,8 @@ MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
   esac
   AC_SUBST(INNODB_DYNAMIC_CFLAGS)
 
-  AC_MSG_CHECKING(whether GCC atomic builtins are available)
-  # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
-  AC_TRY_RUN(
-    [
+  AC_CACHE_CHECK([whether GCC atomic builtins are available],
+		 [mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
       int main()
       {
 	long	x;
@@ -96,21 +94,18 @@ MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
 
 	return(0);
       }
-    ],
-    [
-      AC_DEFINE([HAVE_IB_GCC_ATOMIC_BUILTINS], [1],
-                [GCC atomic builtins are available])
-      AC_MSG_RESULT(yes)
-    ],
-    [
-      AC_MSG_RESULT(no)
-    ]
-  )
+    ], [mysql_cv_gcc_atomic_builtins=yes],
+       [mysql_cv_gcc_atomic_builtins=no],
+       [mysql_cv_gcc_atomic_builtins=no])])
+
+  if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
+    AC_DEFINE(HAVE_IB_GCC_ATOMIC_BUILTINS, 1,
+              [Define to 1 if compiler provides atomic builtins.])
+  fi
 
-  AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
-  # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
-  AC_TRY_RUN(
-    [
+
+  AC_CACHE_CHECK([whether pthread_t can be used by GCC atomic builtins],
+		 [mysql_cv_gcc_atomic_builtins_pthread_t], [AC_TRY_RUN([
       #include <pthread.h>
       #include <string.h>
 
@@ -127,16 +122,14 @@ MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
 
         return(0);
       }
-    ],
-    [
-      AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_GCC], [1],
-                [pthread_t can be used by GCC atomic builtins])
-      AC_MSG_RESULT(yes)
-    ],
-    [
-      AC_MSG_RESULT(no)
-    ]
-  )
+    ], [mysql_cv_gcc_atomic_builtins_pthread_t=yes],
+       [mysql_cv_gcc_atomic_builtins_pthread_t=no],
+       [mysql_cv_gcc_atomic_builtins_pthread_t=no])])
+
+  if test "x$mysql_cv_gcc_atomic_builtins_pthread_t" = xyes; then
+    AC_DEFINE(HAVE_IB_ATOMIC_PTHREAD_T_GCC, 1,
+              [Define to 1 if pthread_t can be used by GCC atomic builtins])
+  fi
 
   AC_MSG_CHECKING(whether Solaris libc atomic functions are available)
   # Define HAVE_IB_SOLARIS_ATOMICS if _all_ of the following
@@ -156,7 +149,6 @@ MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
     AC_DEFINE([HAVE_IB_SOLARIS_ATOMICS], [1],
       [Define to 1 if Solaris libc atomic functions are available]
     )
-  fi
 
   AC_MSG_CHECKING(whether pthread_t can be used by Solaris libc atomic functions)
   # either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
@@ -230,6 +222,8 @@ MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
       AC_MSG_RESULT(no)
     ]
   )
+  fi
+
   ])
 
 # vim: set ft=config:
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -344,55 +344,6 @@ void print_find_structs()
 }
 
 
-static void usage(int version)
-{
-  printf("%s  Ver 3.6 Distrib %s, for %s (%s)\n",
-	 my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
-  if (version)
-    return;
-  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
-  puts("This program generates a perfect hashing function for the sql_lex.cc");
-  printf("Usage: %s [OPTIONS]\n\n", my_progname);
-  my_print_help(my_long_options);
-}
-
-
-extern "C" my_bool
-get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
-	       char *argument __attribute__((unused)))
-{
-  switch(optid) {
-  case 'V':
-    usage(1);
-    exit(0);
-  case 'I':
-  case '?':
-    usage(0);
-    exit(0);
-  case '#':
-    DBUG_PUSH(argument ? argument : default_dbug_option);
-    break;
-  }
-  return 0;
-}
-
-
-static int get_options(int argc, char **argv)
-{
-  int ho_error;
-
-  if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option)))
-    exit(ho_error);
-
-  if (argc >= 1)
-  {
-    usage(0);
-     exit(1);
-  }
-  return(0);
-}
-
-
 int check_dup_symbols(SYMBOL *s1, SYMBOL *s2)
 {
   if (s1->length!=s2->length || strncmp(s1->name,s2->name,s1->length))
@@ -443,12 +394,6 @@ int check_duplicates()
 
 int main(int argc,char **argv)
 {
-  MY_INIT(argv[0]);
-  DBUG_PROCESS(argv[0]);
-
-  if (get_options(argc,(char **) argv))
-    exit(1);
-
   /* Broken up to indicate that it's not advice to you, gentle reader. */
   printf("/*\n\n  Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
 
@@ -549,7 +494,6 @@ static SYMBOL *get_hash_symbol(const cha
   }\n\
 }\n"
 );
-  my_end(0);
   exit(0);
 }
 
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -26,7 +26,6 @@ INCLUDES =		@ZLIB_INCLUDES@ \
 WRAPLIBS=		@WRAPLIBS@
 SUBDIRS =		share
 libexec_PROGRAMS =	mysqld
-EXTRA_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 
 noinst_LTLIBRARIES=	libndb.la \
