#! /usr/bin/make -f

DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND := \
	-I/usr/include/tcl8.6 \
	-D_FILE_OFFSET_BITS=64

%:
	dh $@ --sourcedirectory=build --builddirectory=debian/build

override_dh_auto_configure:
	dh_auto_configure -- --with-x --enable-db vi_cv_path_shell=/bin/sh

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
override_dh_auto_build:
	$(MAKE) -C debian/build a2c CC=gcc
	dh_auto_build
endif

override_dh_clean:
	# This is in the upstream tarball, so shouldn't be removed.
	dh_clean -X 'vi/#v_xchar.c#'

override_dh_auto_install:
	mkdir -p debian/vigor  # work around #707336
	dh_auto_install -- prefix=$(CURDIR)/debian/vigor/usr

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog
