#!/bin/sh

gnu_type=`dpkg-architecture -qDEB_HOST_GNU_TYPE`

# re-configure
dh_auto_configure -- \
          -DCMAKE_INSTALL_PREFIX:PATH=/usr \
          -DMYSQLCPPCONN_ICU_ENABLE:BOOL=0 \
          -DMYSQLCLIENT_STATIC_LINKING:BOOL=0 \
          \
          -DMYSQLCPPCONN_BUILD_EXAMPLES:BOOL=1

cd obj-$gnu_type && make
cd ..

# // Connection properties
# #define EXAMPLE_DB   "test"
# #define EXAMPLE_HOST "tcp://127.0.0.1:3306"
# #define EXAMPLE_USER "root"
# #define EXAMPLE_PASS "root"
mysql -u root -h localhost << EOF
UPDATE mysql.user SET Password=password('root') where User='root';
UPDATE mysql.user SET plugin='' where User='root';
flush privileges;
CREATE DATABASE IF NOT EXISTS test;
EOF

find obj-$gnu_type -name "libmysqlcppconn*so*" -exec rm {} \;
cd obj-$gnu_type
examples/connect
examples/connection_meta_schemaobj
examples/debug
examples/dynamic_load
examples/exceptions
examples/prepared_statement
examples/resultset
examples/resultset_binary
examples/resultset_meta
examples/resultset_types
examples/statement
