#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

%:
	dh  $@

override_dh_auto_install:
	$(MAKE) -C slave install prefix=/usr sysconfdir=/etc DESTDIR=$(CURDIR)/debian/puavo-ds-slave
	$(MAKE) -C master install prefix=/usr sysconfdir=/etc DESTDIR=$(CURDIR)/debian/puavo-ds-master
	$(MAKE) -C ext install prefix=/usr sysconfdir=/etc DESTDIR=$(CURDIR)/debian/puavo-ds-ext

# dh_usrlocal fails to remove some vendored gem directories and because we
# probably have no actual need for it. So skip.
override_dh_usrlocal:

# We vendor in every ruby dependency required by this package. Unfortunately
# Ubuntu Precise Pangolin does not have recent enough version of Bundler to do
# this (It's missing --standalone). So we have rubygems as build dependency
# and use it install more recent version of Bundler before actually building
# the package with bundler.

# Setup environment variables so that puavo-ds Makefile can use the 'bundle'
# command like it would have been installed by the system.
export GEM_HOME := $(CURDIR)/debian/tmp
export PATH := $(GEM_HOME)/bin:$(PATH)

override_dh_auto_build:
	# Install bundler to a tmp dir
	gem install -i $(GEM_HOME) bundler --version '1.2.4'
	dh_auto_build --

override_dh_installinit:
	dh_installinit
