#!/usr/bin/make -f
#
# Module:     rules   
# Date:       04/22/04   
# Version:    1.21   
# Edited by:  teon@teon.org   
# Description:   
#
#  AddUser-NG Debian package rules file.  
#   
# License:  
#  
#  This program is free software; you can redistribute it and/or modify  
#  it under the terms of the GNU General Public License Version 2 as  
#  published by the Free Software Foundation.  
#  
#  This program 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 General Public License for more details.  
#  
#  You should have received a copy of the GNU General Public License  
#  along with this program; if not, write to the Free Software  
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,  
#  USA.  
#  
# This file is part of adduser-ng program.  
#  
# Copyright (C) 2003-2004 Bartosz Oler <liar@bzimage.us>  
# Copyright (C) 2003-2004 Robert Olejnik <teon@teon.org>  
#


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

#
# PACKAGES
#

# this packages will be made
adduser_package=adduser-ng
pluginloader_package=libadduser-pluginloader-perl
cdk_package=adduser-ui-cdk
quota_package=adduser-plugin-quota
eximconf_package=adduser-plugin-eximconf
eximconf4_package=adduser-plugin-eximconf4
notifyjabber_package=adduser-plugin-notifyjabber
cvsaccess_package=adduser-plugin-cvsaccess
bkdinit_package=adduser-plugin-bkdinit

# docs packages
doc_user=adduser-ng-doc
doc_devel=adduser-ng-doc-devel


build: build-stamp
build-stamp:
	dh_testdir
	
	scripts/generate_docs.sh txt Docs/user_polish.xml Docs/
	scripts/generate_docs.sh html Docs/user_polish.xml Docs/
	scripts/generate_docs.sh html-nochunks Docs/user_polish.xml Docs/
	scripts/generate_docs.sh txt Docs/user_english.xml Docs/
	scripts/generate_docs.sh html Docs/user_english.xml Docs/
	scripts/generate_docs.sh html-nochunks Docs/user_english.xml Docs/
	scripts/generate_docs.sh txt Docs/developer_polish.xml Docs/
	scripts/generate_docs.sh html Docs/developer_polish.xml Docs/
	scripts/generate_docs.sh html-nochunks Docs/developer_polish.xml Docs/

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	$(MAKE) CONFIG_PREFIX=debian/$(adduser_package) clean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) PREFIX=debian/$(adduser_package)/usr CONFIG_PREFIX=debian/$(adduser_package) PACKAGE=adduser-ng install_adduser install_adduser
	# fix the config file location
	perl -i -pe 's#debian/$(adduser_package)/etc/adduser-ng/adduser-ng.conf#/etc/adduser-ng/adduser-ng.conf#' debian/$(adduser_package)/usr/sbin/adduser-ng
	$(MAKE) PREFIX=debian/$(pluginloader_package)/usr PACKAGE=libadduser-pluginloader-perl install_pluginloader
	$(MAKE) PREFIX=debian/$(cdk_package)/usr PACKAGE=adduser-ui-cdk install_uicdk
	$(MAKE) PREFIX=debian/$(quota_package)/usr PACKAGE=adduser-plugin-quota install_pluginquota
	$(MAKE) PREFIX=debian/$(notifyjabber_package)/usr PACKAGE=adduser-plugin-notifyjabber install_pluginnotifyjabber
	$(MAKE) PREFIX=debian/$(cvsaccess_package)/usr PACKAGE=adduser-plugin-cvsaccess install_plugincvsaccess
	$(MAKE) PREFIX=debian/$(bkdinit_package)/usr PACKAGE=adduser-plugin-bkdinit install_pluginbkdinit
	$(MAKE) PREFIX=debian/$(eximconf_package)/usr PACKAGE=adduser-plugin-eximconf install_plugineximconf
	$(MAKE) PREFIX=debian/$(eximconf4_package)/usr PACKAGE=adduser-plugin-eximconf4 install_plugineximconf4
	$(MAKE) PREFIX=debian/$(doc_user)/usr PACKAGE=$(doc_user) install_docs_user
	$(MAKE) PREFIX=debian/$(doc_devel)/usr PACKAGE=$(doc_devel) install_docs_devel

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installcatalogs
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installman
#	dh_installinfo
	dh_installman Docs/adduser-ng.8 Docs/adduser-ng.pl.8
	dh_link
	dh_compress -X.xml
	dh_fixperms
	dh_perl lib/AddUser/ lib/AddUser/UI/
#	dh_python
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

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