#!/usr/bin/make -f
# export DH_VERBOSE =1

%:
	+dh $@ --buildsystem=octave

.ONESHELL:
override_dh_auto_configure:
	mkdir inst
	cp *.m inst
	rm -rf inst/polyline*.m inst/slice*.m inst/closestnode.m inst/layersurf.m
	cp LICENSE.txt COPYING

	@cat > DESCRIPTION << EOF
	Name: brain2mesh
	Version: 0.7.9
	Date: 2020-27-06
	Title: Fully automated high-quality brain tetrahedral mesh generation toolbox
	Author: Qianqian Fang <fangqq@gmail.com>
	Maintainer: Qianqian Fang <fangqq@gmail.com>
	Description:  The Brain2Mesh toolbox provides a streamlined matlab function to convert
	_a segmented brain volumes and surfaces into a high-quality multi-layered
	_tetrahedral brain/full head mesh. Typical inputs include segmentation
	_outputs from SPM, FreeSurfer, FSL etc. This tool does not handle the
	_segmentation of MRI scans, but examples of how commonly encountered
	_segmented datasets can be used to create meshes can be found in the
	_package named brain2mesh-demos.
	URL: http://mcx.space/brain2mesh
	Depends: image, iso2mesh, jsonlab, jnifti, zmat
	EOF

	@cat > INDEX << EOF
	brain2mesh >> Brain2Mesh
	_brain2mesh
	_brain1020
	_label2tpm
	_tpm2label
	_intriangulation
	EOF

	@cat > NEWS << EOF
	= Brain2Mesh - A one-liner brain mesh generator =
	----------------------------------------------------------------------------
	Brain2Mesh ChangeLog (key features marked by *):
	
	== Brain2Mesh 0.7.9 (codename: Pons -beta), FangQ <q.fang (at) neu.edu> ==
	
	2020-03-27 [1e20cf2] add surfonly option,allow per layer threshold and smooth,fix smoothing #12
	2020-03-02 [fbdb166] add polylinesimplify to remove sharp turns, validated with nfri toolbox by Pepe Dan's lab
	2020-03-01 [e8bed87] now interactive clicker can handle partial initpoints
	2020-03-01 [98a42a7] first fully tested brain1020, bisect cm/sm by cz iteratively, add demo
	2020-02-28 [eb9e57e] change license from GPL v2 to GPL v3
	2020-02-28 [3e88bd8] allow missing seg components
	2020-02-22 [44daa41] post the final citation info
	2020-02-22 [f359abf] simplify demo scripts, test smoothing option
	2020-02-22 [8fd8d6d] normalize tpm, add cfg.imfill, update paper ref, enable distbound opt
	2020-02-20 [3646ac6] re-enable surface smoothing option, add citation info
	2019-08-21 [eb9ebb7] convert .nii.gz based segmentation to JNIfTI format .jnii files for portability
	2018-10-14 [2facd27] rewrite the element label mapping step
	2018-10-13 [6ae063d] add dependency check, replace surf2mesh to s2m
	2018-10-13 [5ee7ddc] major code reduction and restructure, replace max_filter with imdilate
	EOF
	@sed -i 's/^_/ /g' INDEX DESCRIPTION
