THRIFT-3460 Improve provided Debian packaging solution

Patch: Filip Chabik & Roger Meier

This closes #721
diff --git a/debian/README.md b/debian/README.md
old mode 100755
new mode 100644
index 98d4da0..8ebfeea
--- a/debian/README.md
+++ b/debian/README.md
@@ -1,19 +1,41 @@
-some tips on Debian Packaging
+## Some tips on Debian Packaging
+
 - Debian New Maintainers' Guide [http://www.debian.org/doc/debian-policy/]
 - Debian Policy Manual [http://www.debian.org/doc/manuals/maint-guide/]
 - Machine-readable debian/copyright file [http://dep.debian.net/deps/dep5/]
+- DebSrc 3.0 guidelines [https://wiki.debian.org/Projects/DebSrc3.0]
 
-build
+
+## Build using dpkg-buildpackage:
+
+```bash
 $ dpkg-buildpackage -d -tc
-  -d             do not check build dependencies and conflicts.
-  -tc            clean source tree when finished.
+  -d   # do not check build dependencies and conflicts.
+  -tc  # clean source tree when finished.
+```
 
-update changelog
+
+## Update changelog:
+
+```bash
 $ date -R
+```
 
-check packages
+One can also install `devscripts` package and run:
+
+```bash
+$ dch -i
+```
+
+
+## Check packages:
+
+```bash
 $ dpkg -c *.deb
 $ lintian *.deb
+```
 
-todo
-make it perfect!
+
+## TODO
+
+Make it perfect!
diff --git a/debian/changelog b/debian/changelog
old mode 100755
new mode 100644
diff --git a/debian/compat b/debian/compat
index 7ed6ff8..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-5
+9
diff --git a/debian/control b/debian/control
index 7f997b2..74cbb58 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
 Source: thrift
 Section: devel
 Priority: extra
-Build-Depends: debhelper (>= 5), build-essential, mono-gmcs, python-dev, ant,
+Build-Depends: debhelper (>= 9), build-essential, mono-gmcs, python-dev, ant,
     mono-devel,  libmono-system-web2.0-cil, erlang-base, ruby-dev | ruby1.9.1-dev, autoconf, automake,
     pkg-config, libtool, bison, flex, libboost-dev | libboost1.53-dev, python-all,
     python-all-dev, python-all-dbg, openjdk-6-jdk | java-sdk,
@@ -11,8 +11,8 @@
 Homepage: http://thrift.apache.org/
 Vcs-Git: https://git-wip-us.apache.org/repos/asf/thrift.git
 Vcs-Browser: https://git-wip-us.apache.org/repos/asf?p=thrift.git
-Standards-Version: 3.7.2
-X-Python-Version: >= 2.6
+Standards-Version: 3.9.5
+X-Python-Version: >= 2.7
 
 Package: thrift-compiler
 Architecture: any
@@ -44,7 +44,7 @@
 
 Package: python-thrift-dbg
 Architecture: any
-Section: python
+Section: debug
 Depends: ${shlibs:Depends}, ${misc:Depends}, python-thrift (= ${binary:Version}), python-all-dbg
 Provides: ${python:Provides}
 Description: Python bindings for Thrift (debug version)
@@ -76,7 +76,7 @@
 
 Package: libthrift-java
 Architecture: all
-Section: libs
+Section: java
 Depends: java-gcj-compat | java1-runtime | java2-runtime, ${misc:Depends}
 Description: Java bindings for Thrift
  Thrift is a software framework for scalable cross-language services
@@ -90,7 +90,7 @@
 
 Package: libthrift-cil
 Architecture: all
-Section: libs
+Section: cli-mono
 Depends: cli-common, libmono-corlib1.0-cil (>= 1.0), libmono-system1.0-cil (>= 1.0), 
     libmono-system-web2.0-cil, ${misc:Depends}
 Description: CLI bindings for Thrift
@@ -131,7 +131,7 @@
 Package: libthrift-dev
 Architecture: any
 Section: libdevel
-Depends: ${shlibs:Depends}, ${misc:Depends}, libthrift0, libglib2.0-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, libthrift0 (= ${binary:Version}), libglib2.0-dev
 Description: Thrift C++ library (development headers)
  Thrift is a software framework for scalable cross-language services
  development. It combines a software stack with a code generation engine to
diff --git a/debian/copyright b/debian/copyright
index 25546b4..850643c 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -4,7 +4,7 @@
 This package and the Debian packaging is licensed under the Apache License,
 see `/usr/share/common-licenses/Apache-2.0'.
 
-The following informations was copied from Apache Thrift LICENSE file.
+The following information was copied from Apache Thrift LICENSE file.
 
 --------------------------------------------------
 SOFTWARE DISTRIBUTED WITH THRIFT:
diff --git a/debian/libthrift0.install b/debian/libthrift0.install
old mode 100755
new mode 100644
diff --git a/debian/rules b/debian/rules
index c94de2e..2441a4c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -18,9 +18,15 @@
 
 PYVERS := $(shell pyversions -r)
 
+export CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
+export CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
+export CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
+export LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
+
 configure: configure-stamp
 configure-stamp:
 	dh_testdir
+
 	# Add here commands to configure the package.
 	if [ -f bootstrap.sh ]; then $(CURDIR)/bootstrap.sh; fi
 	$(CURDIR)/configure --prefix=/usr --with-c_glib --without-erlang