--- /dev/null
+#
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/uclibc++.mk
+
+PKG_NAME:=mysql
+PKG_VERSION:=5.1.73
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=\
+ http://mysql.he.net/Downloads/MySQL-5.1/ \
+ http://www.linorg.usp.br/mysql/Downloads/MySQL-5.1/ \
+ http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.1/ \
+ http://mirror.switch.ch/ftp/mirror/mysql/Downloads/MySQL-5.1/
+
+PKG_MD5SUM:=887f869bcc757957067b9198f707f32f
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
+PKG_LICENSE:=GPL-2.0
+
+PKG_BUILD_DEPENDS:=libncurses libreadline
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+PKG_FIXUP:=libtool
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libmysqlclient/Default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=$(CXX_DEPENDS) +zlib
+ TITLE:=MySQL client library
+ URL:=http://dev.mysql.com/
+endef
+
+define Package/mysql-server
+ SECTION:=utils
+ CATEGORY:=Utilities
+ DEPENDS:=+libmysqlclient +libpthread +libncursesw +libreadline
+ TITLE:=MySQL Server
+ URL:=http://dev.mysql.com/
+ SUBMENU:=database
+endef
+
+define Package/libmysqlclient
+ $(call Package/libmysqlclient/Default)
+endef
+
+define Package/libmysqlclient-r
+ $(call Package/libmysqlclient/Default)
+ TITLE += threadsafe
+ DEPENDS+= +libpthread
+endef
+
+TARGET_CXX=g++-uc
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+ --enable-shared \
+ --enable-static \
+ --enable-thread-safe-client \
+ --disable-assembler \
+ --with-pthread \
+ --with-server \
+ --without-mysqlmanager \
+ --with-mysqld-user=root \
+ --with-unix-socket-path=/tmp \
+ --without-libwrap \
+ --with-low-memory \
+ --without-embedded-server \
+ --without-query-cache \
+ --without-ssl \
+ --without-docs \
+ --without-man \
+ --without-readline \
+ --without-debug \
+ --with-named-thread-libs=-lpthread
+
+CONFIGURE_VARS += \
+ mysql_cv_compress=yes \
+ mysql_cv_gethostname_style=glibc2 \
+ mysql_cv_gcc_atomic_builtins=yes \
+ mysql_cv_gcc_atomic_builtins_pthread_t=yes \
+ ac_cv_c_stack_direction=-1
+
+define Build/Compile
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="include" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+ $(MAKE) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="include" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+ g++ -I $(PKG_BUILD_DIR)/include \
+ -o $(PKG_BUILD_DIR)/sql/gen_lex_hash \
+ $(PKG_BUILD_DIR)/sql/gen_lex_hash.cc
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)/libmysql" \
+ CC="g++" \
+ CFLAGS="$(HOST_CFLAGS)" \
+ CPPFLAGS="$(HOST_CFLAGS)" \
+ LDFLAGS="$(HOST_LDFLAGS)" \
+ conf_to_src
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="libmysql" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+ $(MAKE) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="libmysql" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="libmysql_r" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+ $(MAKE) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="libmysql_r" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+ $(MAKE) -C "$(PKG_BUILD_DIR)" \
+ SUBDIRS="scripts" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ bin_SCRIPTS="mysql_config" \
+ install
+ +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all
+ $(MAKE) -C "$(PKG_BUILD_DIR)" \
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql_config $(1)/usr/bin/
+ ln -sf $(STAGING_DIR)/usr/bin/mysql_config $(2)/bin/
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/mysql $(1)/usr/include/
+ # NOTE: needed for MySQL-Python
+ $(CP) $(PKG_BUILD_DIR)/include/mysqld_error.h $(1)/usr/include/mysql/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/mysql $(1)/usr/lib/
+ rm -f $(1)/usr/lib/mysql/libmysqlclient.la
+endef
+
+define Package/libmysqlclient/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/mysql/libmysqlclient.so.* $(1)/usr/lib/
+endef
+define Package/libmysqlclient-r/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/mysql/libmysqlclient_r.so.* $(1)/usr/lib/
+endef
+
+define Package/mysql-server/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/mysqld $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/myisamchk $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysqladmin $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysqldump $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql_install_db $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/my_print_defaults $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/etc/init.d/
+ $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld
+ $(INSTALL_CONF) conf/my.cnf $(1)/etc/
+ $(INSTALL_DIR) $(1)/usr/share/mysql
+ $(INSTALL_DIR) $(1)/usr/share/mysql/english
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/english/errmsg.sys $(1)/usr/share/mysql/english
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/fill_help_tables.sql $(1)/usr/share/mysql/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/mysql_system_tables.sql $(1)/usr/share/mysql/
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/mysql_system_tables_data.sql $(1)/usr/share/mysql/
+endef
+
+define Package/mysql-server/conffiles
+/etc/my.cnf
+endef
+
+$(eval $(call BuildPackage,mysql-server))
+$(eval $(call BuildPackage,libmysqlclient))
+$(eval $(call BuildPackage,libmysqlclient-r))
--- /dev/null
+[client]
+port = 3306
+socket = /var/run/mysqld.sock
+
+[mysqld]
+user = root
+socket = /var/run/mysqld.sock
+port = 3306
+basedir = /usr
+
+############ Don't put this on the NAND #############
+# Figure out where you are going to put the databases
+# And run mysql_install_db --force
+datadir = /mnt/data/mysql/
+
+######### This should also not go on the NAND #######
+tmpdir = /mnt/data/tmp/
+
+skip-external-locking
+
+bind-address = 127.0.0.1
+
+# Fine Tuning
+key_buffer = 16M
+max_allowed_packet = 16M
+thread_stack = 192K
+thread_cache_size = 8
+
+# Here you can see queries with especially long duration
+#log_slow_queries = /var/log/mysql/mysql-slow.log
+#long_query_time = 2
+#log-queries-not-using-indexes
+
+# The following can be used as easy to replay backup logs or for replication.
+#server-id = 1
+#log_bin = /var/log/mysql/mysql-bin.log
+#expire_logs_days = 10
+#max_binlog_size = 100M
+#binlog_do_db = include_database_name
+#binlog_ignore_db = include_database_name
+
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet = 16M
+
+[mysql]
+#no-auto-rehash # faster start of mysql but no tab completition
+
+[isamchk]
+key_buffer = 16M
+
+
--- /dev/null
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010-2011 OpenWrt.org
+
+START=95
+STOP=10
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+SERVICE_STOP_TIME=9
+
+error() {
+ echo "${initscript}:" "$@" 1>&2
+}
+
+start() {
+ local datadir=$(sed -n -e "s/^[[:space:]]*datadir[[:space:]]*=[[:space:]]*[\"']\?\([^\"']*\)[\"']\?/\1/p" /etc/my.cnf)
+ if [ ! -d "$datadir" ]; then
+ error "Error: datadir '$datadir' in /etc/my.cnf doesn't exist"
+ return 1
+ fi
+ if [ ! -f "$datadir/mysql/tables_priv.MYD" ]; then
+ error "Error: I didn't detect a privileges table, you might need to run mysql_install_db --force to initialize the system tables"
+ return 1
+ fi
+ service_start /usr/bin/mysqld
+}
+
+stop() {
+ service_stop /usr/bin/mysqld
+}
--- /dev/null
+--- a/scripts/mysql_install_db.sh
++++ b/scripts/mysql_install_db.sh
+@@ -322,7 +322,7 @@ then
+ fi
+
+ # Try to determine the hostname
+-hostname=`@HOSTNAME@`
++hostname=`cat /proc/sys/kernel/hostname`
+
+ # Check if hostname is valid
+ if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
--- /dev/null
+--- 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 \