#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export LDFLAGS+=-Wl,--as-needed

# To avoid running configure twice (because gnome-autogen.sh)
export NOCONFIGURE=yes

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  DH_PARALLEL_OPTION=--parallel
endif

# This will set current version string
VERSION := $(shell dpkg-parsechangelog | sed -n 's/Version: //p')
# This will set major version string (strip substring '.<something>' after 'maemo<something>')
CINNAMON_VERSION := $(shell echo $(VERSION) | sed 's/\(.*.*\)\..*/\1.0/')

DH_GENCONTROL_ARGS = -Vcinnamon:Version=$(CINNAMON_VERSION)

%:
	dh  $@ --with autoreconf,python2 $(DH_PARALLEL_OPTION)


override_dh_autoreconf:
	dh_autoreconf --as-needed ./autogen.sh

override_dh_auto_configure:
	dh_auto_configure -- --enable-compile-warnings=yes \
	                     --disable-schemas-install\
			     --enable-gtk-doc

# Disable checks since they are not functional for the moment
override_dh_auto_test:

override_dh_install:
	dh_install -X.la
	test -e $(CURDIR)/debian/cinnamon-common/usr/share/cinnamon/theme || mkdir -p $(CURDIR)/debian/cinnamon-common/usr/share/cinnamon/theme
	cp -r $(CURDIR)/debian/icon.svg $(CURDIR)/debian/cinnamon-common/usr/share/cinnamon/theme/menu.svg

override_dh_strip:
	dh_strip --dbg-package=cinnamon-dbg

override_dh_makeshlibs:
	dh_makeshlibs -Xplugin

override_dh_girepository:
	dh_girepository -l src -p/usr/lib/$(DEB_HOST_MULTIARCH)/muffin /usr/lib/cinnamon

override_dh_gencontrol:
	dh_gencontrol -- $(DH_GENCONTROL_ARGS)
