#!/usr/bin/make -f

include /usr/share/dpkg/buildflags.mk

export BUILD_TLS=yes
export USE_SYSTEMD=yes
export ENABLE_FLASH=yes
export CFLAGS CPPFLAGS LDFLAGS
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -ldl -latomic $(LUA_LDFLAGS)

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
	export MAKEFLAGS
endif

%:
	dh $@

override_dh_auto_install:
	debian/bin/generate-systemd-service-files
	dh_installsystemd --restart-after-upgrade

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Avoid race conditions in upstream testsuite.
	./runtest || true
	./runtest-cluster || true
	./runtest-sentinel || true
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -f src/release.h debian/*.service

override_dh_compress:
	dh_compress -Xredis-trib.rb

override_dh_installchangelogs:
	dh_installchangelogs --keep 00-RELEASENOTES
