#!/bin/bash
# Author:    Igor Calì (igor.cali0@gmail.com)
# last change 2025-06-13

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' wx-common|grep "install ok installed")
echo Checking for wx-common
if [ "" == "$PKG_OK" ]; then
  echo "Setting up wx-common."
  sudo apt-get --yes install wx-common
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libwxgtk3.2-dev|grep "install ok installed")
echo Checking for libwxgtk3.2-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libwxgtk3.2-dev."
  sudo apt-get --yes install libwxgtk3.2-dev
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' build-essential|grep "install ok installed")
echo Checking for build-essential
if [ "" == "$PKG_OK" ]; then
  echo "Setting up build-essential."
  sudo apt-get --yes install build-essential
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' xsltproc|grep "install ok installed")
echo Checking for xsltproc
if [ "" == "$PKG_OK" ]; then
  echo "Setting up xsltproc."
  sudo apt-get --yes install xsltproc
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' docbook-xsl|grep "install ok installed")
echo Checking for xsltproc
if [ "" == "$PKG_OK" ]; then
  echo "Setting up docbook-xsl."
  sudo apt-get --yes install docbook-xsl
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' poxml|grep "install ok installed")
echo Checking for poxml
if [ "" == "$PKG_OK" ]; then
  echo "Setting up poxml."
  sudo apt-get --yes install poxml
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libgtk-3-dev|grep "install ok installed")
echo Checking for libgtk-3-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libgtk-3-dev."
  sudo apt-get --yes install libgtk-3-dev
fi

# Check libayatana-appindicator3-dev first
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libayatana-appindicator3-dev|grep "install ok installed")
echo Checking for libayatana-appindicator3-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libayatana-appindicator3-dev."
  sudo apt-get --yes install libayatana-appindicator3-dev
fi

# Then install libappindicator3-dev as alternative
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libayatana-appindicator3-dev|grep "install ok installed")
if [ "" == "$PKG_OK" ]; then
  PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libappindicator3-dev|grep "install ok installed")
  echo Checking for libappindicator3-dev
  if [ "" == "$PKG_OK" ]; then
    echo "Setting up libappindicator3-dev."
    sudo apt-get --yes install libappindicator3-dev
  fi
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libsqlcipher-dev|grep "install ok installed")
echo Checking for libsqlcipher-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libsqlcipher-dev."
  sudo apt-get --yes install libsqlcipher-dev
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libosmgpsmap-1.0-dev|grep "install ok installed")
echo Checking for libosmgpsmap-1.0-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libosmgpsmap-1.0-dev."
  sudo apt-get --yes install libosmgpsmap-1.0-dev
fi

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' libxml2-dev|grep "install ok installed")
echo Checking for libxml2-dev
if [ "" == "$PKG_OK" ]; then
  echo "Setting up libxml2-dev."
  sudo apt-get --yes install libxml2-dev
fi

echo Toolchain installed.

