#!/usr/bin/make -f

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

# configure seem to fail to add this since 2.9
export DEB_LDFLAGS_MAINT_APPEND=-lpthread

%:
	dh $@ --parallel --with autotools-dev

override_dh_auto_configure:
	dh_auto_configure -- --enable-graphics --with-x --with-fb

override_dh_auto_install:
	dh_auto_install
	# rename links.1 and links to links2.1 and links2
	mv $(CURDIR)/debian/tmp/usr/bin/links \
           $(CURDIR)/debian/tmp/usr/bin/links2
	mv $(CURDIR)/debian/tmp/usr/share/man/man1/links.1 \
           $(CURDIR)/debian/tmp/usr/share/man/man1/links2.1

#	build the textmode only version
	dh_auto_configure -- --without-svgalib --without-x --without-fb --without-directfb --without-libjpeg --without-libtiff
	dh_auto_install
	# Fix "links2" occurrences in links' man-page, see #602228
	sed -z -e 's/\([^.]\)\(links\)2/\1\2/gi;s/\\f3-g\\f1.*\\f3-force-html\\f1/\\f3-force-html\\f1/' -i $(CURDIR)/debian/tmp/usr/share/man/man1/links.1
