#!/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

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@ --with apache2

override_dh_auto_configure:
	cd wims/src; autoreconf && ./configure --without-units --without-chemeq --without-wimsd


DESTDIR=$(CURDIR)/debian/tmp

override_dh_auto_install:
	# for some reason, dh_installdirs does not work as expected !
	mkdir -p $(DESTDIR)
	for d in $$(cat debian/*.dirs); do \
	  if echo $$d | grep -q "#"; then \
	    true; \
	  else \
	    mkdir -p $(DESTDIR)/$$d; \
	  fi; \
	done
	$(MAKE) install DESTDIR=$(DESTDIR)
	for f in $$(grep -l "deny from all" $$(find $(DESTDIR) -name ".htaccess")); do \
	  echo "# syntax for Apache2.4" > $$f; \
	  echo "Require all denied" >> $$f; \
	done
