#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

CFLAGS += -Wno-error
CXXFLAGS += -Wno-error
LDFLAGS += -Wl,-z,defs -Wl,-O1 -Wl,--as-needed

# Let's decide the package name and url depending on the distribution
DISTRO = "$(shell dpkg-vendor --query vendor)"

GST_PACKAGE_NAME := "GStreamer GNonLin (unknown Debian derivative)"
GST_PACKAGE_ORIGIN="http://packages.qa.debian.org/gnonlin1.0"

ifeq ($(DISTRO),"Debian")
GST_PACKAGE_NAME := "GStreamer GNonLin (Debian)"
GST_PACKAGE_ORIGIN="http://packages.qa.debian.org/gnonlin1.0"
endif

ifeq ($(DISTRO),"Ubuntu")
GST_PACKAGE_NAME := "GStreamer GNonLin (Ubuntu)"
GST_PACKAGE_ORIGIN="https://launchpad.net/distros/ubuntu/+source/gnonlin1.0"
endif

configure_flags += \
		--disable-silent-rules \
		--enable-docbook \
		--enable-gtk-doc \
		--with-package-name=$(GST_PACKAGE_NAME) \
		--with-package-origin=$(GST_PACKAGE_ORIGIN) \
		--disable-examples \
		--enable-DEBUG \
		--enable-debug \
		--enable-experimental \
		$(NULL)

%:
	dh $@ --with autoreconf 

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- $(configure_flags)

override_dh_auto_test:
	dh_auto_test || true

override_dh_auto_install:
	dh_auto_install

# Where to put this?
override_dh_install:
	dh_install
	mkdir -p $(CURDIR)/fake-home
	HOME=$(CURDIR)/fake-home dh_gstscancodecs
	rm -rf $(CURDIR)/fake-home

override_dh_strip:
	dh_strip -pgstreamer1.0-gnonlin --dbg-package=gstreamer1.0-gnonlin-dbg

