#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DESTDIR=$(CURDIR)/debian/gtkwave

STRUCT_PACK=
ifneq (,$(filter %amd64 avr32 %i386 m68k powerpc s390 s390x, $(DEB_HOST_ARCH) ))
  STRUCT_PACK=--enable-struct-pack
endif

# arm64 build chroot ships stray /usr/include/rpc/{types,xdr}.h (orphan files from an
# older glibc), which makes configure take the SunRPC path while xdrmem_create()/
# xdr_double() are not linkable anymore (glibc dropped the implementation).  Use the
# upstream TI-RPC switch there instead; other architectures do not probe these headers
# and keep their previous configuration unchanged.
TIRPC_FLAG=
ifeq ($(DEB_HOST_ARCH),arm64)
  TIRPC_FLAG=--with-tirpc
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --enable-gtk3 --enable-judy --with-gsettings $(STRUCT_PACK) $(TIRPC_FLAG) --disable-mime-update

override_dh_installdocs:
	dh_installdocs
	mv $(DESTDIR)/usr/share/gtkwave-gtk3/*.odt $(DESTDIR)/usr/share/doc/gtkwave

override_dh_installexamples:
	mv $(DESTDIR)/usr/share/gtkwave-gtk3/examples $(DESTDIR)/usr/share/doc/gtkwave/
	rmdir $(DESTDIR)/usr/share/gtkwave-gtk3

override_dh_compress:
	dh_compress --exclude=examples --exclude=odt
