#!/usr/bin/make -f
# -*- makefile -*-

export DH_VERBOSE=1
#export DEB_BUILD_OPTIONS = noopt

#CFLAGS += -DSYSLOG -ggdb
#CXXFLAGS += -DSYSLOG -ggdb
#CPPFLAGS += -DSYSLOG

%:
	dh $@ --with systemd,quilt --buildsystem=cmake --parallel

override_dh_auto_configure:
	SERVER_VERSION=$$(dpkg-parsechangelog -S Version) ; \
	API_REGISTRY_VERSION=$$(cat external/api/registry/GIT_VERSION) ; \
	dh_auto_configure -- \
		-DCMAKE_BUILD_TYPE=Release \
		-DZONE_CLIENT_BUILD=ON \
		-DSERVER_VERSION=$${SERVER_VERSION} \
		-DAPI_REGISTRY_VERSION=$${API_REGISTRY_VERSION} \
		-DPostgreSQL_INCLUDE_DIR=/usr/include/postgresql \
		-DPostgreSQL_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
		-DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/12/server


override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/fred-zone-generator/etc/fred/
	cp client/client-example.conf debian/fred-zone-generator/etc/fred/fred-zone-generator.conf
	mkdir -p debian/fred-backend-zone/etc/fred/
	cp server-example.conf debian/fred-backend-zone/etc/fred/fred-zone-services.conf
	#dh_install -Pfred-zone-generator client/client-example.conf debian/tmp/fred-zone-generator/etc/fred/fred-zone-generator.conf

# https://lists.debian.org/debian-mentors/2015/09/msg00606.html
#override_dh_installinit:
#	dh_installinit --noscripts

override_dh_systemd_enable:
	dh_systemd_enable --name fred-zone-services
