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

# Limit the number of threads in OpenMP
export DH_OCTAVE_TEST_ENV = OMP_NUM_THREADS=$(shell test $(shell nproc) -gt 4 && echo 4 || echo $(shell nproc))

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

DEB_COMPRESS_EXCLUDE = .m

### Move Octave scripts into the examples directory
SHAREDIR = debian/octave-sparsersb/usr/share
EXAMPLESDIR = $(SHAREDIR)/doc/octave-sparsersb/examples
OCTDIR = $(SHAREDIR)/octave/packages/sparsersb-*
BINDIR = $(OCTDIR)/bin
execute_after_dh_auto_install:
	mkdir -p $(EXAMPLESDIR)
	mv $(OCTDIR)/sparsersb*.m $(BINDIR)/*.m $(BINDIR)/pd.mtx $(EXAMPLESDIR)
	chmod -x $(EXAMPLESDIR)/*
	rm -rf $(BINDIR)
	rm -f $(OCTDIR)/doc-cache $(BINDIR)/doc-cache
