#!/usr/bin/make -f

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

%:
	dh $@

override_dh_auto_configure:
	aclocal
	autoconf
	automake -a -c
	dh_auto_configure -- --sysconfdir=/etc --enable-gtk=2.4 --without-mmx

override_dh_auto_build:
	for i in $$(ls po/*.po | sed 's/.po//'); do \
		msgfmt -o $$i.gmo $$i.po; \
	done
	dh_auto_build

override_dh_installman:
	help2man src/sdl/VisualBoyAdvance \
		-n VisualBoyAdvance -s 1 -N \
		-o $(CURDIR)/debian/VisualBoyAdvance.1
	sed -i -e 's/src\/sdl\///' $(CURDIR)/debian/VisualBoyAdvance.1
	dh_installman

override_dh_installchangelogs:
	cat ChangeLog ChangeLog.1.7.1 ChangeLog.1.7 ChangeLog.1.5.1 > debian/ChangeLog
	dh_installchangelogs

clean:
	dh_testdir
	dh_testroot
	
	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) clean
	find -name "Makefile" -delete
	find -name "Makefile.in" -delete
	find -type d -name ".deps" | xargs rm -rf;
	dh_clean
