#!/usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

include /usr/share/dpkg/architecture.mk

%:
	dh $@


override_dh_auto_build:
ifeq (linux,$(DEB_HOST_ARCH_OS))
	dh_auto_build -D src -- -f fte-unix.mak
else
	dh_auto_build -D src -- -f fte-unix.mak cfte xfte sfte nfte
endif

override_dh_auto_install:
	# Don't run dh_auto_install It triggers upstream's default
	# build target which breaks non-linux builds. See above.

override_dh_auto_clean:
	dh_auto_clean -D src -- -f fte-unix.mak

override_dh_install-arch:
	cd config; $(CURDIR)/src/cfte main.fte $(CURDIR)/debian/fte/etc/fte/system.fterc
	dh_install

override_dh_install-indep:
	chmod -R go=rX config
	tar --sort=name -cf $(CURDIR)/debian/fte-docs/usr/share/doc/fte/config-example.tar config
	gzip -9n $(CURDIR)/debian/fte-docs/usr/share/doc/fte/config-example.tar
	dh_install

override_dh_installchangelogs:
	dh_installchangelogs NEWS