#!/usr/bin/make -f

ifeq ($(DEB_BUILD_ARCH),$(filter i386 amd64 ia64 powerpc s390 alpha armel mipsel kfreebsd-amd64 kfreebsd-i386 armhf,$(DEB_BUILD_ARCH)))
	GRIP = --with-grib
else
	GRIP = --without-grib
endif

%:
	dh $@ --parallel --with autoreconf

override_dh_autoreconf:
	tar cf antlr.tar src/antlr
	# Add here commands to configure the package.
	dh_autoreconf

override_dh_auto_configure:
	# Patched source FTBFS if this embedded code copy is present
	rm -rf src/antlr
	dh_auto_configure -- --with-fftw=yes --with-python=yes --with-wxWidgets $(GRIP) --with-udunits --with-pslib

override_dh_auto_test:
	-dh_auto_test --parallel

override_dh_auto_clean:
	if [ -f  antlr.tar ]; then tar xf antlr.tar; fi
	rm -f antlr.tar
	# The Makefile shipped in the .orig.tar.gz is generated from
	# CMake and hence even the clean target requires cmake. Meh.
	# If such a Makefile is still present, delete it.
	if [ -f Makefile ] && fgrep -q CMAKE Makefile; then rm -v Makefile; fi
	dh_auto_clean --parallel

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_compress:
	dh_compress -X.pro
