#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

ifeq ($(DEB_HOST_ARCH_OS), linux)
        linuxflags += --with-alsa
endif

unexport HOME

PKGDIR:=$(CURDIR)/debian/vice

override_dh_autoreconf:
	sed "s/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g" \
		< configure.proto > configure.ac
	dh_autoreconf

override_dh_auto_configure:
	./configure \
		--prefix=/usr --infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--enable-x64 \
		--disable-parsid \
		--enable-hardsid \
		--with-resid \
		--enable-arch=no \
		--with-png \
		--with-jpeg \
		--enable-lame \
		--enable-external-ffmpeg \
		--enable-rs232 \
		--enable-ipv6 \
		--with-oss \
		$(linuxflags) \
		--with-pulse \
		--enable-cpuhistory \
		--enable-realdevice \
		--verbose

override_dh_install:
	dh_install
	# remove extra licence file
	rm -f $(PKGDIR)/usr/lib/vice/doc/COPYING
	# remove ROM 'dummy' placeholders
	find $(PKGDIR)/usr/lib/vice -size 6c -exec rm {} \;
	# remove duplicated documentation
	rm -rf $(PKGDIR)/usr/lib/vice/doc/

override_dh_installinfo:
	dh_installinfo
	rm -rf $(PKGDIR)/usr/share/info/

%:
	dh $@ --with autoreconf

.PHONY: override_dh_autoreconf override_dh_auto_configure \
	override_dh_install override_dh_installinfo
