# Makefile - makefile for xhotkeys
PACKAGE=xhotkeys

# Destination directoy
DESTDIR= 

# Define destination directories

BINDIR=$(DESTDIR)/usr/bin
SBINDIR=$(DESTDIR)/usr/sbin
MAN1DIR=$(DESTDIR)/usr/share/man/man1
SHAREDIR=$(DESTDIR)/usr/share/$(PACKAGE)
LIBDIR=$(DESTDIR)/usr/lib/$(PACKAGE)

# Useful variables
DEBIANVERSION=$(shell cat debian/changelog | head -n1 | awk '{print $$2}' | sed "s/^.//" | sed "s/.$$//")
VERSION=$(shell echo $(DEBIANVERSION) | sed "s/-/./")
TARBALL=$(PACKAGE)-$(VERSION).tar.gz
ARCH=$(shell dpkg --print-architecture)
DEBPACKAGE=$(PACKAGE)_$(DEBIANVERSION)_$(ARCH).deb
FTPSERVER=ftp://savannah.gnu.org/incoming/savannah/$(PACKAGE)/

# ------------- don't edit anything below this line --------------

FILES=xhotkeys xhotkeys.glade README TODO Makefile debian/changelog

all: 

install: all
	# Create directories
	mkdir -p $(SHAREDIR)
	
	# Install files
	install -m 755 xhotkeys $(BINDIR)
	install -m 644 xhotkeys.glade $(SHAREDIR)
	install -m 644 xhotkeys.1 $(MAN1DIR)

dist: ../$(TARBALL) ../$(DEBPACKAGE)

../$(TARBALL): $(FILES)
	cp debian/changelog ChangeLog
	(cd ..; tar --exclude=CVS -czf $(TARBALL) $(PACKAGE))
	rm -f ../$(TARBALL).sig
	gpg -b --use-agent ../$(TARBALL) || true

../$(DEBPACKAGE): ../$(TARBALL)
	(cp ../$(TARBALL) /tmp; cd /tmp; tar xvzf $(TARBALL); cd $(PACKAGE); fakeroot dpkg-buildpackage)
	cp /tmp/$(DEBPACKAGE) ..
	rm -f ../$(DEBPACKAGE).sig
	gpg -b --use-agent ../$(DEBPACKAGE) || true
	
upload: dist web
	(cd ..; wput $(TARBALL)* $(FTPSERVER))
	(cd ..; wput $(DEBPACKAGE)* $(FTPSERVER))
	(cd web/$(PACKAGE); cvs ci .)
	
web: web/$(PACKAGE)/index.html 

web/$(PACKAGE)/index.html: web/$(PACKAGE)/index-template.html
	cat web/$(PACKAGE)/index-template.html | sed "s/@DEBIAN_PACKAGE@/$(DEBPACKAGE)/" | sed "s/@TARBALL@/$(TARBALL)/" | sed "s/@DATE@/$(shell LC_ALL=C date)/" >  web/$(PACKAGE)/index.html
clean:


