#!/usr/bin/make -f
# -*- makefile -*-

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

PACKAGE  = jwm

include debian/debian-vars.mk
include debian/debian-autotools.mk

config.status: configure
	# target: config.status
	dh_testdir
	CFLAGS="$(CFLAGS)" ./configure \
		--host=$(DEB_HOST_GNU_TYPE) \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr --mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--sysconfdir=/etc/jwm

build-stamp: config.status
	# target: build-stamp
	dh_testdir
	# $( config-save )
	$(config-patch)
	$(MAKE)
	touch build-stamp

build: build-stamp

clean:
	# target: clean
	dh_testdir
	dh_testroot
	rm -f build-stamp config.log

	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean

install: build
	# target: install
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	#  Install binary
	$(INSTALL_DIR) $(BINDIR)
	$(INSTALL_BIN) src/$(PACKAGE) $(BINDIR)

	#  Install RC file
	#example.jwmrc

	#  Install GDM support
	$(INSTALL_DIR) $(XSESSIONDIR)
	$(INSTALL_DATA) debian/*.desktop $(XSESSIONDIR)

	#  Install poweroff program
	$(INSTALL_DIR) $(LIBDIR)
	$(INSTALL_SCRIPT) debian/jwm-poweroff.sh $(LIBDIR)

binary-indep: build install
	# target: binary-indep -- Build architecture-independent files

binary-arch: build install
	# target: binary-arch -- Build architecture-dependent files

	# $( config-restore )
	# Clean up for diff. not included in upstream source 2.0.1
	rm -f config.guess config.sub

	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
#       dh_install
	dh_installmenu
#       dh_installdebconf
#       dh_installlogrotate
#       dh_installemacsen
#       dh_installpam
#       dh_installmime
#       dh_installinit
#       dh_installcron
#       dh_installinfo
	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
.PHONY: build clean binary-indep binary-arch binary install
