#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

BASIS-VERSION = $(shell if [ -e /usr/lib/openoffice/basis-link ]; then (readlink /usr/lib/openoffice/basis-link | sed -e "s/basis//"); else (readlink /usr/lib/libreoffice/basis-link | sed -e "s/basis//"); fi)

GALLERY = debian/ooohg/usr/lib/libreoffice/basis$(BASIS-VERSION)/share/gallery

LOSHARE = debian/ooohg/usr/share/libreoffice

%:
	dh $@ 

override_dh_auto_install:
	install -d $(GALLERY)
	install -d $(LOSHARE)/ooohg
	install -m 644 data/sg???.* $(GALLERY)
	cp -a data/Geo data/Hist_Etats data/Hist $(LOSHARE)/ooohg
	find $(LOSHARE)/ooohg -type f -exec chmod 644 {} \;
	find $(LOSHARE)/ooohg -name Thumbs.db -exec rm {} \;
	for d in Geo Hist_Etats Hist; do \
	  ln -s $(LOSHARE)/ooohg/$$d $(GALLERY); \
	done


override_dh_gencontrol:
	dh_gencontrol -- -V'basis-version=$(BASIS-VERSION)'
	sed debian/postinst -e 's/@BASIS@/basis$(BASIS-VERSION)/' \
	  > debian/ooohg/DEBIAN/postinst
