# Makefile

TRANSLATIONS=""

all: build

test:
	set -e; for SCRIPT in scripts/*; \
	do \
		sh -n $$SCRIPT; \
	done

build:
	@echo "Nothing to build."

install: test
	# Installing scripts
	install -D -m 0755 scripts/cgi $(DESTDIR)/usr/lib/cgi-bin/live-webhelper
	install -D -m 0644 scripts/common $(DESTDIR)/usr/share/live-webhelper/common
	install -D -m 0755 scripts/cron $(DESTDIR)/etc/cron.d/live-webhelper
	install -D -m 0644 scripts/default $(DESTDIR)/etc/default/live-webhelper

	# Installing templates
	mkdir -p $(DESTDIR)/usr/share/live-webhelper/templates/debian-official
	cp templates/debian-official/*.html templates/debian-official/*.txt $(DESTDIR)/usr/share/live-webhelper/templates/debian-official
	mkdir -p $(DESTDIR)/usr/share/live-webhelper/templates/debian-unofficial
	cp templates/debian-unofficial/*.html templates/debian-unofficial/*.txt $(DESTDIR)/usr/share/live-webhelper/templates/debian-unofficial

	# Installing documentation
	mkdir -p $(DESTDIR)/usr/share/doc/live-webhelper
	cp -r COPYING docs/* $(DESTDIR)/usr/share/doc/live-webhelper

	# Installing manpages
	set -e; for MANPAGE in manpages/*.en.7; \
	do \
		install -D -m 0644 $$MANPAGE $(DESTDIR)/usr/share/man/man7/`basename $$MANPAGE .en.7`.7; \
	done

	set -e; for TRANSLATIONS in $$TRANSLATIONS; \
	do \
		for MANPAGE in manpages/*.$$TRANSLATION.7; \
		do \
			install -D -m 0644 $$MANPAGE $(DESTDIR)/usr/share/man/$$TRANSLATION/man7/`basename $$MANPAGE .$$TRANSLATION.7`.7; \
		done; \
	done

	# Installing logfile
	install -d -m 0755 $(DESTDIR)/var/log
	touch $(DESTDIR)/var/log/live
	chown www-data:www-data $(DESTDIR)/var/log/live

uninstall:
	# Uninstalling scripts
	rm -f $(DESTDIR)/etc/cron.d/live-webhelper
	rm -f $(DESTDIR)/etc/default/live-webhelper
	rm -f $(DESTDIR)/usr/lib/cgi-bin/live-webhelper

	# Uninstalling shared data
	rm -rf $(DESTDIR)/usr/share/live-webhelper

	# Uninstalling documentation
	rm -rf $(DESTDIR)/usr/share/doc/live-webhelper

	# Uninstalling manpages
	set -e; for MANPAGE in manpages/*.en.7; \
	do \
		rm -f $(DESTDIR)/usr/share/man/man7/`basename $$MANPAGE .en.7`.7; \
	done

	set -e; for TRANSLATIONS in $$TRANSLATIONS; \
	do \
		for MANPAGE in manpages/*.$$TRANSLATION.7; \
		do \
			install -D -m 0644 $$MANPAGE $(DESTDIR)/usr/share/man/$$TRANSLATION/man7/`basename $$MANPAGE .$$TRANSLATION.7`.7; \
		done; \
	done

update:
	set -e; for FILE in manpages/*.en.* scripts/common; \
	do \
		sed -i	-e 's/2007\\-07\\-23/2007\\-07\\-30/' \
			-e 's/1.0~a20/1.0~a21/' \
		$$FILE; \
	done

clean:

distclean:

reinstall: uninstall install
