PACKAGE = debian-edu-config

PROGS = cfengine-debian-edu \
        update-ini-file update-hostname-from-ip \
	debian-edu-hd-warn debian-edu-lessdisks \
	debian-edu-ltsp debian-edu-pxelinux.cfg

SPROGS = debian-edu-restart-services \
	debian-edu-test-install ltsp-make-client \
        debian-edu-fsautoresize debian-edu-etc-svk

INSTALL     = install -D -p -m 755
INSTALL_DATA= install -D -p -m 644

prefix     = /usr/local
sysconfdir = /etc
cfdir      = $(sysconfdir)/cfengine/debian-edu
bindir     = $(prefix)/bin
sbindir    = $(prefix)/sbin
docdir     = $(prefix)/share/doc/$(PACKAGE)
mandir     = $(prefix)/share/man
ldapdir    = $(sysconfdir)/ldap
schemadir  = $(ldapdir)/schema
dhcp3dir   = $(sysconfdir)/dhcp3
libdir     = /usr/lib
pkglibdir  = $(libdir)/debian-edu-config
mailcapdir = $(libdir)/mime/packages
vardir     = /var


CFFILES = \
	cf.apache2 \
	cf.apt \
	cf.bind9 \
	cf.cfengine \
	cf.cups \
	cf.dhcpserver \
	cf.exim \
	cf.imap \
	cf.homes \
	cf.inetd \
	cf.kdm \
	cf.ldapserver \
	cf.ldapclient \
	cf.locale \
	cf.ltsp \
	cf.fstab \
	cf.mime-support \
	cf.mozilla \
	cf.munin \
	cf.nagios \
	cf.nagios2 \
	cf.nat \
	cf.ntp \
	cf.pcmcia \
	cf.samba \
	cf.slbackup \
	cf.squid \
	cf.ssh \
	cf.syslog \
	cf.sysstat \
	cfd.conf \
	cfengine.conf

CFBINFILES = \
	cfd \
	cfrunhosts.pl

# Files to install in /etc/
SYSCONFFILES = \
	X11/Xsession.d/10debian-edu-one-login-per-host \
	X11/Xsession.d/10debian-edu-set-umask \
	desktop-profiles/debian-edu-config.listing \
	bind/debian-edu/db.10 \
	bind/debian-edu/db.192.168 \
	bind/debian-edu/db.intern \
	bind/debian-edu/named-bind9.conf \
	bind/debian-edu/bind9-default \
	bind/debian-edu/named.conf.options \
	courier/authldaprc-debian-edu \
	courier/imapd-debian-edu.cnf \
	debian-edu/hd-warn.conf \
	debian-edu/nightkill.conf \
	debian-edu/lts.conf.dist \
	default/backdoor \
	cfengine/cfservd.conf \
	cfengine/update.conf \
	cfengine/inputs/cfagent.conf \
	cups/cupsd-debian-edu.conf \
	dhclient-exit-hooks \
	dhcp3/dhcpd-debian-edu.conf \
	exim/exim-ldap-client.conf \
	exim/exim-ldap-server.conf \
	exim4/exim-ldap-client-v4.conf \
	exim4/exim-ldap-server-v4.conf \
	filesystems \
	ldap/slapd-etch_debian-edu.conf \
	ldap/ssl/slapd-cert.cnf \
	pam.d/common-auth-debian-edu \
	pam.d/common-auth-ldap-debian-edu \
	pam.d/common-account-ldap-debian-edu \
	pam.d/common-password-ldap-debian-edu \
	pam.d/common-session-winbind-debian-edu \
	pam.d/common-account-winbind-debian-edu \
	pam.d/common-auth-winbind-debian-edu \
	pam.d/common-password-winbind-debian-edu \
	pam.d/common-session-debian-edu \
	usbmount/usbmount-debian-edu.conf \
	samba/netlogon/login.bat \
	samba/netlogon/shortcut.vbs \
	samba/smb-debian-edu.conf \
	samba/smb-winbind-debian-edu.conf \
	security/pam_mount-winbind-debian-edu.conf \
	security/pam_mount-stateless-debian-edu.conf \
	krb5-winbind-debian-edu.conf \
	lsb-release \
	nagios/nagios-debian-edu.cfg \
	nagios/debian-edu/checkcommands.cfg \
	nagios/debian-edu/contactgroups.cfg \
	nagios/debian-edu/contacts.cfg \
	nagios/debian-edu/dependencies.cfg \
	nagios/debian-edu/htpasswd.users \
	nagios/debian-edu/index.html \
	nagios/debian-edu/main.html \
	nagios/debian-edu/side.html \
	nagios/debian-edu/misccommands.cfg \
	nagios/debian-edu/resource.cfg \
	nagios/debian-edu/services.cfg \
	nagios/debian-edu/timeperiods.cfg \
	nagios/debian-edu/servicetemplates.cfg \
	nagios/debian-edu/hosttemplates.cfg \
	nagios/debian-edu/skolelinux_logo.png \
	nagios/debian-edu/skolelinux_logo_140.png \
	nagios/debian-edu/hosts/gateway.cfg \
	nagios/debian-edu/hosts/tjener.cfg \
	nagios/debian-edu/hostgroups/gateways.cfg \
	nagios/debian-edu/hostgroups/servers.cfg \
	apache2/mods-available/debian-edu-userdir.conf \
	apache2/sites-available/debian-edu-default \
	apache2/sites-available/debian-edu-ssl-default \
	apache2/conf.d/debian-edu-config-doc \
	nagios2/debian-edu/cgi.cfg \
	nagios2/debian-edu/commands.cfg \
	nagios2/debian-edu/contactgroups.cfg \
	nagios2/debian-edu/contacts.cfg \
	nagios2/debian-edu/dependencies.cfg \
	nagios2/debian-edu/htpasswd.users \
	nagios2/debian-edu/escalations.cfg \
	nagios2/debian-edu/hostextinfo.cfg \
	nagios2/debian-edu/hostgroups.cfg \
	nagios2/debian-edu/hosts.cfg \
	nagios2/debian-edu/host_templates.cfg \
	nagios2/debian-edu/nagios.cfg \
	nagios2/debian-edu/resources.cfg \
	nagios2/debian-edu/serviceextinfo.cfg \
	nagios2/debian-edu/servicegroups.cfg \
	nagios2/debian-edu/services.cfg \
	nagios2/debian-edu/service_templates.cfg \
	nagios2/debian-edu/timeperiods.cfg


