#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# This file is public domain software, originally written by Joey Hess. 

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

CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif

export CC = gcc

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	xmkmf -a
	$(MAKE) CDEBUGFLAGS='$(CFLAGS) -DUNIX98' \
		ICELIB= EXTENSIONLIB= SMLIB= XMULIB= LIBDIR=/usr/lib
	sed '1,/XXGDB history/d;/------------/d' XXGDB_README \
		> debian/upstream.changelog
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	dh_prep
	dh_clean debian/upstream.changelog

	# Add here commands to clean up after the build process.
	test ! -f Makefile || { $(MAKE) clean && rm Makefile; }

install: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs usr/share/pixmaps/

	# Add here commands to install the package into debian/<packagename>
	install -o root -g root -m 644 debian/mini.debug.xpm debian/xxgdb/usr/share/pixmaps/
	$(MAKE) DESTDIR=`pwd`/debian/xxgdb \
		BINDIR=/usr/bin LIBDIR=/usr/lib install \
		MANPATH=/usr/share/man MANSUFFIX=1 install.man

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs README README.NEW_INTERFACE XXGDB_README XDBX_README
	dh_installexamples
	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installman
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs debian/upstream.changelog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb


binary: binary-indep binary-arch
.PHONY: binary clean binary-indep binary-arch build install \
	clean1
