Revert "For ONL and BAL v3.0 build environment, you could only build for ONL and BAL source codes now."

This reverts commit a3ea20f2ee6b72c72a0a13584997ced6a7993760.

Change-Id: Idb3bdcdb46e9c5675acc4602c3bc312cf0fc59ff
diff --git a/agent/Makefile.in b/agent/Makefile.in
index 67ad514..29bdaf3 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -19,7 +19,6 @@
 ##        Config
 ##
 ##
-TOP_DIR=`pwd`
 OPENOLTDEVICE ?= generic
 
 #
@@ -27,14 +26,14 @@
 # SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK.
 # sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK.
 # ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch.
-BAL_MAJOR_VER = 03.00
-BAL_VER = 3.0.3.3
-SDK_VER = 6.5.13
-DEV_VER ?= 201904171432
+BAL_MAJOR_VER = 02.06
+BAL_VER = 2.6.0.1
+SDK_VER = 6.5.7
+DEV_VER ?= 201804301043
 #
 # Version of Open Network Linux (ONL).
-ONL_KERN_VER_MAJOR = 4.14
-ONL_KERN_VER_MINOR = 49
+ONL_KERN_VER_MAJOR = 3.7
+ONL_KERN_VER_MINOR = 10
 #
 # Build directory
 BUILD_DIR = build
@@ -104,9 +103,7 @@
 onl:
 	if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
 		mkdir -p $(ONL_DIR); \
-		git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
-		cp download/Makefile.onl $(ONL_DIR)/Makefile; \
-		install -m 755 download/build-asfvolt16.sh $(ONL_DIR)/OpenNetworkLinux; \
+		git clone https://gerrit.opencord.org/$(ONL_REPO) $(ONL_DIR); \
 		make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR); \
 	fi;
 onl-force:
@@ -120,14 +117,16 @@
 ##        BAL
 ##
 ##
-BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).tgz
+BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).zip
 SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
 ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
 OPENOLT_BAL_PATCH = OPENOLT_BAL_$(BAL_VER).patch
 BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
-BCM_SDK = $(BAL_DIR)/switch_sdk/6.5.13
-BALLIBDIR = $(BAL_DIR)/build/asfvolt16-bal/build/lib/libbal_core.so
-BALLIBNAME = bal_core.so
+ONL_KERNDIR = $(PWD)/$(ONL_DIR)/OpenNetworkLinux/packages/base/amd64/kernels/kernel-$(ONL_KERN_VER_MAJOR)-x86-64-all/builds
+MAPLE_KERNDIR = $(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/kernels
+BCM_SDK = $(BAL_DIR)/bal_release/3rdparty/bcm-sdk
+BALLIBDIR = $(BAL_DIR)/bal_release/build/core/src/apps/bal_api_dist_shared_lib
+BALLIBNAME = bal_api_dist
 BAL_INC = -I$(BAL_DIR)/bal_release/src/common/os_abstraction \
 	-I$(BAL_DIR)/bal_release/src/common/os_abstraction/posix \
 	-I$(BAL_DIR)/bal_release/src/common/config \
@@ -151,21 +150,32 @@
 sdk: onl
 ifeq ("$(wildcard $(BAL_DIR))","")
 	mkdir $(BAL_DIR)
-	tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
+	unzip download/$(BAL_ZIP) -d $(BAL_DIR)
 	cp download/$(SDK_ZIP) $(BCM_SDK)
 	chmod -R 744 $(BAL_DIR)
 	cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
-	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux SW_UTIL_SHELL=y
-	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/board_files/broadcom/bal_config.ini
-	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
+	mkdir -p $(MAPLE_KERNDIR)
+	ln -s $(ONL_KERNDIR)/linux-$(ONL_KERN_VER) $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER)
+	ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/archives/linux-$(ONL_KERN_VER).tar.xz $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER).tar.xz
+	ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/$(ONL_KERN_VER_MAJOR)/configs/x86_64-all/x86_64-all.config $(MAPLE_KERNDIR)/x86_64-all.config
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk_dir
+	cat download/$(OPENOLT_BAL_PATCH) | patch -p1 -d $(BAL_DIR)
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk_dir
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk
+	KERNDIR=$(ONL_KERNDIR)/linux-$(ONL_KERN_VER) BOARD=$(OPENOLTDEVICE) ARCH=x86_64 SDKBUILD=build_bcm_user make -C $(BCM_SDK)/build-$(OPENOLTDEVICE)/sdk-all-$(SDK_VER)/systems/linux/user/x86-generic_64-2_6
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal
+	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/$(OPENOLTDEVICE)/board_files/broadcom/bal_config.ini
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board
 endif
 
-bal-release: sdk
-	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/board_files/broadcom/bal_config.ini
-	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
+bal: sdk
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal
+	echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/asfvolt16/board_files/broadcom/bal_config.ini
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board
 
 bal-clean:
-	make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean
+	make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) clean_bal
 
 ########################################################################
 ##
@@ -229,10 +239,7 @@
 OBJS = $(SRCS:.cc=.o)
 DEPS = $(SRCS:.cc=.d)
 .DEFAULT_GOAL := all
-#all: $(BUILD_DIR)/openolt
-all: notes onl sdk
-notes:
-	echo "\033[1;31m!!! The OpenOLT source codes is not yet support the BAL V3.0, so ignoring to build !!!\033[0m"
+all: $(BUILD_DIR)/openolt
 $(BUILD_DIR)/openolt: sdk protos $(OBJS)
 	$(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc)
 	ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
diff --git a/agent/download/Makefile.onl b/agent/download/Makefile.onl
deleted file mode 100644
index a025194..0000000
--- a/agent/download/Makefile.onl
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2018 Makefile
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-asfvolt16-4.14:
-	cd OpenNetworkLinux && docker/tools/onlbuilder --non-interactive -8 -c ./build-asfvolt16.sh
diff --git a/agent/download/build-asfvolt16.sh b/agent/download/build-asfvolt16.sh
deleted file mode 100644
index ae86073..0000000
--- a/agent/download/build-asfvolt16.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2018 Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apt-cacher-ng && source setup.env && make amd64
-exit