#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

include /usr/share/dpkg/buildflags.mk

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

build-arch-stamp:
	dh_testdir
	$(MAKE) -C scan CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
	scan/compile -o rules/rules.compiled rules/*.description rules/*.switch
	sed -e "s!^\(lib\|share\)dirdefault *= *'[^']*' *#.*!\1dirdefault = '/usr/\1/bls-standalone'!" bls-standalone.py > bls-standalone
	touch $@

build-arch build: build-arch-stamp
build-indep:

clean:
	dh_testdir
	dh_testroot
	rm -f build-arch-stamp bls-standlone rules/rules.compiled
	$(MAKE) -C scan clean
	dh_clean

binary-indep: build-indep
# We have nothing to do.

binary-arch: build-arch
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_install
	dh_installman bls-standalone.1
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary
