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

export DH_VERBOSE=1

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	export CFLAGS += -O0
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	ifeq ($(NUMJOBS),auto)
		NUMJOBS = $(shell getconf _NPROCESSORS_ONLN)
	endif
	ifeq ($(strip $(NUMJOBS)),)
		NUMJOBS = $(shell getconf _NPROCESSORS_ONLN)
	endif
else
	NUMJOBS = $(shell getconf _NPROCESSORS_ONLN)
endif

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --sbindir=/sbin

override_dh_auto_build:
	dh_auto_build -- -j$(NUMJOBS)

override_dh_auto_install:
	dh_auto_install
	find debian/phrel -name '*.a' -delete

override_dh_fixperms:
	dh_fixperms
	chmod 0600 debian/phrel/etc/phrel/phreld.conf
	chmod 0640 debian/phrel/etc/default/phreld debian/phrel/etc/sysconfig/phreld

%:
	dh $@
