#!/usr/bin/make -f
#
# debian/rules for vice
#
# First created Jan 2000 by Zed Pobre, with some reference to the work
# done by Giuliano Procida 1997-1999

#include /usr/share/dpatch/dpatch.make

PACKAGE=vice
DATADIRS=C64 C128 PET PLUS4 VIC20 CBM-II
install_program=install -p -o root -g root -m 755
make_directory=install -d -o root -g root -m 755

unexport HOME

romtest:
	chmod 755 debian/genromlist
	debian/genromlist
	touch romtest

configure: romtest configure-stamp
configure-stamp:
#	aclocal
#	autoheader
#	automake
#	autoconf
#	cd src/resid && aclocal && automake && autoconf
	./configure \
	    --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man \
	    --enable-gnomeui --enable-ethernet \
	    --enable-fullscreen --enable-parsid --with-midas --without-xaw3d
	touch $@

build-arch: build
build-indep: build

build: build-stamp
#build-stamp: patch-stamp configure-stamp
build-stamp: configure-stamp
	dh_testdir

	$(MAKE)
	touch $@

#clean: unpatch
clean:
	dh_testdir
	rm -f build-stamp configure-stamp romtest

	[ ! -f Makefile ] || $(MAKE) distclean
	rm -f config.log
	find . -name Makefile -exec rm {} \;
#	find . -name Makefile.in -exec rm {} \;
#	cd src/resid && rm -f aclocal.m4 config.status config.log configure
	rm -rf src/resid/tmp src/resid/autom4te.cache
	rm -f src/translate_text.c.po.c src/translate.h \
          src/arch/amigaos/intl_text.c.po.c po/vice.pot
	rm -f po/*.gmo
	dh_clean

binary-indep: build

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs

	$(MAKE) DESTDIR=`pwd`/debian/$(PACKAGE) install

# 	Remove the 0-byte placeholders
	cd debian/$(PACKAGE)/usr/lib/vice && find . -size 6c -exec rm {} \;

	rm -rf debian/$(PACKAGE)/usr/lib/vice/doc
	cp debian/icons/*.xpm debian/$(PACKAGE)/usr/share/pixmaps/
	dh_installdocs
	$(make_directory) debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/html
	cp doc/html/*.html debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/html
	ln -sf vice_toc.html debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/html/index.html
	ln -sf ../../share/doc/vice/html debian/$(PACKAGE)/usr/lib/vice/doc
#	$(install_program) debian/vice-getroms debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)/
	mkdir -p debian/$(PACKAGE)/usr/share/applications/ && \
	  cp -Rv debian/desktop/* debian/$(PACKAGE)/usr/share/applications/

	dh_installchangelogs -k ChangeLog

	rm -rf debian/$(PACKAGE)/usr/share/info
	dh_installinfo
#	rm -f debian/$(PACKAGE)/usr/info usr/share/info/dir.gz
	dh_installmenu

	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb


binary:	binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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