#!/usr/bin/make -f

include /usr/share/dpkg/buildflags.mk

export CFLAGS CPPFLAGS LDFLAGS
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -ldl -latomic

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

%:
	dh $@ --with systemd

override_dh_auto_install:
	debian/bin/generate-systemd-service-files

override_dh_auto_build:
	dh_auto_build --parallel -- V=1

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq ($(wildcard /usr/bin/taskset),)
	# Avoid race conditions in upstream testsuite. (#830500)
	taskset --cpu-list 0 ./runtest
	# Sentinel integration tests use too many timers to be reliable or
	# meaningful.
	taskset --cpu-list 0 ./runtest-sentinel || true
endif
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
