PACKAGE = debian-edu-config

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

SPROGS = debian-edu-restart-services skolelinux-restart-services \
	debian-edu-test-install skolelinux-test-install ltsp-make-client

INSTALL     = install -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.amanda \
	cf.apache \
	cf.apt \
	cf.bind8 \
	cf.bind9 \
	cf.cfengine \
	cf.cups \
	cf.devfsd \
	cf.dhcpserver \
	cf.exim \
	cf.imap \
	cf.homes \
	cf.inetd \
	cf.issue \
	cf.kdm \
	cf.ldapserver \
	cf.ldapclient \
	cf.locale \
	cf.ltsp \
	cf.mime-support \
	cf.mozilla \
	cf.munin \
	cf.nagios \
	cf.nat \
	cf.ntp \
	cf.opera \
	cf.pcmcia \
	cf.samba \
	cf.shell \
	cf.shorewall \
	cf.slbackup \
	cf.squid \
	cf.ssh \
	cf.syslog \
	cf.sysstat \
	cf.udev \
	cf.webmin \
	cfd.conf \
	cfengine.conf \
	cf.sarge-installation-cleanup \
	cf.kdm_hdwarn

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 \
	X11/Xsession.d/20debian-edu-kdedirs \
	bind/debian-edu/db.10 \
	bind/debian-edu/db.192.168 \
	bind/debian-edu/db.intern \
	bind/debian-edu/named-bind8.conf \
	bind/debian-edu/named-bind9.conf \
	courier/authldaprc-debian-edu \
	courier/imapd-debian-edu.cnf \
	debian-edu/hd-warn.conf \
	debian-edu/nightkill.conf \
	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-debian-edu.conf \
	ldap/slapd-sarge_debian-edu.conf \
	ldap/ssl/slapd-cert.cnf \
	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 \
	pam.d/cron-debian-edu \
	pam.d/cupsys-debian-edu \
	pam.d/kde-debian-edu \
	pam.d/kscreensaver-debian-edu \
	pam.d/login-debian-edu \
	pam.d/other-debian-edu \
	pam.d/passwd-debian-edu \
	pam.d/samba-debian-edu \
	pam.d/ssh-debian-edu \
	pam.d/su-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 \
	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

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

SYSCONFSCRIPTS = \
	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.nb \
	www/index.html.nl \
	www/skl-ren_css.css \
	www/logo-trans.png

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. 
	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 : 
	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
	echo -n > debian/conffiles.raw
	for cf in $(CFFILES); do \
		$(INSTALL_DATA) cf/$$cf $(DESTDIR)$(cfdir)/$$cf; \
		echo $(cfdir)/$$cf >> debian/conffiles.raw; \
	done
	for cf in $(CFBINFILES); do \
		$(INSTALL) cf/$$cf $(DESTDIR)$(cfdir)/$$cf; \
		echo $(cfdir)/$$cf >> debian/conffiles.raw; \
	done

	echo /etc/cron.d/$(PACKAGE) >> debian/conffiles.raw


	for file in $(SYSCONFFILES) ; do \
		$(INSTALL_DATA) etc/$$file $(DESTDIR)$(sysconfdir)/$$file; \
		echo $(sysconfdir)/$$file >> debian/conffiles.raw; \
	done

	mkdir -p $(DESTDIR)$(sysconfdir)/init.d
	for file in $(SYSCONFSCRIPTS) ; do \
		$(INSTALL) etc/$$file $(DESTDIR)$(sysconfdir)/$$file; \
		echo $(sysconfdir)/$$file >> debian/conffiles.raw; \
	done

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

	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 \
	; do \
		$(INSTALL) $$f $(DESTDIR)/usr/$$f ; \
	done

	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-kde2/share/config/kioslaverc \
		share/debian-edu/networked-kde3/share/config/kioslaverc \
	; do \
		$(INSTALL_DATA) $$f $(DESTDIR)/usr/$$f ; \
	done

# Using manpages autodetection : 
	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
	for schema in $(SCHEMAS) ; do \
		$(INSTALL_DATA) ldap-schemas/$$schema $(DESTDIR)$(schemadir)/$$schema;\
		echo $(schemadir)/$$schema >> debian/conffiles.raw; \
	done
	for ldif in $(LDIFS) ; do \
		$(INSTALL_DATA) ldap-bootstrap/$$ldif $(DESTDIR)$(ldapdir)/$$ldif ; \
		echo $(ldapdir)/$$ldif >> debian/conffiles.raw; \
	done

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

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

	sort -u debian/conffiles.raw > debian/conffiles
	rm debian/conffiles.raw

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



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

dist:
	debuild -us -uc
