#!/usr/bin/make -f
#
# @package      hubzero-cms
# @file         rules
# @author       Nicholas J. Kisseberth <nkissebe@purdue.edu>
# @copyright    Copyright (c) 2012 HUBzero Foundation, LLC.
# @license      http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
#
# Copyright (c) 2012 HUBzero Foundation, LLC.
#
# This file is part of: The HUBzero(R) Platform for Scientific Collaboration
#
# The HUBzero(R) Platform for Scientific Collaboration (HUBzero) is free
# software: you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# HUBzero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# HUBzero is a registered trademark of Purdue University.

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

PACKAGE=$(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
VERSION=$(shell dpkg-parsechangelog  | sed -rne 's,^Version: ([^-]+).*,\1,p')
DEBVERSION=$(shell dpkg-parsechangelog  | sed -ne 's,Version: ,,p')

include /usr/share/quilt/quilt.make

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch configure-stamp

build: build-stamp

build-stamp: configure-stamp
	dh_testdir
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) DESTDIR=$(CURDIR)/debian/hubzero-cms install

# Build architecture-independent files here.
binary-indep: build install
	dh_install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
#	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
#	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms -X /var/log/hubzero-cms -X /var/log/hubzero-cms/daily -X /var/log/hubzero-cms/imported -X /var/log/hubzero-cms/archive -X /var/log/apache2/daily -X /var/log/apache2/imported -X /var/log/apache2/archive -X /var/log/apache2 /var/log/hubzero-cms/daily/cron/ 
	chown root:adm $(CURDIR)/debian/hubzero-cms/var/log/apache2
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/apache2/daily
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/apache2/imported
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/apache2/archive
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/hubzero-cms
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/hubzero-cms/daily
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/hubzero-cms/daily/cron
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/hubzero-cms/imported
	chown www-data:www-data $(CURDIR)/debian/hubzero-cms/var/log/hubzero-cms/archive
	
#	dh_perl
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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