Updates to use cmake GLOB and libbcc.so.0 in python init

In order not to miss some files in the tools and examples source
directories, use cmake file(GLOB) to collect relevant files. To ease the
implementation, move all tools to be .py suffixed in the source, but
sans-suffix in the installation (same as before)

In addition, to prevent future API breakage confusion (though of course
that may still happen), use CDLL("libbcc.so.0") in the bcc __init__.py.

Fixes: #317
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
diff --git a/examples/tracing/CMakeLists.txt b/examples/tracing/CMakeLists.txt
index 211bfad..dfce81b 100644
--- a/examples/tracing/CMakeLists.txt
+++ b/examples/tracing/CMakeLists.txt
@@ -1,6 +1,6 @@
-set(EXAMPLE_FILES bitehist.c bitehist_example.txt disksnoop.c
-  disksnoop_example.txt task_switch.c tcpv4connect tcpv4connect_example.txt
-  vfsreadlat.c vfsreadlat_example.txt)
-set(EXAMPLE_PROGRAMS bitehist.py disksnoop.py task_switch.py trace_fields.py vfsreadlat.py)
-install(FILES ${EXAMPLE_FILES} DESTINATION share/bcc/examples/tracing)
-install(PROGRAMS ${EXAMPLE_PROGRAMS} DESTINATION share/bcc/examples/tracing)
+file(GLOB C_FILES *.c)
+file(GLOB PY_FILES *.py)
+file(GLOB TXT_FILES *.txt)
+install(PROGRAMS ${PY_FILES} DESTINATION share/bcc/examples/tracing)
+install(FILES ${C_FILES} DESTINATION share/bcc/examples/tracing)
+install(FILES ${TXT_FILES} DESTINATION share/bcc/examples/tracing)
diff --git a/examples/tracing/bitehist_example.txt b/examples/tracing/bitehist_example.txt
index 1122131..f908264 100644
--- a/examples/tracing/bitehist_example.txt
+++ b/examples/tracing/bitehist_example.txt
@@ -3,7 +3,7 @@
 This prints a power-of-2 histogram to show the block I/O size distribution.
 A summary is printed after Ctrl-C is hit.
 
-# ./bitehist.py 
+# ./bitehist.py
 Tracing... Hit Ctrl-C to end.
 ^C
      kbytes          : count     distribution
diff --git a/examples/tracing/tcpv4connect b/examples/tracing/tcpv4connect.py
similarity index 100%
rename from examples/tracing/tcpv4connect
rename to examples/tracing/tcpv4connect.py
diff --git a/examples/tracing/tcpv4connect_example.txt b/examples/tracing/tcpv4connect_example.txt
index b1ce37c..0ff06e3 100644
--- a/examples/tracing/tcpv4connect_example.txt
+++ b/examples/tracing/tcpv4connect_example.txt
@@ -1,11 +1,11 @@
-Demonstrations of tcpv4connect, the Linux eBPF/bcc version.
+Demonstrations of tcpv4connect.py, the Linux eBPF/bcc version.
 
 
 This example traces the kernel function performing active TCP IPv4 connections
 (eg, via a connect() syscall; accept() are passive connections). Some example
 output (IP addresses changed to protect the innocent):
 
-# ./tcpv4connect 
+# ./tcpv4connect.py
 PID    COMM         SADDR            DADDR            DPORT
 1479   telnet       127.0.0.1        127.0.0.1        23  
 1469   curl         10.201.219.236   54.245.105.25    80  
diff --git a/man/man8/CMakeLists.txt b/man/man8/CMakeLists.txt
index 9843d14..ce74859 100644
--- a/man/man8/CMakeLists.txt
+++ b/man/man8/CMakeLists.txt
@@ -1,4 +1,2 @@
-set(FILES biolatency.8 biosnoop.8 funccount.8 funclatency.8 hardirqs.8
-  killsnoop.8 opensnoop.8 pidpersec.8 softirqs.8 syncsnoop.8 tcpaccept.8
-  tcpconnect.8 vfscount.8 vfsstat.8)
+file(GLOB FILES *.8)
 install(FILES ${FILES} DESTINATION share/bcc/man/man8)
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
index 01fd08a..8c5ea1f 100644
--- a/src/python/bcc/__init__.py
+++ b/src/python/bcc/__init__.py
@@ -24,7 +24,7 @@
 import sys
 basestring = (unicode if sys.version_info[0] < 3 else str)
 
