#!/usr/bin/make -f

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

# Note: Read /usr/share/doc/autotools-dev/README.Debian.gz

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CONFOPTS += --enable-debug
endif

EXTRADRIVERS := $(shell cut -d/ -f5 $(CURDIR)/debian/lcdproc-extra-drivers.install)

DRIVERS = all,!irman,!svga

# --with autotools_dev will update/restore config.sub and config.guess
%:
	dh $@ --with autotools_dev

override_dh_auto_configure:
# from /usr/share/doc/autotools-dev/examples/rules.gz
	perl -pi -e 's!DriverPath.*!DriverPath=/usr/lib/$(DEB_BUILD_MULTIARCH)/lcdproc/!;' LCDd.conf
	chmod +x debian/autogen.sh
	debian/autogen.sh
# Add here commands to configure the package.
	dh_auto_configure -- \
		--enable-stat-nfs \
		--enable-stat-smbfs \
		--enable-drivers="$(DRIVERS)" \
		--enable-libusb \
		--enable-seamless-hbars \
		--enable-testmenus \
		--enable-permissive-menu-goto \
		--enable-lcdproc-menus \
		$(CONFOPTS)

override_dh_installman:
	dh_installman --language=C

override_dh_strip:
	dh_strip --dbg-package=lcdproc-dbg

override_dh_installinit:
	dh_installinit --name=LCDd -- start 60 2 3 4 5 . stop 60 0 1 6 .

override_dh_install:
	dh_install $(foreach lib,$(EXTRADRIVERS),--exclude=$(lib)) -plcdproc 
	dh_install --autodest  -plcdproc-extra-drivers
	dh_install --remaining-packages --list-missing
