Makefile: fix SONAME
diff --git a/ChangeLog b/ChangeLog
index 141ed91..fb4de2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,22 @@
 This file details the changelog of Capstone.
 
 ---------------------------------
+Version 2.1.1: March 13th, 2014
+
+This is a stable release to fix some bugs deep in the core. There is no update
+to any architectures or bindings, so bindings version 2.1 can be used with this
+version 2.1.1 just fine.
+
+[ Core changes]
+
+- Fix a buffer overflow bug in Thumb mode (ARM). Some special input can
+  trigger this flaw.
+- Fix a crash issue when embedding Capstone into OSX kernel. This should
+  also enable Capstone to be embedded into other systems with limited stack
+  memory size such as Linux kernel or some firmwares.
+- Use a proper SONAME for library versioning (Linux).
+
+---------------------------------
 Version 2.1: March 5th, 2014
 
 [ API changes ]
diff --git a/Makefile b/Makefile
index 982389e..4df7321 100644
--- a/Makefile
+++ b/Makefile
@@ -195,7 +195,8 @@
 # Linux, *BSD
 EXT = so
 AR_EXT = a
-LDFLAGS += -Wl,-soname,lib$(LIBNAME)$(PKG_MAJOR)
+API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
+LDFLAGS += -Wl,-soname,lib$(LIBNAME)$(API_MAJOR)
 endif
 endif
 endif
@@ -292,6 +293,7 @@
 
 dist:
 	git archive --format=tar.gz --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).tgz
+	git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip
 
 .c.o:
 	$(CC) $(CFLAGS) -c $< -o $@
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index eda37c4..f01334a 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,48 +1,7 @@
-1. API change
+Version 2.1.1 is a stable release that fixes some bugs deep in the core.
+There is no update to any architectures or bindings, so older bindings
+of release 2.1 can be used with this version 2.1.1 just fine.
 
-Version 2.1 changes the API cs_close() from (prototype):
+For this reason, after upgrading to 2.1.1, users do NOT need to upgrade
+their bindings from release 2.1.
 
-	cs_err cs_close(csh handle);
-
-to:
-
-	cs_err cs_close(csh *handle);
-
-
-Therefore, all C code written on top of Capstone must be fixed accordingly,
-from something like:
-
-
-	csh handle;
-	//....
-	cs_close(handle); // <-- cs_close() used to take handle as argument.
-
-to:
-
-	csh handle;
-	//....
-	cs_close(&handle); // <-- cs_close() now takes pointer to handle as argument.
-
-
-Internally, this change is to invalidate @handle, making sure it cannot be
-mistakenly used after the handle is closed.
-
-
-NOTE: this change is on C interface only. All the bindings Python, Java or
-bindings made by community such as C#, Go, Ruby & Vala should hide this change
-behind their API. For this reason, code using these bindings still work exactly
-like before and do not need to have any modification.
-
-
-2. Upgrade bindings
-
-Version 2.1 makes some changes to Java & Python bindings, like adding some new
-instructions (affecting *_const.py & *_const.java). While this does not break
-API compatibility (i.e users do not need to modify their program written with
-prior version 2.0), they must upgrade these bindings and must not use the old
-bindings from prior versions.
-
-We cannot emphasize this enough: When upgrading to the new engine, always
-upgrade to the bindings coming with the same core. If do not follow this
-principle, applications can silently break without any clear evidence,
-making it very hard to debug sometimes.
diff --git a/packages/homebrew/capstone.rb b/packages/homebrew/capstone.rb
index 2c3297d..d3ece23 100644
--- a/packages/homebrew/capstone.rb
+++ b/packages/homebrew/capstone.rb
@@ -2,15 +2,18 @@
 
 class Capstone < Formula
   homepage 'http://capstone-engine.org'
-  url 'http://capstone-engine.org/download/2.1/capstone-2.1.tgz'
-  sha1 '3e5fe91684cfc76d73caa857a268332ac9d40659'
+  url 'http://capstone-engine.org/download/2.1/capstone-2.1.1.tgz'
+  sha1 'f4b114aba2626832f1c217191faaa748245d76a8'
 
   def patches
-    # fix pkgconfig path
+    # Fix pkgconfig path. Fixed upstream:
+    # https://github.com/aquynh/capstone/commit/xxx
     DATA
   end
 
   def install
+    # Fixed upstream in next version:
+    # https://github.com/aquynh/capstone/commit/dc0d04
     inreplace 'Makefile', 'lib64', 'lib'
     system "./make.sh"
     ENV["PREFIX"] = prefix
@@ -18,14 +21,17 @@
   end
 end
 
-
 __END__
---- a/Makefile.org	2014-03-05 11:26:42.000000000 +0800
-+++ a/Makefile	2014-03-05 11:28:34.000000000 +0800
-@@ -144,13 +144,6 @@
+--- Makefile.org	2014-03-11 16:41:54.000000000 +0800
++++ Makefile	2014-03-11 16:43:12.000000000 +0800
+@@ -145,17 +145,6 @@
  ifeq ($(UNAME_S),Darwin)
  EXT = dylib
  AR_EXT = a
+-ifneq ($(USE_SYS_DYN_MEM),yes)
+-# remove string check because OSX kernel complains about missing symbols
+-CFLAGS += -D_FORTIFY_SOURCE=0
+-endif
 -# By default, suppose that Brew is installed & use Brew path for pkgconfig file
 -PKGCFCGDIR = /usr/local/lib/pkgconfig
 -# is Macport installed instead?
diff --git a/packages/homebrew/patch-Makefile-2.1 b/packages/homebrew/patch-Makefile-2.1
deleted file mode 100644
index b222ef5..0000000
--- a/packages/homebrew/patch-Makefile-2.1
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/Makefile.org	2014-03-05 11:26:42.000000000 +0800
-+++ a/Makefile	2014-03-05 11:28:34.000000000 +0800
-@@ -144,13 +144,6 @@
- ifeq ($(UNAME_S),Darwin)
- EXT = dylib
- AR_EXT = a
--# By default, suppose that Brew is installed & use Brew path for pkgconfig file
--PKGCFCGDIR = /usr/local/lib/pkgconfig
--# is Macport installed instead?
--ifneq (,$(wildcard /opt/local/bin/port))
--# then correct the path for pkgconfig file
--PKGCFCGDIR = /opt/local/lib/pkgconfig
--endif
- else
- # Cygwin?
- IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l)
diff --git a/pkgconfig.mk b/pkgconfig.mk
index f709f42..588ea09 100644
--- a/pkgconfig.mk
+++ b/pkgconfig.mk
@@ -6,6 +6,6 @@
 PKG_MINOR = 2
 
 # version bugfix level. Example: PKG_EXTRA = 1
-PKG_EXTRA =
+PKG_EXTRA = 1