#!/bin/bash
ARCH=$(uname -m)
mkdir /usr/src/mariadb-connector-odbc/build
cd /usr/src/mariadb-connector-odbc/build
if [ -f /etc/rpi-issue ]; then
    DM_DIR=/usr/lib/arm-linux-gnueabihf cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb -L/usr/lib"
else
    DM_DIR=/usr/lib/$ARCH-linux-gnu cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb" -DWITH_SSL=OPENSSL -DCMAKE_INSTALL_PREFIX=/usr/local
fi
make
make install

cat << EOF > /etc/ld.so.conf.d/99-iiab.conf
/usr/local/lib/mariadb/
EOF

ldconfig
