#!/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

package=rcouch

CFLAGS=
LDFLAGS=

build:
	cp -f debian/vars.config rel/rcouch.config
	unset CC CFLAGS CPPFLAGS LDFLAGS CXX CXXFLAGS \
		&& make rel USE_STATIC_ICU=1
	touch build

clean:
	dh_clean
	rm -f build
	make clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	cp -R rel/rcouch/lib debian/$(package)/usr/lib/rcouch
	cp -R rel/rcouch/releases debian/$(package)/usr/lib/rcouch
	cp -R rel/rcouch/erts* debian/$(package)/usr/lib/rcouch
	mkdir -p debian/$(package)/usr/share/rcouch
	cp -R rel/rcouch/share/* debian/$(package)/usr/share/rcouch/
	chmod 0755 debian/$(package)/usr/lib/rcouch/erts*/bin/*
	install -p -D -m 0755 rel/rcouch/bin/couchjs debian/$(package)/usr/bin/couchjs
	install -p -D -m 0755 rel/rcouch/bin/rcouch debian/$(package)/usr/sbin/rcouch
	install -p -D -m 0644 rel/$(package)/etc/default.ini debian/$(package)/etc/rcouch/default.ini
	install -p -D -m 0664 rel/$(package)/etc/local.ini debian/$(package)/etc/rcouch/local.ini
	install -p -D -m 0644 rel/$(package)/etc/app.config debian/$(package)/etc/rcouch/app.config
	install -p -D -m 0644 rel/$(package)/etc/vm.args debian/$(package)/etc/rcouch/vm.args
	install -p -D -m 0755 debian/debian_rcouch_init debian/$(package)/etc/init.d/rcouch

	dh_shlibdeps

binary-indep: install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: install
	dh_strip -a
	dh_compress -a
	dh_installdeb
	dh_gencontrol
	dh_builddeb

binary: binary-indep binary-arch
