#!/usr/bin/make -f

#export DH_VERBOSE=1

d = debian/matomo

%:
	dh $@

build: build-stamp
build-stamp:
	@rm -f debian/files
	@dh_testdir

clean:
	@dh_testdir
	@dh_testroot
	@dh_prep
	@$(MAKE) clean

install: build
	@dh_testdir
	@dh_testroot
	@dh_prep
	@dh_installdirs
	@$(MAKE) checkfetch DESTDIR=$(CURDIR)/$d
	@$(MAKE) cleanup DESTDIR=$(CURDIR)/$d
	@$(MAKE) checkconfig DESTDIR=$(CURDIR)/$d
	@$(MAKE) checkmatomoinstall DESTDIR=$(CURDIR)/$d
	@$(MAKE) checkmatomorootdir DESTDIR=$(CURDIR)/$d
	@dh_install
	@dh_lintian
	@dh_link


# build architecture-independent files
binary-indep: build install
	@dh_testdir
	@dh_testroot
	@dh_installdirs -i
	@dh_install -i
	@dh_installcron
	@dh_installchangelogs
	@dh_installdocs
	@dh_installdebconf
	@dh_compress
	@dh_link
	@dh_fixperms
	@$(MAKE) fixperms DESTDIR=$(CURDIR)/$d
	@$(MAKE) fixsettings DESTDIR=$(CURDIR)/$d
	@$(MAKE) checklintianlic DESTDIR=$(CURDIR)/$d
	@$(MAKE) checklintianextralibs DESTDIR=$(CURDIR)/$d
	@$(MAKE) manifest DESTDIR=$(CURDIR)/$d
	@dh_installdeb
# The binary carries an epoch that the source version does not. The epoch is what makes
# apt prefer this package over the matomo Debian itself distributes, whose 5.3.1+dfsg-1
# dpkg reads as newer than anything published here -- so on a machine with both
# repositories, a release upgrade would silently move the installation onto Debian's
# package. Keeping it off the source version keeps the changelog increasing normally
# towards the release that follows, and keeps the colon out of the git tag.
	@dh_gencontrol -- -v1:5.3.1-2
	@dh_md5sums
	@dh_builddeb

# build architecture-dependent files
binary-arch: build install

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