#!/usr/bin/make -f

CFG := \
       --enable-unitchecks \
       --with-javagui \

DEB_HOST_ARCH     ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBPATH := /usr/lib/$(DEB_HOST_MULTIARCH)

ifeq (,$(findstring $(DEB_HOST_ARCH), hurd-i386 mips mipsel))
CFG += --with-LHAPDF=$(LIBPATH)
else
CFG += --with-LHAPDF=no
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CFG)

override_dh_auto_build-indep:
	dh_auto_build
	$(MAKE) html

override_dh_auto_install:
	dh_auto_install
	mv debian/tmp/$(LIBPATH)/ThePEG/lib* debian/tmp/$(LIBPATH)
	sed -i -e 's,/.*debian/tmp,,' \
		debian/tmp/$(LIBPATH)/ThePEG/ThePEGDefaults.rpo
	chrpath -d debian/tmp/usr/bin/runThePEG
	chrpath -d debian/tmp/usr/bin/setupThePEG
	chrpath -d debian/tmp/$(LIBPATH)/ThePEG/HepMCAnalysis.so
	chrpath -d debian/tmp/$(LIBPATH)/ThePEG/RivetAnalysis.so

override_dh_install-indep:
	dh_install
	# lintian's useless-autogenerated-doxygen-file
	find debian/thepeg-reference/usr/share/doc/thepeg-reference/html -name '*.md5' -print -delete
