#!/usr/bin/make -f

export DH_VERBOSE=1

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


override_dh_auto_clean:
	rm -rf build subprojects/toml-test-1.1.0 subprojects/packagecache/v*.gz subprojects/test-drive

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

# dh_fortran_lib builds the GNU-flavour library by rewriting
# libtoml-f.so.0.4.3 with patchelf (--set-soname libtoml-f-gnu.so.0). The
# rewritten ELF that patchelf 0.18 leaves behind has an inconsistent section
# header table, which objcopy from binutils 2.46 refuses to rewrite:
#   objcopy: warning: .../libtoml-f-gnu.so.0.4.3 has a corrupt string table index
#   dh_strip: error: objcopy --only-keep-debug ... returned exit code 1
# The generated library itself is loadable and usable, so install it as
# generated and keep stripping / dbgsym extraction for the other files.
override_dh_strip:
	dh_strip --exclude=libtoml-f-gnu.so

override_dh_auto_install:
	meson install -C build
