#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

COMPONENTS := \
	annotation      atomtype        builder3d     \
	builder3dtools  charges         control       \
	core            data            dict          \
	diff            extra           fingerprint   \
	forcefield      formula         interfaces    \
	ioformats       io              ionpot        \
	isomorphism     libiocml        libiomd       \
	nonotify        pcore           pdb           \
	qm              qsar            qsaratomic    \
	qsarbond        qsarionpot      qsarmolecular \
	qsarprotein     reaction        render        \
	sdg             smarts          smiles        \
	standard        structgen      valencycheck

%:
	dh $@ --with javahelper

override_dh_auto_build:
	dh_auto_build -- -Dlib=/usr/share/java info dist-all

override_dh_install:
	dh_install
	for COMPONENT in $(COMPONENTS); do \
		install -m 644 dist/jar/cdk-$$COMPONENT.jar \
			debian/libcdk-java/usr/share/java/cdk-$$COMPONENT-$(DEB_VERSION_UPSTREAM).jar; \
		ln -s cdk-$$COMPONENT-$(DEB_VERSION_UPSTREAM).jar \
			debian/libcdk-java/usr/share/java/cdk-$$COMPONENT.jar; \
		if [ $$COMPONENT != "core" ]; then \
			echo usr/share/java/cdk-$$COMPONENT.jar cdk-core.jar >> debian/classpath; \
		else \
			echo usr/share/java/cdk-$$COMPONENT.jar jama.jar jgrapht.jar log4j-1.2.jar xercesImpl.jar vecmath.jar xom.jar >> debian/classpath; \
		fi \
	done
