#!/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
	#dh $@ ---with quilt --buildsystem=cmake

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


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

override_dh_installsystemd:
	dh_installsystemd --name=fred-backend-registry
	dh_installsystemd --name=fred-auction-warehouse

override_dh_systemd_enable:
	dh_systemd_enable --name=fred-backend-registry
	dh_systemd_enable --name=fred-auction-warehouse

override_dh_systemd_start:
	dh_systemd_start --name=fred-backend-registry
	dh_systemd_start --name=fred-auction-warehouse
