#!/usr/bin/make -f
# -*- makefile -*-
# 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

TARGET  := $(CURDIR)/debian/gargoyle

include /usr/share/quilt/quilt.make

build: build-stamp

build-stamp: $(QUILT_STAMPFN)
	dh_testdir

	# compile the package.
	jam

	touch $@

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# clean up after the build process.
	jam clean
	rm -rf build/

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_prep  
	dh_installdirs

	# install the package into debian/gargoyle-free.
	jam install  # to build/dist/
	mkdir -p $(TARGET)/opt/gargoyle
	install -m 755 build/dist/gargoyle $(TARGET)/opt/gargoyle/
	mkdir -p $(TARGET)/etc
	mkdir -p $(TARGET)/usr/bin
	install garglk/garglk.ini $(TARGET)/etc/
	#ln -s /opt/gargoyle/gargoyle $(TARGET)/usr/bin/gargoyle
	echo '#!/bin/sh\nLD_LIBRARY_PATH=$$LD_LIBRARY_PATH:/opt/gargoyle /opt/gargoyle/gargoyle $$*' > $(TARGET)/usr/bin/gargoyle
	chmod +x $(TARGET)/usr/bin/gargoyle


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

# Build architecture-dependent files here.
binary-arch: install
	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_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_lintian
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps -l"$(TARGET)/opt/gargoyle/"
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