LIBFILES = \
	mime/packages/debian-edu-mailcap

SYSCONFSCRIPTS = \
	resolvconf/update.d/bind-debian-edu \
	X11/Xsession-debian-edu \
	samba/smbaddclient.pl

SCHEMAS = \
	samba.schema \
	samba-2.2.x.schema \
	courier.schema \
	automount-debian-edu.schema \
	norEduPerson.schema \
	EduPerson.schema \
	lis.schema

LDIFS = \
	root.ldif \
	autofs.ldif \
	netgroup.ldif

LDAPPROGRAMS = \
	ldappasswd2 \
	ldap2netgroup \
	ldap-debian-edu-install \
	samba-debian-edu-admin \
	mkslapdcert

VARFILES = \
	www/index.html.de \
	www/index.html.en \
	www/index.html.es \
	www/index.html.fr \
	www/index.html.no \
	www/index.html.nl \
	www/index.html.ru \
	www/skl-ren_css.css \
	www/logo-trans.png \
	www/wpad.dat

KIOSKFILES = \
	share/debian-edu/students/share/apps/kdesktop/Desktop/kalzium.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/kmplot.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/kstars.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/ooo-impress.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/ooo-writer.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/gcompris.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/gimp-2.2.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/kgeography.desktop \
	share/debian-edu/students/share/apps/kdesktop/Desktop/stopmotion.desktop \
	share/debian-edu/students/share/config/kdeglobals \
	share/debian-edu/students/share/config/kdesktoprc \
	share/debian-edu/students/share/config/konqiconviewrc \
	share/debian-edu/students/share/config/uiserverrc \
	share/debian-edu/students/share/config/adept_notifierrc \
	share/debian-edu/students/share/services/update_ksycoca \
	share/debian-edu/students/share/config/menus/applications.menu \
	share/debian-edu/students/share/config/menus/kde-applications.menu \
	share/debian-edu/students/share/applications/kalzium.desktop \
	share/debian-edu/students/share/applications/kbruch.desktop \
	share/debian-edu/students/share/applications/klatin.desktop \
	share/debian-edu/students/share/applications/kmplot.desktop \
	share/debian-edu/students/share/applications/kpercentage.desktop \
	share/debian-edu/students/share/applications/kstars.desktop \
	share/debian-edu/students/share/applications/kturtle.desktop \
	share/debian-edu/students/share/applications/kvoctrain.desktop \
	share/debian-edu/students/share/applications/kwordquiz.desktop \
	share/debian-edu/students/share/applications/oocalc.desktop \
	share/debian-edu/students/share/applications/ooimpress.desktop \
	share/debian-edu/students/share/applications/oowriter.desktop  \
	share/debian-edu/root/share/apps/kdesktop/Desktop/tjener.desktop

all:

install: install-testsuite
	install -d $(DESTDIR)$(bindir)
	install -d $(DESTDIR)$(sbindir)
	install -d $(DESTDIR)$(sysconfdir) $(DESTDIR)$(sysconfdir)/cups
	install -d $(DESTDIR)$(sysconfdir)/exim
	install -d $(DESTDIR)$(sysconfdir)/courier
	install -d $(DESTDIR)$(ldapdir)
	install -d $(DESTDIR)$(dhcp3dir)
	install -d $(DESTDIR)$(mailcapdir)

# program's manpages are autodetected. 
	set -e ; for prog in $(PROGS); do \
		$(INSTALL) bin/$$prog $(DESTDIR)$(bindir) ; \
		if [ -e "share/man/man1/$$prog.1" ]; \
		then \
		$(INSTALL_DATA) "share/man/man1/$$prog.1" $(DESTDIR)$(mandir)/man1/$$sprog.1 ; \
		fi \
	done
