#!/usr/bin/make -f

# I build for Maemo as follows:
#     cd $SRC_DIR/build
#     make dist
#     cd /tmp
#     rm -rf /tmp/woodchuck-$VERSION
#     tar xfvz $SRC_DIR/build/woodchuck-$VERSION.tar.gz
#     /scratchbox/login -d /tmp/woodchuck-$VERSION \
#         dpkg-buildpackage -us -uc -rfakeroot
#
# Setting DEB_BUILD_OPTIONS doesn't work!  /scratchbox/login sets
# DEB_BUILD_OPTIONS unconditionally.  Ouch!  The following works
# around that.
#
# EXTRA_DEB_BUILD_OPTIONS := nostrip,debug
ifneq ($(origin EXTRA_DEB_BUILD_OPTIONS), undefined)
  ifeq ($(origin DEB_BUILD_OPTIONS), undefined)
    DEB_BUILD_OPTIONS := ${EXTRA_DEB_BUILD_OPTIONS}
  else
    DEB_BUILD_OPTIONS:= ${EXTRA_DEB_BUILD_OPTIONS},${DEB_BUILD_OPTIONS}
  endif
endif

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

binary-post-install/smart-storage-logger::
	# Maemo 5 doesn't appear to include dpkg-vendor, but does have
	# /etc/dpkg/origins/maemo.  Also, Maemo's version of
	# dh_installinit is too old to automate this for us.
	if test -e /etc/dpkg/origins/maemo; then \
	  mkdir -p debian/smart-storage-logger/etc/event.d; \
	  cp debian/smart-storage-logger-maemo.upstart \
		debian/smart-storage-logger/etc/event.d/smart-storage-logger; \
	fi

binary-post-install/murmeltier::
	# See comment above.
	if test -e /etc/dpkg/origins/maemo; then \
	  mkdir -p debian/murmeltier/etc/event.d; \
	  cp debian/murmeltier-maemo.upstart \
		debian/murmeltier/etc/event.d/murmeltier; \
	fi
