#!/usr/bin/make -f

export DH_OPTIONS

export DEB_BUILD_HARDENING=1
export DEB_BUILD_HARDENING_FORTIFY=1

include /usr/share/hardening-includes/hardening.make

CPPFLAGS=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
CXXFLAGS=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)

UPSTREAM_NAME=ugene
pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')

#.PHONY: override_dh_strip
#override_dh_strip:
#	dh_strip --dbg-package=ugene-dbg

%:
	dh $@

override_dh_auto_configure:
	# exclude non-free plugins
	qmake-qt4 -r UGENE_WITHOUT_NON_FREE=1
	find . -name Makefile.* | xargs -r sed -i '/STRIP/d'

#override_dh_auto_build:
#	$(MAKE)

override_dh_auto_clean:
	dh_auto_clean
	rm -rf src/_debug src/_release ugene

override_dh_auto_install:
	dh_auto_install
	# This should be default:
	# $(MAKE) INSTALL_ROOT=$$(pwd)/debian/$(pkg) install
	# Remove data dir which goes to ugene-data package
	rm -rf debian/$(pkg)/usr/share/$(pkg)

override_dh_shlibdeps:
	dh_shlibdeps -l$(CURDIR)/debian/$(pkg)/usr/lib/$(pkg) -l$(CURDIR)/debian/$(pkg)/usr/lib64/$(pkg)

# Remark: The following uscan command requires devscripts > 2.12.4 which is not
#         yet released at the time of this package release.  The code can be obtained
#         via
#   git clone git://tille@git.debian.org/git/users/tille/devscripts.git
#         and then use scripts/uscan.pl
get-orig-source:
	mkdir -p ../tarballs
	uscan --verbose --force-download --repack-compression xz --destdir ../tarballs
