#!/usr/bin/make -f

LIB_PKGS = $(shell sed -nr 's/^Package:[[:space:]]*(libx264-[0-9]+)[[:space:]]*$$/\1/p' debian/control)

%:
	dh $@ --with quilt,bash-completion

override_dh_auto_configure:
	./configure --prefix=/usr --host=$(DEB_HOST_GNU_TYPE) \
	--enable-debug --enable-static --disable-lavf --enable-shared \
	--disable-avs --enable-pic --system-libx264 \
	--libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

#	exit 1

override_dh_install:

ifeq "$(DEB_BUILD_ARCH)" "amd64"
	LD_LIBRARY_PATH=$(CURDIR):$(LD_LIBRARY_PATH) help2man -N --help-option=--fullhelp --name="video encoder for the H.264/MPEG-4 AVC standard" ./x264  > debian/x264.1
endif

	dh_install

debian/libx264-recommends-dummy.so:
	cc -xc -shared -Wl,--no-as-needed -o $@ /dev/null \
	-lOpenCL

override_dh_shlibdeps: debian/libx264-recommends-dummy.so
	dh_shlibdeps

	dpkg-shlibdeps -dRecommends -edebian/libx264-recommends-dummy.so -xlibc6 -O >> debian/$(LIB_PKGS).substvars

override_dh_auto_clean:
	touch config.mak

	dh_auto_clean

override_dh_clean:
	dh_clean debian/libx264-recommends-dummy.so
