#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
PACKAGE = ganglia-web

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

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

build: build-stamp
	make

build-stamp:
	dh_testdir
	# Just in case, make sure changelog exists
	touch ChangeLog NEWS

	# Add here commands to compile the package.
	$(MAKE)
	#/usr/bin/docbook-to-man debian/ganglia.sgml > ganglia.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	# Add here commands to clean up after the build process.
#	[ ! -f Makefile ] || make clean
#	-rm -f dotconf-1.0.9/conftest.o
#	-rm -f dotconf-1.0.9/conftest
	-rm -f web/version.php web/conf.php
	-rm -rf debian/patches/ .pc/
	debconf-updatepo
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	
	# Seed the package directories
	dh_install --sourcedir=debian/tmp

#Install webfrontend
	$(MAKE) install APACHE_USER=www-data DESTDIR=$(CURDIR)/debian/ganglia-webfrontend GDESTDIR=/usr/share/ganglia-webfrontend  GWEB_STATEDIR=/var/lib/ganglia-web
	rm debian/ganglia-webfrontend/usr/share/ganglia-webfrontend/COPYING
	cp -f debian/apache.conf \
		 debian/ganglia-webfrontend/etc/ganglia-webfrontend
	cp -f debian/conf_debian.php \
		 debian/ganglia-webfrontend/usr/share/ganglia-webfrontend/conf.php
	rm -rf debian/ganglia-webfrontend/usr/share/ganglia-webfrontend/debian

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs -i
	dh_fixperms -i
	dh_compress -i
	dh_installdebconf -i
	dh_installdeb -i
	dh_shlibdeps -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i
	
binary-arch:

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
