#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export _prefix=/usr
export _datadir="${_prefix}/share"
export appname=notepadpp
export appname_32=notepadpp-bin32
export appname_64=notepadpp-bin64
export appname_common=notepadpp-common
export appdir_32=notepadpp32
export appdir_64=notepadpp64
export debuilddir="debian"
export buildroot="${debuilddir}/${appname}"
export buildroot_common="${debuilddir}/${appname_common}"
export buildroot_32="${debuilddir}/${appname_32}"
export buildroot_64="${debuilddir}/${appname_64}"

%:
	dh $@

override_dh_fixperms:
	dh_fixperms
	chmod 0666 ${buildroot_32}${_datadir}/${appdir_32}/config.xml || :
	chmod 0666 ${buildroot_32}${_datadir}/${appdir_32}/session.xml || :
	chmod 0666 ${buildroot_32}${_datadir}/${appdir_32}/shortcuts.xml || :
	chmod 0666 ${buildroot_32}${_datadir}/${appdir_32}/stylers.xml || :
	chmod 0777 ${buildroot_32}${_datadir}/${appdir_32}/backup || :
	chmod 0666 ${buildroot_64}${_datadir}/${appdir_64}/config.xml || :
	chmod 0666 ${buildroot_64}${_datadir}/${appdir_64}/session.xml || :
	chmod 0666 ${buildroot_64}${_datadir}/${appdir_64}/shortcuts.xml || :
	chmod 0666 ${buildroot_64}${_datadir}/${appdir_64}/stylers.xml || :
	chmod 0777 ${buildroot_64}${_datadir}/${appdir_64}/backup || :

override_dh_auto_install:
	dh_auto_install
	# fix the *model.xml files
	mkdir -p ${buildroot_32}${_datadir}/${appdir_32}/backup ${buildroot_64}${_datadir}/${appdir_64}/backup
	install -m0644 ${appname_32}/langs.model.xml ${buildroot_32}${_datadir}/${appdir_32}/langs.xml
	install -m0644 ${appname_64}/langs.model.xml ${buildroot_64}${_datadir}/${appdir_64}/langs.xml