#!/bin/sh

. config/options

cd $BUILD/$1*

mkdir -p objdir-host
cd objdir-host
do_configure host \
  --with-zlib-dir="$ROOT/$TOOLCHAIN"
make
cd ..

HOST_GEN_LEX_HASH="$ROOT/$BUILD/$1*/objdir-host/sql/gen_lex_hash"
sed -i "s:\./gen_lex_hash:${HOST_GEN_LEX_HASH}:g" sql/Makefile.in

export ac_cv_c_stack_direction=-1
export ac_cv_sys_restartable_syscalls=yes

do_configure target \
  --libexecdir=/usr/sbin \
  --with-unix-socket-path=/var/run/mysqld/mysqld.sock \
  --with-tcp-port=3306 \
  --with-low-memory \
  --enable-largefile \
  --with-big-tables \
  --with-mysqld-user=root \
  --with-extra-charsets=all \
  --with-charset=utf8 \
  --with-collation=utf8_unicode_ci \
  --with-pthread \
  --with-named-thread-libs=-lpthread \
  --enable-thread-safe-client \
  --enable-assembler \
  --enable-local-infile \
  --without-debug \
  --without-docs \
  --without-man \
  --with-readline \
  --without-libwrap \
  --without-pstack \
  --with-server \
  --without-embedded-server \
  --without-libedit \
  --with-query-cache \
  --without-plugin-partition \
  --without-plugin-daemon_example \
  --without-plugin-ftexample \
  --without-plugin-archive \
  --without-plugin-blackhole \
  --without-plugin-example \
  --without-plugin-federated \
  --without-plugin-ibmdb2i \
  --without-plugin-innobase \
  --without-plugin-innodb_plugin \
  --without-plugin-ndbcluster \

make
make_install
mv .install/usr/lib/mysql/* .install/usr/lib
