#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@ 

override_dh_auto_clean:

override_dh_auto_build:
	sed -i '/# @@REPLACE@@/,$$d' $(CURDIR)/debian/apache.conf
	cat $(CURDIR)/www/.htaccess >> $(CURDIR)/debian/apache.conf
	echo "</Directory>" >> $(CURDIR)/debian/apache.conf

override_dh_install:
	dh_install
	sed -i 's#@data_dir@#/usr/share/php/data#' $(CURDIR)/debian/semanticscuttle/usr/share/php/SemanticScuttle/header.php \
                                                  $(CURDIR)/debian/semanticscuttle/usr/share/php/SemanticScuttle/Config.php \
                                                  $(CURDIR)/debian/semanticscuttle/usr/share/semanticscuttle/www/www-header.php
	sed -i 's#@www_dir@#/usr/share/semanticscuttle/www#' $(CURDIR)/debian/semanticscuttle/usr/share/php/SemanticScuttle/header.php \
                                                            $(CURDIR)/debian/semanticscuttle/usr/share/php/SemanticScuttle/Config.php
	install -m 644 $(CURDIR)/data/config.php.dist $(CURDIR)/debian/semanticscuttle/etc/semanticscuttle/config.php
	sed -i '/Database configuration/,/\$$dbhost.*=.*$$/c\ * Database configuration in dbconfig-common\
 */\
require_once("/etc/semanticscuttle/database.php");' $(CURDIR)/debian/semanticscuttle/etc/semanticscuttle/config.php
	rm $(CURDIR)/debian/semanticscuttle/usr/share/semanticscuttle/www/.htaccess
	rm -r $(CURDIR)/debian/semanticscuttle/usr/share/semanticscuttle/www/js/jquery-ui-1.8.11
#	rm -r $(CURDIR)/debian/semanticscuttle/usr/share/semanticscuttle/www/js/jstree-1.0-rc2
