VOL-1053 - OpenOLT - Makefile cleanup

- fix issue with libprotobuf dependency
- suppress a stats log

Change-Id: Ib0caf3394fa8f4a281dcaf47cb4e55ed3ceb62fa
diff --git a/Makefile b/Makefile
index 1211afa..a9e4a93 100644
--- a/Makefile
+++ b/Makefile
@@ -56,52 +56,23 @@
 CXX = g++
 CPPFLAGS += `pkg-config --cflags protobuf grpc`
 CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
-#ifeq ($(SYSTEM),Darwin)
-#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
-#					 -lgrpc++_reflection\
-#					 -ldl
-#else
-#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
-#					 -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-#					 -ldl
-#endif
-LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
+LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` -ldl
 
 prereq:
 	sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io
 	sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers
 
-	# Install GRPC plugins
+	# Install GRPC, libprotobuf and protoc
 	rm -rf $(GRPC_DST)
 	git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST)
 	cd $(GRPC_DST) && git submodule update --init
-	make -C $(GRPC_DST)
-	sudo make -C $(GRPC_DST) install
-	# Install libprotobuf and protoc
-	cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh
-	cd $(GRPC_DST)/third_party/protobuf && ./configure
+	cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh && ./configure
 	make -C $(GRPC_DST)/third_party/protobuf
 	sudo make -C $(GRPC_DST)/third_party/protobuf install
 	sudo ldconfig
-
-	# libunwind (needed by glog)
-	rm -rf /tmp/libunwind-1.2
-	wget http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.2.tar.gz -P /tmp
-	cd /tmp && tar -xzvf libunwind-1.2.tar.gz
-	cd /tmp/libunwind-1.2 && ./configure
-	make -C /tmp/libunwind-1.2
-	sudo make -C /tmp/libunwind-1.2 install
-
-	# cmake (needed by glog)
-	sudo apt-get remove cmake cmake-data
-	sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x
-	sudo -E apt-get update
-	sudo apt-get install -y cmake
-
-        # glog
-	rm -rf /tmp/glog
-	git clone https://github.com/google/glog.git /tmp/glog
-	cd /tmp/glog && cmake -H. -Bbuild -G "Unix Makefiles" && cmake --build build && sudo cmake --build build --target install
+	make -C $(GRPC_DST)
+	sudo make -C $(GRPC_DST) install
+	sudo ldconfig
 
 docker:
 	echo $(USER)
@@ -163,9 +134,6 @@
 	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/model \
 	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/api \
 	-I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_reference/cli
-#       -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_customized/os_abstraction
-#       -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_customized/os_abstraction/posix
-#       -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/config
 CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
 CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST
 
@@ -225,20 +193,18 @@
 .DEFAULT_GOAL := all
 all: $(BUILD_DIR)/openolt
 $(BUILD_DIR)/openolt: sdk protos $(OBJS)
-	$(CXX) $(OBJS) $(OPENOLT_API_LIB) -o $@ -L$(BALLIBDIR) -l$(BALLIBNAME) $(LDFLAGS)
+	$(CXX) -pthread -L/usr/local/lib -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) /usr/local/lib/libprotobuf.a -o $@ -l$(BALLIBNAME) -lgrpc++ -lgrpc -lpthread -ldl
 	ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(DEVICE)/release/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz $(BUILD_DIR)/.
 	ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(DEVICE)/release/broadcom/libbal_api_dist.so $(BUILD_DIR)/.
 	ln -sf $(PWD)/$(BAL_DIR)/bal_release/build/core/src/apps/bal_core_dist/bal_core_dist $(BUILD_DIR)/.
 	ln -sf $(shell ldconfig -p | grep libgrpc.so.6 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc.so.6
 	ln -sf $(shell ldconfig -p | grep libgrpc++.so.1 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc++.so.1
-	ln -sf $(shell ldconfig -p | grep libgrpc++_reflection.so.1 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc++_reflection.so.1
 
 deb:
 	cp $(BUILD_DIR)/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz mkdebian/debian
 	cp $(BUILD_DIR)/openolt mkdebian/debian
 	cp $(BUILD_DIR)/libgrpc.so.6 mkdebian/debian
 	cp $(BUILD_DIR)/libgrpc++.so.1 mkdebian/debian
-	cp $(BUILD_DIR)/libgrpc++_reflection.so.1 mkdebian/debian
 	cd mkdebian && ./build_$(DEVICE)_deb.sh
 	mv *.deb $(BUILD_DIR)/openolt.deb
 	make deb-cleanup
@@ -253,7 +219,6 @@
 	rm -f mkdebian/debian/$(DEVICE).substvars
 	rm -rf mkdebian/debian/$(DEVICE)/
 	rm -f mkdebian/debian/libgrpc++.so.1
-	rm -f mkdebian/debian/libgrpc++_reflection.so.1
 	rm -f mkdebian/debian/libgrpc.so.6
 	rm -f mkdebian/debian/openolt
 	rm -f mkdebian/debian/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz
@@ -263,7 +228,7 @@
 clean: protos-clean deb-cleanup
 	rm -f $(OBJS) $(DEPS)
 	rm -rf protos/googleapis
-	rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++_reflection.so.1
+	rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1
 	rm -f $(BUILD_DIR)/libbal_api_dist.so
 	rm -f $(BUILD_DIR)/openolt
 	rm -f $(BUILD_DIR)/bal_core_dist
diff --git a/mkdebian/debian/asfvolt16.postinst b/mkdebian/debian/asfvolt16.postinst
index c19fb79..5369f78 100644
--- a/mkdebian/debian/asfvolt16.postinst
+++ b/mkdebian/debian/asfvolt16.postinst
@@ -6,7 +6,6 @@
 grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
 rm -f /run/bcm68620
 mv /tmp/openolt /broadcom
-mv /tmp/libgrpc++_reflection.so.1 /usr/local/lib
 mv /tmp/libgrpc++.so.1 /usr/local/lib
 mv /tmp/libgrpc.so.6 /usr/local/lib
 mv /broadcom/libbal_api_dist.so /usr/local/lib
diff --git a/mkdebian/debian/asfvolt16.postrm b/mkdebian/debian/asfvolt16.postrm
index 64bde5b..f5dc1d5 100644
--- a/mkdebian/debian/asfvolt16.postrm
+++ b/mkdebian/debian/asfvolt16.postrm
@@ -4,7 +4,6 @@
 rm -rf /broadcom
 sed -i '\/opt\/bcm68620\/svk_init.sh/d' /etc/rc.local
 rm -rf /run/bcm68620
-rm -rf /usr/local/lib/libgrpc++_reflection.so.1
 rm -rf /usr/local/lib/libgrpc++.so.1
 rm -rf /usr/local/lib/libgrpc.so.6
 rm -rf /usr/local/lib/libbal_api_dist.so
diff --git a/mkdebian/debian/asfvolt16.preinst b/mkdebian/debian/asfvolt16.preinst
index 6660aaa..9377c9a 100644
--- a/mkdebian/debian/asfvolt16.preinst
+++ b/mkdebian/debian/asfvolt16.preinst
@@ -31,7 +31,6 @@
 
 rm -rf  /broadcom
 
-rm -rf /usr/local/lib/libgrpc++_reflection.so.1
 rm -rf /usr/local/lib/libgrpc++.so.1
 rm -rf /usr/local/lib/libgrpc.so.5
 rm -rf /usr/local/lib/libbal_api_dist.so
diff --git a/mkdebian/debian/rules b/mkdebian/debian/rules
index c785567..8a7f968 100755
--- a/mkdebian/debian/rules
+++ b/mkdebian/debian/rules
@@ -27,7 +27,6 @@
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/release_asfvolt16_V02.06.201804301043.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/libgrpc++_reflection.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc++.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
diff --git a/protos/Makefile b/protos/Makefile
index 95629a8..1795977 100644
--- a/protos/Makefile
+++ b/protos/Makefile
@@ -17,16 +17,7 @@
 CXX = g++
 CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens
 CXXFLAGS += -std=c++11
-#ifeq ($(SYSTEM),Darwin)
-#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
-#           -lgrpc++_reflection\
-#           -ldl
-#else
-#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
-#           -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-#           -ldl
-#endif
-LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
+#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
 PROTOC = protoc
 GRPC_CPP_PLUGIN = grpc_cpp_plugin
 GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
diff --git a/src/stats_collection.cc b/src/stats_collection.cc
index 5ec33bc..ef922c3 100644
--- a/src/stats_collection.cc
+++ b/src/stats_collection.cc
@@ -93,8 +93,8 @@
     err = bcmbal_stat_get(DEFAULT_ATERM_ID, &stat.hdr, clear_on_read);
     if (err == BCM_ERR_OK)
     {
-        std::cout << "Interface statistics retrieved"
-                  << " intf_id:" << intf_id << std::endl;
+        //std::cout << "Interface statistics retrieved"
+        //          << " intf_id:" << intf_id << std::endl;
 
         port_stats->set_rx_bytes(stat.data.rx_bytes);
         port_stats->set_rx_packets(stat.data.rx_packets);