#!/usr/bin/make -f

ifeq "$(DEB_BUILD_ARCH)" "amd64"
	MFX =  --enable-qsv --enable-vce
else
	MFX = --disable-qsv --disable-vce
endif

ifneq (,$(filter-out amd64 arm64,$(DEB_HOST_ARCH)))
	NVENC = --disable-nvenc
endif

ifneq (cc,$(CC))
	GCC_OPTS = --cc=$(CC)
endif

# To generate the content of revision.txt from git repository.
# HandBrake/scripts/repo-info.sh HandBrake

%:
	dh $@ --with quilt -B$(DEB_BUILD_GNU_TYPE)

override_dh_auto_configure:
	./configure --prefix=/usr \
	--host=$(DEB_HOST_GNU_TYPE) \
	--build=$(DEB_BUILD_GNU_TYPE) \
	--disable-gtk-update-checks --enable-fdk-aac \
	--disable-df-fetch --disable-df-verify \
	$(MFX) $(NVENC) $(GCC_OPTS)

#	exit 1

override_dh_clean:
	dh_clean gtk/po/*.gmo gtk/Makefile.in gtk/aclocal.m4 \
	gtk/config.h.in gtk/configure gtk/depcomp gtk/src/Makefile.in \
	gtk/compile gtk/config.guess gtk/config.sub gtk/install-sh \
	gtk/ltmain.sh gtk/missing gtk/po/Makefile.in.in gtk/m4/libtool.m4 \
	download/ffmpeg-4.4.3.tar.xz download/oneVPL-2021.6.0.tar.gz gtk/m4/*.m4

	-rm -rf win
	-rm -rf macosx

override_dh_installchangelogs:
	dh_installchangelogs NEWS.markdown

#	help2man --no-info x86_64-linux-gnu/HandBrakeCLI > debian/HandBrakeCLI.1
