#!/usr/bin/make -f

%:
	dh $@ --parallel -Scmake

override_dh_auto_configure:
	# Patched source FTBFS if this embedded code copy is present
	tar cf antlr.tar src/antlr
	rm -rf src/antlr

	# /usr/include/plplot/plConfig.h requires plplot_config.h which is not available
	mkdir -pv src/plplot
	cp -pv /usr/include/plplot/*.h src/plplot/
	sed -e s/plplot_config.h/config.h/ < /usr/include/plplot/plConfig.h > src/plplot/plConfig.h

	dh_auto_configure -Scmake -- -DFFTW=YES -DPYTHON=YES -DWXWIDGETS=YES -DGRIB=YES -DUDUNITS=YES -DPSLIB=YES

override_dh_auto_install:
	dh_auto_install
	# See https://wiki.debian.org/RpathIssue
	chrpath --delete debian/gnudatalanguage/usr/bin/gdl

override_dh_auto_test:
	cd obj*/testsuite; $(CC) -o launchtest ../../testsuite/launchtest.c
	-xvfb-run dh_auto_test --parallel -Scmake

override_dh_auto_clean:
	if [ -f  antlr.tar ]; then tar xf antlr.tar; fi
	rm -f antlr.tar
	dh_auto_clean --parallel -Scmake
	rm -rf src/plplot

override_dh_compress:
	dh_compress -X.pro
