#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
SHELL+=-e

ABI_VER = 0.9.4.1

TMP_DIR = $(shell pwd)/debian/tmp

build-stamp: build

build:
	(cd abi-$(ABI_VER);$(MAKE) realclean)
	(cd abi-$(ABI_VER);			    \
	    $(MAKE)			    \
	    UNIX_CAN_BUILD_STATIC=0	    \
	    ABI_BUILD_VERSION=$(ABI_VER)    \
	    OUTDIR=$(TMP_DIR))
	touch build-stamp

clean:
	(cd abi-$(ABI_VER);$(MAKE) realclean)
	-rm -f build-stamp install-stamp binary-stamp
	-rm -R debian/tmp

install: build-stamp
	install -m 755 -d debian/tmp/usr/bin
	mv debian/tmp/bin/AbiWord_d debian/tmp/usr/bin/
	ln -s AbiWord debian/tmp/usr/bin/abiword
	install -m 755 -d debian/tmp/usr/bin
	install -m 755 -d debian/tmp/usr/share/man/man1
	install -m 755 -d debian/tmp/usr/share/doc/abiword/examples
	install -m 755 -d debian/tmp/usr/share/abisuite/icons
	install -m 755 -d debian/tmp/usr/share/abisuite/fonts
	install -m 755 -d debian/tmp/usr/share/abisuite/AbiWord/strings
	install -m 755 -d debian/tmp/usr/share/abisuite/AbiWord/help
	install -m 755 -d debian/tmp/usr/share/abisuite/dictionary

	#documentation
	install -m 644 debian/AbiWord_d.1 debian/tmp/usr/share/man/man1/.
	ln -s AbiWord_d.1.gz debian/tmp/usr/share/man/man1/AbiWord.1.gz
	ln -s Abiword_d.1.gz debian/tmp/usr/share/man/man1/abiword.1.gz
	cp debian/copyright debian/tmp/usr/share/doc/abiword/.
	cp debian/changelog debian/tmp/usr/share/doc/abiword/changelog.Debian
	cp abi-$(ABI_VER)/user/wp/readme.txt debian/tmp/usr/share/doc/abiword/README
	gzip -9 debian/tmp/usr/share/doc/abiword/README
	gzip -9 debian/tmp/usr/share/doc/abiword/changelog.Debian
	gzip -9 debian/tmp/usr/share/man/man1/AbiWord_d.1

	#shared data
	cp -r abidistfiles/icons/* debian/tmp/usr/share/abisuite/icons/.
	cp -r unixfonts/fonts/* debian/tmp/usr/share/abisuite/fonts/.
	cp -r abi-$(ABI_VER)/user/wp/strings/* debian/tmp/usr/share/abisuite/AbiWord/strings/.
	cp -r abi-$(ABI_VER)/user/wp/help/* debian/tmp/usr/share/abisuite/AbiWord/help/.
	ln -s ../../../lib/ispell/american.hash debian/tmp/usr/share/abisuite/dictionary/american.hash
	touch install-stamp

# Build architecture-dependent files here.
binary: install
	dh_testdir
	dh_installmenu
	dh_installdocs
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
	touch binary-stamp
	
source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
