#!/usr/bin/make -f

CMAKE_FLAGS = -DCastXML_INSTALL_DOC_DIR:STRING=/usr/share/doc/castxml

# Bug 785931 prevents using "find_package(LLVM)".  We work around this
# by (1) copying a modified version of LLVMConfig.cmake into cwd, and
# (2) modifying CMAKE_PREFIX_PATH so that find_package() searches the
# cwd.

bogus_llvmconfig = /usr/share/llvm-3.6/cmake/LLVMConfig.cmake
ifneq (,$(wildcard $(bogus_llvmconfig)))
	CMAKE_FLAGS += -DCMAKE_PREFIX_PATH:STRING="."
override_dh_auto_configure: bug_785931_workaround
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_FLAGS)

override_dh_installman:
	help2man -n "Create an XML representation of C++ declarations" --no-info debian/castxml/usr/bin/castxml  > castxml.1
	dh_installman castxml.1

bug_785931_workaround:
	sed -e 's,/usr/lib/llvm-3.6/share/llvm/cmake,/usr/share/llvm-3.6/cmake,' $(bogus_llvmconfig) > LLVMConfig.cmake
