#!/usr/bin/make -f

# Uncomment below to enable verbose build messages.
#export DH_VERBOSE = 1

# Enable all build hardening flags.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_clean:
	# Delete the generated font.ufo instances.
	find -name font.ufo -exec rm -R '{}' +

	# Delete the generated fonts.
	rm -rf opentype

override_dh_auto_build:
	# Make the instances.
	afdko makeinstancesufo -d Italic/SourceSans3-Italic.designspace
	afdko makeinstancesufo -d Upright/SourceSans3-Upright.designspace

	# Link the features file.
	find -name font.ufo -exec ln -s ../../../../features.fea '{}' \;

	# Make the OpenType directory.
	mkdir -p opentype

	# Build the OpenType fonts.
	find -name font.ufo -execdir afdko makeotf -r -gs -omitMacNames \;

	# Move the fonts to the OpenType directory.
	find Italic -name *.otf -exec mv '{}' opentype \;
	find Upright -name *.otf -exec mv '{}' opentype \;

override_dh_installchangelogs::
	# Move relnotes.txt to changelog.
	dh_installchangelogs relnotes.txt
