# HCI Education Survey Makefile
# This makefile generates reports and installs them in the DESTDIR directory

# reports are the files that get generated
reports= \
	respond.html \
	totals.inc \
	contact.html \
	country.html \
	course.html \
	faculty.html \
	program.html
# generators are the shell scripts to generate reports
generators= html-contact html-country html-course \
	html-faculty html-program

# DESTDIR is where the generated reports and data files are copied
DESTDIR=/acminfo/2/sigs/sigchi/educhi
HTTPDIR=http://www.acm.org/sigchi/educhi/
HTTPDIR=

all: ${reports}

# newcopy installs the file only if it is newer and differs from the original
install: ${reports}
	for i in index.html ${reports} Data/*; do newcopy $$i cat ${DESTDIR}; done
	# cp ${reports} Data/* survey.txt ${DESTDIR}

clean:
	/bin/rm -f ${reports}

.PRECIOUS: ${generators} index.html Data/* survey.txt

contact.html: Data/* html-contact
	html-contact Data/* > $@

faculty.html: Data/* makefile html-faculty
	html-faculty Data/* > $@

course.html: Data/* makefile html-course
	html-course Data/* > $@

country.html: Data/* html-country
	html-country Data/* > $@

program.html: Data/* makefile html-program
	html-program Data/* > $@

totals.inc: Data/*
	programs=`cat Data/* | grep -ic "^%section.*program"`; \
	faculty=`cat Data/* | grep -ic "^%section.*faculty"`; \
	courses=`cat Data/* | grep -ic "^%section.*course"`; \
	echo "$$programs programs, $$faculty faculty, and $$courses courses." > $@

respond.html: Data/* makefile
	for i in Data/*; do sssearch section=unit $$i | ssformat -t "	<li><a href='${HTTPDIR}$$i'>%shortname</a>"; done > $@