# Using manpages autodetection : 
	set -e ; for sprog in $(SPROGS); do \
		$(INSTALL) sbin/$$sprog $(DESTDIR)$(sbindir) ; \
		if [ -e "share/man/man8/$$sprog.8" ]; \
		then \
		$(INSTALL_DATA) "share/man/man8/$$sprog.8" $(DESTDIR)$(mandir)/man8/$$sprog.8 ; \
		fi \
	done
	$(INSTALL_DATA) README $(DESTDIR)$(docdir)/README
	set -e ; for cf in $(CFFILES); do \
		$(INSTALL_DATA) cf/$$cf $(DESTDIR)$(cfdir)/$$cf; \
	done
	set -e ; for cf in $(CFBINFILES); do \
		$(INSTALL) cf/$$cf $(DESTDIR)$(cfdir)/$$cf; \
	done



	set -e ; for file in $(SYSCONFFILES) ; do \
		$(INSTALL_DATA) etc/$$file $(DESTDIR)$(sysconfdir)/$$file; \
	done

	mkdir -p $(DESTDIR)$(sysconfdir)/init.d
	set -e ; for file in $(SYSCONFSCRIPTS) ; do \
		$(INSTALL) etc/$$file $(DESTDIR)$(sysconfdir)/$$file; \
	done

	set -e ; for file in $(LIBFILES) ; do \
		$(INSTALL_DATA) lib/$$file $(DESTDIR)$(libdir)/$$file; \
	done

	set -e ; for f in share/debian-edu-config/tools/passwd \
		share/debian-edu-config/tools/adduser \
		share/debian-edu-config/tools/movehome \
		share/debian-edu-config/tools/nightkill.sh \
		share/debian-edu-config/tools/logoutkill.sh \
		share/debian-edu-config/tools/ldap-user-clean-attic.sh \
		share/debian-edu-config/tools/ldapdump.sh \
		share/debian-edu-config/tools/ldap-users.pl \
		share/debian-edu-config/tools/nbdswap-cleanup \
		share/debian-edu-config/tools/nbdquery \
	; do \
		$(INSTALL) $$f $(DESTDIR)/usr/$$f ; \
	done

	set -e ; for f in share/debian-edu/common/share/config/kcookiejarrc \
		share/debian-edu/common/share/config/artsmessagerc \
		share/debian-edu/common/share/config/kdeprintrc \
		share/debian-edu/common/share/config/kpersonalizerrc \
		share/debian-edu/common/share/config/konquerorrc \
		share/debian-edu/common/share/mimelnk/applnk/msword.desktop \
		share/debian-edu/networked-kde3/share/config/kioslaverc \
		share/debian-edu/thin-client/share/config/kcmartsrc \
	; do \
		$(INSTALL_DATA) $$f $(DESTDIR)/usr/$$f ; \
	done

	set -e ; for f in $(KIOSKFILES) ; do \
		$(INSTALL_DATA) "$$f" "$(DESTDIR)/usr/$$f" ; \
	done

	set -e ; for f in \
 share/ltsp/plugins/ltsp-build-client/Debian-custom/000-arch-detection \
 share/ltsp/plugins/ltsp-build-client/Debian-custom/025-bootprompt-opts \
	; do \
		$(INSTALL_DATA) $$f $(DESTDIR)/usr/$$f ; \
	done

	$(INSTALL_DATA) sbin/debian-edu-fsautoresizetab $(DESTDIR)/usr/share/debian-edu-config/fsautoresizetab

# Using manpages autodetection : 
	set -e ; for program in $(LDAPPROGRAMS) ; do \
		$(INSTALL) ldap-tools/$$program $(DESTDIR)$(bindir)/$$program; \
		if [ -e "share/man/man1/$$program.1" ]; \
		then \
		$(INSTALL_DATA) "share/man/man1/$$program.1" $(DESTDIR)$(mandir)/man1/$$sprog.1 ; \
		fi \
	done
	set -e ; for schema in $(SCHEMAS) ; do \
		$(INSTALL_DATA) ldap-schemas/$$schema $(DESTDIR)$(schemadir)/$$schema;\
	done
	set -e ; for ldif in $(LDIFS) ; do \
		$(INSTALL_DATA) ldap-bootstrap/$$ldif $(DESTDIR)$(ldapdir)/$$ldif ; \
	done

	set -e ; for file in $(VARFILES) ; do \
		$(INSTALL_DATA) var/$$file $(DESTDIR)/var/$$file ; \
	done

	chmod 700 $(DESTDIR)/var/lib/maildirs/


install-testsuite:
	install -d $(DESTDIR)$(pkglibdir)/testsuite
	set -e ; for test in testsuite/* ; do \
		$(INSTALL) $$test $(DESTDIR)$(pkglibdir)/$$test; \
	done



clean:
	# Remove CVS cruft
	-find . -name '.#*' | xargs rm

dist:
	debuild -us -uc
