#!/usr/bin/make -f
SHELL+= -e

GIT_VERSION := $(strip $(shell [ -x ./git-version.sh ] && \
                                   ./git-version.sh || echo "unknown"))
DEB_DH_GENCONTROL_ARGS += -u-VGit-Id=$(GIT_VERSION)

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

# for dbg package
CFLAGS += -g -O2
DEB_DH_STRIP_ARGS += --dbg-package=ohm --dbg-package=ohm-utils \
	             --dbg-package=ohm-plugins-legacy

include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_TAR_SRCDIR = ${DEB_SOURCE_PACKAGE}-${DEB_UPSTREAM_VERSION}

DEB_CONFIGURE_USER_FLAGS = --disable-static --without-xauth --without-dpms --disable-nls --enable-mlocknice=auto
DEB_DH_INSTALL_SOURCEDIR = debian/tmp
DEB_UPDATE_RCD_PARAMS = "start 59 2 3 4 5 . stop 18 0 1 6 ."

ifeq ($(strip $(shell echo $$ENABLE_GPROF)),yes)
DEB_CONFIGURE_USER_FLAGS += --enable-gprof
endif

# Omit *.la files but warn about other missing things.
binary-post-install/ohm::
	rm -f debian/tmp/usr/lib/*.la
common-binary-post-install-arch:: list-missing

post-patches:: debian/stamp-autogen

debian/stamp-autogen:
	cd $(DEB_BUILDDIR) && ./autogen.sh
	touch $@

clean::
	-rm -rf debian/stamp-autogen

# do not include docs and changelogs in these packages
DEB_INSTALL_DOCS_ohm := --no-act
DEB_INSTALL_CHANGELOGS_ohm := --no-act
DEB_INSTALL_DOCS_libohm-plugin-core0 := --no-act
DEB_INSTALL_CHANGELOGS_libohm-plugin-core0 := --no-act
DEB_INSTALL_DOCS_ohm-dev := --no-act
DEB_INSTALL_CHANGELOGS_ohm-dev := --no-act
DEB_INSTALL_DOCS_ohm-utils := --no-act
DEB_INSTALL_CHANGELOGS_ohm-utils := --no-act
DEB_INSTALL_DOCS_ohm-plugins-legacy := --no-act
DEB_INSTALL_CHANGELOGS_ohm-plugins-legacy := --no-act