-lib = ct.CDLL("libbcc.so")
+lib = ct.CDLL("libbcc.so.0")
 
 # keep in sync with bpf_common.h
 lib.bpf_module_create_b.restype = ct.c_void_p
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 8b76a42..1a9c2e2 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,11 +1,9 @@
-set(PROGRAMS biolatency biosnoop funccount funclatency hardirqs killsnoop
-  opensnoop pidpersec softirqs syncsnoop tcpaccept tcpconnect vfscount vfsstat)
-set(C_FILES pidpersec.c vfscount.c vfsstat.c)
-set(EXAMPLE_FILES biolatency_example.txt funclatency_example.txt
-  killsnoop_example.txt pidpersec_example.txt syncsnoop_example.txt
-  tcpconnect_example.txt vfsstat_example.txt biosnoop_example.txt
-  funccount_example.txt hardirqs_example.txt opensnoop_example.txt
-  softirqs_example.txt tcpaccept_example.txt vfscount_example.txt)
-install(PROGRAMS ${PROGRAMS} DESTINATION share/bcc/tools)
+file(GLOB C_FILES *.c)
+file(GLOB PY_FILES *.py)
+file(GLOB TXT_FILES *.txt)
+foreach(FIL ${PY_FILES})
+  get_filename_component(FIL_WE ${FIL} NAME_WE)
+  install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
+endforeach()
 install(FILES ${C_FILES} DESTINATION share/bcc/tools)
-install(FILES ${EXAMPLE_FILES} DESTINATION share/bcc/tools/doc)
+install(FILES ${TXT_FILES} DESTINATION share/bcc/tools/doc)
diff --git a/tools/biolatency b/tools/biolatency.py
similarity index 100%
rename from tools/biolatency
rename to tools/biolatency.py
diff --git a/tools/biosnoop b/tools/biosnoop.py
similarity index 100%
rename from tools/biosnoop
rename to tools/biosnoop.py
diff --git a/tools/funccount b/tools/funccount.py
similarity index 100%
rename from tools/funccount
rename to tools/funccount.py
diff --git a/tools/funclatency b/tools/funclatency.py
similarity index 100%
rename from tools/funclatency
rename to tools/funclatency.py
diff --git a/tools/hardirqs b/tools/hardirqs.py
similarity index 100%
rename from tools/hardirqs
rename to tools/hardirqs.py
diff --git a/tools/killsnoop b/tools/killsnoop.py
similarity index 100%
rename from tools/killsnoop
rename to tools/killsnoop.py
diff --git a/tools/offcputime b/tools/offcputime.py
similarity index 100%
rename from tools/offcputime
rename to tools/offcputime.py
diff --git a/tools/opensnoop b/tools/opensnoop.py
similarity index 100%
rename from tools/opensnoop
rename to tools/opensnoop.py
diff --git a/tools/pidpersec b/tools/pidpersec.py
similarity index 100%
rename from tools/pidpersec
rename to tools/pidpersec.py
diff --git a/tools/softirqs b/tools/softirqs.py
similarity index 100%
rename from tools/softirqs
rename to tools/softirqs.py
diff --git a/tools/stackcount b/tools/stackcount.py
similarity index 100%
rename from tools/stackcount
rename to tools/stackcount.py
diff --git a/tools/stacksnoop b/tools/stacksnoop.py
similarity index 100%
rename from tools/stacksnoop
rename to tools/stacksnoop.py
diff --git a/tools/syncsnoop b/tools/syncsnoop.py
similarity index 100%
rename from tools/syncsnoop
rename to tools/syncsnoop.py
diff --git a/tools/tcpaccept b/tools/tcpaccept.py
similarity index 100%
rename from tools/tcpaccept
rename to tools/tcpaccept.py
diff --git a/tools/tcpconnect b/tools/tcpconnect.py
similarity index 100%
rename from tools/tcpconnect
rename to tools/tcpconnect.py
diff --git a/tools/vfscount b/tools/vfscount.py
similarity index 100%
rename from tools/vfscount
rename to tools/vfscount.py
diff --git a/tools/vfsstat b/tools/vfsstat.py
similarity index 100%
rename from tools/vfsstat
rename to tools/vfsstat.py