#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@

# id3lib ships a config.h.in generated from an old-style acconfig.h. The
# default autoreconf (run automatically since compat 10) would invoke
# autoheader, which fails on the missing ID3LIB_ICONV_* templates. Disable
# it and regenerate the build system manually below, without autoheader,
# keeping the shipped config.h.in.
override_dh_autoreconf:

override_dh_auto_configure:
	libtoolize -fc
	aclocal
	autoconf
	automake --add-missing --copy
	# Enable hardened build flags through dpkg-buildflags
	dh_auto_configure -- $(shell dpkg-buildflags --export=configure)

# Build the Doxygen API documentation. Only needed for the indep build,
# so it does not waste buildd resources during arch-only builds.
execute_after_dh_auto_build-indep:
	cd doc && doxygen
	rm -f doc/api/jquery.js

# Comment out dependency_libs in the .la file to avoid overlinking.
override_dh_install:
	sed -i 's/^dependency_libs/#dependency_libs/g' \
		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libid3.la
	dh_install

# Remove prebuilt config.{sub,guess} and the generated Doxygen output.
override_dh_clean:
	dh_clean
	rm -f config.sub config.guess
	rm -rf doc/api/
