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

DESTDIR = $(CURDIR)/debian/chemical-structures
DB2MAN  = /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
XP      = xsltproc --nonet

%:
	dh  $@

override_dh_auto_clean:
	find . -name *.pyc | xargs rm -f
	rm -rf build
	dh_auto_clean

debian/chemstruc.1: debian/manpage.xml
	cd debian; $(XP) $(DB2MAN) manpage.xml

override_dh_auto_configure:
	mkdir -p build
	cd build; cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)/usr ..

override_dh_auto_build: debian/chemstruc.1
	## do nothing since install would run the build again.
	## cd build; make

override_dh_auto_install:
	cd build; make install
	install -m 755 convert.cgi $(DESTDIR)/usr/share/chemical-structures
	install -m 755 chemstruc  $(DESTDIR)/usr/bin
	install -m 644 apache.conf $(DESTDIR)/etc/chemical-structures
	rm -f $(DESTDIR)/usr/share/chemical-structures/jmol/LICENSE.txt

