#!/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.
execute_before_dh_auto_configure:
	mkdir -p lib

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

# Fix the installation of the architecture-dependent files
arch_dir = debian/octave-ltfat/usr/share

execute_before_dh_installdeb-arch:
	# Move the README file to the appropriate place
	mv $(arch_dir)/octave/packages/ltfat-*/README $(arch_dir)/doc/octave-ltfat

execute_after_dh_installdeb-arch:
	rm -rf $(arch_dir)/octave

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

execute_before_dh_installdeb-indep:
	mv $(arch_dir)/octave $(indep_dir)
	# Remove useless Python script
	rm $(indep_dir)/octave/packages/ltfat-*/private/test_ltfatarghelper.py
