#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh $@ --buildsystem=octave --with=octave

export CFLAGS = $(shell dpkg-buildflags  --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)

ifeq ($(dpkg-architecture -qDEB_BUILD_ARCH),mips64el)
DEB_BUILD_MAINT_OPTIONS = nocheck
endif

# The following rule is needed because an empty lib/ directory is
# needed for building the package correctly.  Even though there is one
# in the tarball, it is not created by gbp-import-orig, hence the
# mkdir command below.
override_dh_auto_configure:
	mkdir -p lib
	# Remove extraneous directory
	rm -rf inst/ltfat
	dh_auto_configure

# Build the blockproc.jar file, which is deleted from the upstream
# tarball and clean up the generated *.class files
override_dh_auto_build:
	dh_auto_build
	$(MAKE) -C inst/blockproc/java
	find inst/blockproc/java -name \*.class | xargs rm -f

# Install the architecture independent files
octdir = debian/octave-ltfat-common/usr/share/

override_dh_auto_install:
	dh_auto_install
	mkdir -p $(octdir)
	mv debian/octave-ltfat/usr/share/octave $(octdir)
	# Remove the extra license file (Lintian warning)
	@echo "*******************************************************"
	@echo "Warning: check whether this fix is still needed:"
	find debian/octave-ltfat-common/ -name COPYING -exec rm \{} \;
	@echo "*******************************************************"

get-orig-source:
	uscan --verbose --force-download --repack --compression=xz
