DESTDIR   =
SHAREDIR  = $(DESTDIR)/usr/share/grr
VARLIBDIR = $(DESTDIR)/var/lib/grr
ETCDIR    = $(DESTDIR)/etc/grr
SQLDIR    =  $(DESTDIR)/usr/share/dbconfig-common/data/grr/install

all:

clean:
	rm -f *~

install:
	install -d $(SHAREDIR) $(VARLIBDIR) $(ETCDIR) $(SQLDIR)
	install -m 644 *.php *.html *.js $(SHAREDIR)
	install -m 644 tables.my.sql $(SQLDIR)/mysql
	for d in images img_grr include language lasso themes; do \
	  cp -a $$d $(SHAREDIR); \
	done
	# a symlink to Debian's jckeditor to replace jckeditor
	ln -s /usr/share/javascript/jckeditor $(SHAREDIR)/jckeditor
	# a symlink to Debian's ckeditor to replace ckeditor
	ln -s /usr/share/javascript/ckeditor $(SHAREDIR)/ckeditor
	# a symlink to Debian's phpmailer
	ln -s /usr/share/php/libphp-phpmailer $(SHAREDIR)/phpmailer
	# replace the embedded prototype library by Debian's library
	ln -s /usr/share/javascript/prototype/prototype.js $(SHAREDIR)/include/prototype-1.6.0.3.js
	ln -s /etc/grr/connect.inc.php $(SHAREDIR)/include
	install -m 644 apache.conf $(ETCDIR)
	# fix improper execution flags
	find $(SHAREDIR) -type f -exec chmod 644 {} \;


.PHONY: all clean install