#!/usr/bin/make -f

ifneq (,$(findstring parallel=,$(DEB_BUILD_OPTIONS)))
	NCPUS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
else
	NCPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
	ifeq ($(NCPUS),-1)
		NCPUS:=1
	endif
	ifeq ($(NCPUS),0)
		NCPUS:=1
	endif
endif

%:
	dh $@ --with quilt

override_dh_auto_configure:
	python3 ./waf configure \
	--prefix=/usr \
	--confdir=/etc/mpv \
	--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--zshdir=/usr/share/zsh/vendor-completions \
	--disable-build-date \
	--disable-rpi \
	--enable-cdda \
	--enable-dvbin \
	--enable-dvdnav \
	--enable-sdl2 \
	--enable-zimg \
	--lua=52arch

#	exit 1

override_dh_auto_build:
	python3 ./waf build -j $(NCPUS)

override_dh_installchangelogs:
	dh_installchangelogs RELEASE_NOTES

override_dh_auto_install:
	python3 ./waf -v install --destdir=debian/tmp

override_dh_auto_clean:
	[ ! -f ./waf ] || python3 ./waf -v distclean
	find . -name "*.pyc" -delete
