#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/default.mk
OUT = obj-$(DEB_HOST_GNU_TYPE)

ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
 BUILD_MODE = Release
else
 BUILD_MODE = Debug
endif

GYPFLAGS += \
	--format=cmake \
	--depth=. \
	--generator-output=. \
	-Gconfig=$(BUILD_MODE) \
	-Goutput_dir=$(OUT) \
	-Dlinux_path_opus_include=/usr/include/opus

# Workaround for non-Linux, see bugs.debian.org/799356
ifneq ($(DEB_HOST_ARCH_OS),linux)
 GYPFLAGS += --no-parallel
endif

%:
	dh $@ --sourcedirectory=$(OUT)/$(BUILD_MODE)

override_dh_auto_configure:
	gyp $(GYPFLAGS)
	dh_auto_configure

override_dh_auto_install:
	install -D $(OUT)/obj.target/libtgvoip.a \
		debian/libtgvoip-dev/usr/lib/$(DEB_HOST_MULTIARCH)/libtgvoip.a
	dh_auto_install

override_dh_auto_clean:
	dh_auto_clean || dh_auto_clean --sourcedirectory=$(CURDIR)
