#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

OS=$(shell awk '/^NAME=/' /etc/os-release | sed 's/NAME=//' | sed 's/\"//g' | tr '[:upper:]' '[:lower:]')
ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH | cut -c1-3)
VERSION=$(shell awk '/VERSION=/' /etc/os-release | sed 's/VERSION=//' | sed 's/\"//g' | sed 's/[.]0/./')

%:
	dh $@ --buildsystem=cmake

ifeq ($(OS) $(VERSION) $(ARCH), uos 20 amd)
override_dh_auto_install:
	dh_auto_install
# linglong.conf will be installed to the first package in control file
	dh_install debian/sysctl.d/linglong.conf /etc/sysctl.d
endif

override_dh_auto_configure:
	dh_auto_configure -- -DCPM_LOCAL_PACKAGES_ONLY=ON -DLINGLONG_VERSION=$(DEB_VERSION_UPSTREAM) ${DH_AUTO_ARGS}

# https://sources.debian.org/src/amavisd-new/1:2.13.0-3/debian/rules/?hl=10#L10
execute_after_dh_installinit:
	dh_installsysusers # this is needed until dh compat 14
