+BTPASS_VERSION=1.2
+BTPASS_PKG_VERSION=1
+ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+export BTPASS_VERSION
+
+PKG=btpasskey_$(BTPASS_VERSION)-$(BTPASS_PKG_VERSION)_$(ARCH).deb
+ORIG=btpasskey_$(BTPASS_VERSION).orig.tar.gz
+BUILDDIR=btpasskey-$(BTPASS_VERSION)
+btpasskey: $(PKG)
+
+$(PKG): $(ORIG) $(BUILDDIR)/debian/rules
+ cd $(BUILDDIR); debuild
+
+$(BUILDDIR)/debian/rules: $(BUILDDIR)/btpasskey.c
+ -mkdir $(BUILDDIR)/debian
+ -cp -p packaging/btpasskey-debian/* $(BUILDDIR)/debian
+ sed 's!prefix=/usr/local!prefix=/usr!' btpasskey/Makefile > $(BUILDDIR)/Makefile
+$(BUILDDIR)/btpasskey.c: btpasskey/btpasskey.c btpasskey/btpasskey.1 btpasskey/Makefile
+ -mkdir $(BUILDDIR)
+ cp -p $+ $(BUILDDIR)
+
+$(ORIG): $(BUILDDIR)/btpasskey.c
+ tar czf $@ $(BUILDDIR)
+
+clean:
+ rm -rf $(BUILDDIR) btpasskey_$(BTPASS_VERSION)*
+