#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

#export DH_VERBOSE = 1

# Get the multiarch path
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export HOME=$(CURDIR)/debian/fake_home

# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_configure:
	if [ ! -f configure.ac ]; then cp configure.ac.in configure.ac; fi
	libtoolize --force --copy
	aclocal
	autoconf
	chmod +x configure.sh
	./configure.sh --prefix=/usr \
	               --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	               --sysconfdir=/etc \
	               --localstatedir=/var

override_dh_auto_build:
	# Create a fake home to prevent DBus/Inkscape crashes
	mkdir -p $(HOME)
	# Touch icons to skip the broken 'convert' commands if they exist
	# (Comment these out if you MUST regenerate icons)
	touch icons/*.png || true
	dh_auto_build

override_dh_auto_install:
	# Force everything into the package directory and kill /usr/local
	dh_auto_install -- \
		DESTDIR=$(CURDIR)/debian/xfce4-graphinator-plugin \
		plugindir=/usr/lib/$(DEB_HOST_MULTIARCH)/xfce4/panel/plugins \
		libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_usrlocal:
	# Explicitly do nothing if dh_usrlocal still complains
	true