-libs :=
-libs += .libs/cycript
-libs += .libs/libcycript.dylib
-libs += .libs/libcycript-any.dylib
-libs += .libs/libcycript-sys.dylib
-libs += .libs/libcycript-sim.dylib
-libs += .libs/libcycript.o
+version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
+deb := cycript_$(version)_iphoneos-arm.deb
+
+cycript :=
+cycript += Cycript_/cycript
+cycript += Cycript_/libcycript.dylib
+cycript += Cycript_/libcycript-any.dylib
+cycript += Cycript_/libcycript-sys.dylib
+cycript += Cycript_/libcycript-sim.dylib
+
+framework :=
+framework += Cycript.framework/Cycript
+framework += Cycript.framework/Headers/Cycript.h
+
+all: cycript $(cycript) $(framework)
+
+cycript.zip: all
+ rm -f $@
+ zip -r9y $@ cycript Cycript_ Cycript.framework
+
+package: cycript.zip
+
+$(deb): Cycript_/cycript Cycript_/libcycript.dylib
+ rm -rf package
+ mkdir -p package/DEBIAN
+ sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
+ mkdir -p package/usr/{bin,lib}
+ $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript_/cycript
+ $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript_/libcycript.dylib
+ ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib
+ dpkg-deb -Zlzma -b package $@