#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

LLVM_VERSION := 6.0

CONFIG_EXTRA := \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DLIBCLANG_T=/usr/lib/$(DEB_HOST_MULTIARCH)/libclang-$(LLVM_VERSION).so \
    -DLIBCLANG_INCLUDE_T=/usr/lib/llvm-$(LLVM_VERSION)/include/ \
    -DLIBLLDB_T=/usr/lib/$(DEB_HOST_MULTIARCH)/liblldb-$(LLVM_VERSION).so \
    -DLIBLLDB_INCLUDE_T=/usr/lib/llvm-$(LLVM_VERSION)/include/

# Disable clang / lldb on arches where they're not available (yet)
#  Remember to update debian/control when changing these
ARCH_LLDB := amd64 arm64 armel armhf i386 mips mipsel
ARCH_CLANG := amd64 arm64 armel armhf i386 mips mips64el mipsel powerpc ppc64 ppc64el sparc64 s390x

CONFIG_EXTRA += $(if $(filter $(DEB_HOST_ARCH),$(ARCH_CLANG)),,-DENABLE_CLANG=0)
CONFIG_EXTRA += $(if $(filter $(DEB_HOST_ARCH),$(ARCH_LLDB)),,-DENABLE_LLDB=0)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIG_EXTRA)

override_dh_install:
	dh_install
ifneq (,$(filter $(DEB_HOST_ARCH),$(ARCH_LLDB)))
	dh_install -pcodelite-plugins usr/bin/codelite-lldb usr/lib/codelite
	dh_install -pcodelite-plugins usr/lib/codelite/LLDBDebugger.so
endif

override_dh_makeshlibs:

override_dh_shlibdeps:
	dh_shlibdeps -Lcodelite
