#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

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

config.status:
	dh_testdir
	tar cf antlr.tar src/antlr
	# Add here commands to configure the package.
	dh_autoreconf
	# 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

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: config.status
	dh_testdir
	dh_auto_build
	-dh_auto_test
	touch $@

clean:
	dh_testdir
	dh_testroot
	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
	dh_autoreconf_clean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_auto_install

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installman doc/gdl.1
	dh_link
	dh_strip
	dh_compress -X.pro
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
