#!/usr/bin/make -f
#
# debian/rules file to build a Mingw32 cross compiler toolchain.
#
# Created 30 Jan 2001, by Ron Lee <ron@debian.org>

#export DH_VERBOSE=1

# m-privacy
export DEB_CFLAGS_MAINT_APPEND += -march=x86-64-v2 -mtune=generic -flto=16 -ffat-lto-objects -D_GLIBCXX_ASSERTIONS -fstack-clash-protection
export DEB_CXXFLAGS_MAINT_APPEND += -march=x86-64-v2 -mtune=generic -flto=16 -ffat-lto-objects -D_GLIBCXX_ASSERTIONS -fstack-clash-protection
export DEB_LDFLAGS_MAINT_APPEND += -march=x86-64-v2 -mtune=generic -flto=16 -ffat-lto-objects -D_GLIBCXX_ASSERTIONS -fstack-clash-protection

#export CC=gcc-11

package = libmprivacy

DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p' | tr '.-' ',,')

top_dir      := $(shell pwd)

DEB_HOST_MULTIARCH =
DEB_HOST_ARCH      ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

build : build-stamp

configure-stamp:
	touch $@

build-stamp : configure-stamp
	dh_testdir
	$(MAKE) -j9
	touch $@

install : install-stamp

install-stamp : build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k

	$(MAKE) install DESTDIR=$(top_dir)/debian/$(package)/
	touch $@

clean:
	$(MAKE) clean
	dh_testdir
	dh_testroot
	rm -rf *-stamp
	dh_clean


binary-indep:
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs
#	dh_strip
	dh_compress
	dh_fixperms
	dh_install
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb -- -Zxz

binary: binary-indep binary-arch

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

