#!/usr/bin/make -f
# Reference: https://github.com/jellyfin/jellyfin-desktop/blob/55ef28f4d4324d46fb55592ccdaa490119f0a6eb/dev/appimage/Dockerfile#L7
# You must remove unused comment lines for the released package.
# See debhelper(7) (un-comment to enable)
# This is an autogenerated template for debian/rules.
#
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
#
# Copy some variable definitions from pkg-info.mk and vendor.mk
# under /usr/share/dpkg/ to here if they are useful.
#
# See FEATURE AREAS/ENVIRONMENT in dpkg-buildflags(1)
# Apply all hardening options
#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,-O1
#
# With debhelper version 9 or newer, the dh command exports
# all buildflags.  So there is no need to include the
# /usr/share/dpkg/buildflags.mk file here if compat is 9 or newer.
#
# These are rarely used code. (START)
#
# The following include for *.mk magically sets miscellaneous
# variables while honoring existing values of pertinent
# environment variables:
#
# Architecture-related variables such as DEB_TARGET_MULTIARCH:
#include /usr/share/dpkg/architecture.mk
# Vendor-related variables such as DEB_VENDOR:
#include /usr/share/dpkg/vendor.mk
# Package-related variables such as DEB_DISTRIBUTION
#include /usr/share/dpkg/pkg-info.mk
#
# You may alternatively set them susing a simple script such as:
# DEB_VENDOR ?= $(shell dpkg-vendor --query  Vendor)
#
# These are rarely used code. (END)
#

### main packaging script based on post dh7 syntax
%:
	dh $@

override_dh_dwz:
	dh_dwz -XEGL -XGLESv2 -Xlibcef -Xvk_swiftshader -Xvulkan

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp/usr/libexec/jellyfin-desktop PREFIX=/
	for size in 16 24 32 48 64 128 256 ; do \
	  mkdir -p debian/tmp/usr/share/icons/hicolor/$${size}x$${size}/apps ; \
	  convert -background none resources/linux/org.jellyfin.JellyfinDesktop.svg \
	    -resize $${size}x$${size} \
	    debian/tmp/usr/share/icons/hicolor/$${size}x$${size}/apps/org.jellyfin.JellyfinDesktop.png ; \
	done
	mv $(CURDIR)/debian/tmp/usr/libexec/jellyfin-desktop/usr/* \
	  $(CURDIR)/debian/tmp/usr/libexec/jellyfin-desktop && \
	  rmdir $(CURDIR)/debian/tmp/usr/libexec/jellyfin-desktop/usr

override_dh_shlibdeps:
	dh_shlibdeps -Xlibcef.so

#override_dh_auto_configure:
#	dh_auto_configure -- \
#	      -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_TARGET_MULTIARCH)"
#
# You may need to patch CMakeLists.txt to set the library install path to be:
#-install(TARGETS <sharedlibname> LIBRARY DESTINATION lib)
#+install(TARGETS <sharedlibname> LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})

# Multiarch package requires library files to be installed to
# /usr/lib/<triplet>/ .  If the build system does not support
# $(DEB_HOST_MULTIARCH), you may need to override some targets such as
# dh_auto_configure or dh_auto_install to use $(DEB_HOST_MULTIARCH) .
