#!/usr/bin/make -f

export DH_VERBOSE=1

FMODDIR:=$(shell dh_fortran get_fmoddir)
FLIBDIR:=$(shell dh_fortran get_flibdir)

include /usr/share/dpkg/architecture.mk
PKGFILE=debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/jonquil.pc

# The magic debhelper  rule
%:
	dh $@ --with fortran


override_dh_auto_clean:
	rm -rf build subprojects/test-drive subprojects/toml-f

override_dh_auto_configure:
	meson setup build --prefix=$(CURDIR)/debian/tmp/usr

override_dh_auto_build:
	meson compile -C build	

override_dh_auto_test:
	@echo Bypass tests this build. require downloads

override_dh_auto_install:
	meson install -C build
	sed -i -e 's%@FMODDIR@%${FMODDIR}%' $(PKGFILE)
	sed -i -e 's%@FLIBDIR@%${FLIBDIR}%' $(PKGFILE)
	sed -i -e 's%{libdir}%{flibdir}%' $(PKGFILE)
	sed -i -e 's%{includedir}%{fmoddir}%g' $(PKGFILE)
