#!/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.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

# smokeping doesn't like building with your locale
unexport LC_ALL

TMP=$(CURDIR)/debian/smokeping

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr --with-htdocs-dir=/usr/share/smokeping/www --bindir=/usr/sbin --sysconfdir=/usr/share/doc/smokeping/

override_dh_auto_install:
	dh_auto_install

	rm -r $(TMP)/usr/share/smokeping/www/cropper
	dh_link /var/cache/smokeping/images /usr/share/smokeping/www/images
	for d in cropper prototype scriptaculous; do \
	        dh_link /usr/share/javascript/$$d /usr/share/smokeping/www/$$d; \
	done
	install -m 644 $(CURDIR)/htdocs/cropper/smokeping-zoom.js $(TMP)/usr/share/smokeping/www

	mv $(TMP)/usr/share/doc/smokeping/*.dist $(TMP)/etc/smokeping/
	rename 's/\.dist$$//' $(TMP)/etc/smokeping/*.dist $(TMP)/usr/share/smokeping/smokeping.fcgi.dist
	rm -f $(TMP)/usr/share/perl5/BER.pm $(TMP)/usr/share/perl5/SNMP_*
	mv $(TMP)/usr/sbin/smokeping_cgi $(TMP)/usr/lib/cgi-bin/smokeping.cgi
	install -m 644 $(CURDIR)/debian/apache2.conf $(TMP)/etc/smokeping
	$(CURDIR)/debian/split_config $(TMP)
	install -m 644 $(CURDIR)/debian/default-config $(TMP)/etc/smokeping/config

%:
	dh $@ --with autoreconf
