# Tanım: Qt ile yazılmış 2D CAD paketi
# URL: http://www.qcad.org
# Paketçi: Cihan_Alkan
# Gerekler: qt5 xorg-glu
# Grup: tasarım

isim=qcad
surum=3.21.2.6
devir=1
kaynak=(https://github.com/qcad/qcad/archive/v${surum}.tar.gz::$isim-$surum.tar.gz)

derle() {
  cd qcad-$surum
  sed -e 's|$${QT_VERSION}|5.5.0|g' \
      -i src/3rdparty/3rdparty.pro # Don't require specific Qt version

  qmake-qt5 qcad.pro
  make

  # remove project files
  find . \( -name '*.pri' -or -name '.pro' -or -name '*.ts' \) -delete
  find . \( -name 'Makefile' -name '.gitignore' \) -delete

  install -dm755 "$PKG"/usr/lib/qcad
  cp -r examples fonts libraries linetypes patterns scripts themes ts \
      "$PKG"/usr/lib/qcad
  cp release/{*.so,qcad-bin} "$PKG"/usr/lib/qcad

  # install man
  install -Dm644 qcad.1 "$PKG"/usr/share/man/man1/qcad.1

  # readme
  install -Dm644 readme.txt "$PKG"/usr/lib/qcad/readme.txt

  # qt
  cp -r plugins platforminputcontexts platforms xcbglintegrations \
      "$PKG"/usr/lib/qcad

  install -Dm644 scripts/qcad_icon.png "$PKG"/usr/share/pixmaps/qcad_icon.png
  install -Dm644 qcad.desktop "$PKG"/usr/share/applications/qcad.desktop

  install -dm755 "$PKG"/usr/bin
  echo -e '#!/bin/sh\nLD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}"/usr/lib/qcad" exec /usr/lib/qcad/qcad-bin "$@"' >"$PKG"/usr/bin/qcad

  chmod 0755 "$PKG"/usr/bin/qcad

}
