#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# package maintainers to append CFLAGS
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Package lsb-release is needed in build dependencies.
distro = $(shell lsb_release --id --short | tr '[:upper:]' '[:lower:]')
release = $(shell lsb_release --release --short)
buildsystem = qmake
export QT_SELECT=5
ifeq ($(distro),ubuntu) # Ubuntu
  ifeq ($(shell expr $(release) \>= 24.04), 1) # 24.04 and newer
    export QT_SELECT=6
    buildsystem = qmake6
  endif
else ifeq ($(distro),debian) # Debian
  # libdebhelper-perl-13.11.4 doesn't provide qmake6 module although Qt-6 is available on Debian 12.
  ifeq ($(shell expr $(release) \>= 13), 1) # 13 and newer
    ifeq ($(shell expr $(release) \<= 9.99), 1)
      # To catch Debian 8.x and 9.x
    else
      export QT_SELECT=6
      buildsystem = qmake6
    endif
  endif
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --buildsystem=$(buildsystem) -- DISABLE_VERSION_NOTIFICATION=1

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_install:
	dh_install --fail-missing -XAUTHORS

override_dh_compress:
	dh_compress -XCOPYING
