Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 2 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 6 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 8 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 14 | |
| 15 | ######################################################################## |
| 16 | ## |
| 17 | ## |
| 18 | ## Config |
| 19 | ## |
| 20 | ## |
| 21 | TOP_DIR=`pwd` |
Girish Gowdra | 5287fde | 2021-07-31 00:41:45 +0000 | [diff] [blame] | 22 | OPENOLTDEVICE ?= sim |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 23 | |
Elia Battiston | 869a5de | 2022-02-08 11:40:58 +0100 | [diff] [blame] | 24 | OPENOLT_PROTO_VER ?= v5.2.1 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 25 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 26 | ######################################################################## |
| 27 | ## |
| 28 | ## |
| 29 | ## Install prerequisites |
| 30 | ## |
| 31 | ## |
| 32 | |
Thiyagarajan Subramani | a2c2c5a | 2021-05-18 14:47:52 +0530 | [diff] [blame] | 33 | CXX != if [ "$(OPENOLTDEVICE)" = "rlt-3200g-w" ]; then echo "g++-6"; else echo "g++-4.9"; fi |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 34 | CXXFLAGS += -g -O2 |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 35 | CXXFLAGS += `pkg-config --cflags-only-I grpc++` -I/usr/local/include/pcapplusplus/ |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 36 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 37 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
| 38 | CXXFLAGS += -DTEST_MODE -DENABLE_LOG |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 39 | LDFLAGS += -lpthread -lm `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr -lPcap++ -lPacket++ -lCommon++ |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 40 | CXXFLAGSDEVICE = -I../device -I../device/$(OPENOLTDEVICE) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 41 | |
| 42 | export CXX CXXFLAGS OPENOLT_PROTO_VER |
| 43 | |
Girish Gowdra | 5287fde | 2021-07-31 00:41:45 +0000 | [diff] [blame] | 44 | BAL_MAJOR_VER = 3 |
| 45 | BAL_MINOR_VER = 10 |
| 46 | BAL_REV_HOST_VER = 2 |
| 47 | BAL_REV_EMBEDDED_VER = 2 |
| 48 | BAL_API_SO_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_HOST_VER) |
| 49 | BAL_API_VER = $(BAL_API_SO_VER).$(BAL_REV_EMBEDDED_VER) |
| 50 | |
| 51 | BAL_API_DIR=bal-oss-api-$(BAL_API_VER) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 52 | BALLIBNAME=bcm_host_api_stubs |
| 53 | BALLIBDIR=$(BAL_API_DIR)/stubs |
| 54 | BAL_INC = -I$(BAL_API_DIR)/include \ |
| 55 | -I$(BAL_API_DIR)/include/object_model |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 56 | CXXFLAGS += $(BAL_INC) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 57 | |
| 58 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 59 | ######################################################################## |
| 60 | ## |
| 61 | ## |
| 62 | ## build |
| 63 | ## |
| 64 | ## |
| 65 | |
| 66 | .DEFAULT_GOAL := all |
| 67 | |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 68 | .PHONY = bcm_host_api_stubs build clean prereqs-system prereqs-local |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 69 | |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 70 | OPENOLT_PROTOS_DIR = ../../protos |
| 71 | OPENOLT_API_LIB = lib/libopenoltapi.a |
| 72 | OPENOLT_LIB = lib/libopenolt.a |
| 73 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 74 | # Set the OPENOLT_ROOT_DIR variable to "/app" folder inside the docker container, if not already set. |
| 75 | ifeq ($(OPENOLT_ROOT_DIR),) |
| 76 | OPENOLT_ROOT_DIR := /app |
| 77 | endif |
| 78 | |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 79 | all: bcm_host_api_stubs $(OPENOLT_API_LIB) $(OPENOLT_LIB) build |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 80 | |
| 81 | # test |
| 82 | TEST_OPENOLT_LIB_DIR=./lib |
| 83 | TEST_BIN=test_openolt |
| 84 | # The below way of getting source files is not working |
| 85 | #TEST_SRCS = $($(filter-out src/bal_stub.cc, $(wildcard src/*.cc))) |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 86 | TEST_SRCS = src/main_test.cc src/bal_mocker.cc src/test_core.cc |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 87 | TEST_OBJS = $(TEST_SRCS:.cc=.o) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 88 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 89 | build: $(TEST_OBJS) |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 90 | $(CXX) $(shell cmock-config --libs) -L$(TEST_OPENOLT_LIB_DIR) -L/usr/lib/ -I/usr/include -I./inc -I../src -o $(TEST_BIN) $(TEST_OBJS) -lgmock -lgtest -lopenolt -lopenoltapi $(LDFLAGS) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 91 | src/%.o: src/%.cc |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 92 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I./inc -I../common -I../src -I/usr/include -c $< -o $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | # bcm_host_api_stubs |
Chaitrashree G S | fd15c8c | 2019-09-09 18:46:15 -0400 | [diff] [blame] | 96 | bcm_host_api_stubs: |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 97 | echo $(OPENOLT_ROOT_DIR); \ |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 98 | # TODO: This is temporary hack below to introduce the definition BAL IEs that are missing in https://github.com/balapi/bal-api-<BAL-VER> |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 99 | if [ -d $(BAL_API_DIR) ]; then \ |
| 100 | echo "$(BAL_API_DIR) exists"; \ |
| 101 | else \ |
Girish Gowdra | 5287fde | 2021-07-31 00:41:45 +0000 | [diff] [blame] | 102 | mkdir -p $(BAL_API_DIR); \ |
| 103 | mkdir -p lib; \ |
| 104 | cd $(BAL_API_DIR); \ |
| 105 | git clone https://github.com/balapi/bal-sdk.git -b $(BAL_API_VER); \ |
| 106 | mv bal-sdk bal-sdk-$(BAL_API_VER); \ |
| 107 | cd bal-sdk-$(BAL_API_VER); \ |
| 108 | make BOARD=$(OPENOLTDEVICE); \ |
| 109 | cp build/fs/libbal_host_api-oss.$(BAL_API_SO_VER).so ../../lib/libbal_host_api-oss.so; \ |
| 110 | cd .. && ln -s bal-sdk-$(BAL_API_VER)/build/fs/include include; \ |
| 111 | sed -i 's/BUG_ON_PRINT((condition),/printf(/g' include/bcmos_system.h; \ |
| 112 | cd ..;\ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 113 | fi |
| 114 | |
| 115 | # openoltapi |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 116 | CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 117 | $(OPENOLT_API_LIB): $(wildcard $(OPENOLT_PROTOS_DIR)/*.proto) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 118 | make -C $(OPENOLT_PROTOS_DIR) all |
| 119 | mkdir -p lib |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 120 | cp $(OPENOLT_PROTOS_DIR)/libopenoltapi.a lib/ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 121 | libproto-clean: |
| 122 | make -C $(OPENOLT_PROTOS_DIR) clean |
| 123 | |
| 124 | # openolt |
Girish Gowdra | b0337eb | 2022-03-25 16:44:21 -0700 | [diff] [blame^] | 125 | OPENOLT_SRCS = $(wildcard ../src/*.cc) ../common/server.cc ../device/device.cc $(wildcard ../device/$(OPENOLTDEVICE)/*.cc) src/bal_stub.cc |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 126 | OPENOLT_OBJS = $(OPENOLT_SRCS:.cc=.o) |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 127 | $(OPENOLT_LIB): $(OPENOLT_OBJS) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 128 | mkdir -p lib |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 129 | ar cr $@ $^ |
| 130 | ranlib $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 131 | ../common/%.o: ../common/%.cc |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 132 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I../src -c $< -o $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 133 | ../src/%.o: ../src/%.cc |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 134 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I../src -c $< -o $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 135 | src/%.o: src/%.cc |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 136 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I../src -c $< -o $@ |
Girish Gowdra | b0337eb | 2022-03-25 16:44:21 -0700 | [diff] [blame^] | 137 | ../device/%.o: ../device/%.cc |
| 138 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I../src -c $< -o $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 139 | ../device/$(OPENOLTDEVICE)/%.o: ../device/$(OPENOLTDEVICE)/%.cc |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 140 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I../common -I./inc -I../src -c $< -o $@ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 141 | |
| 142 | test: all |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 143 | ./test_openolt --gtest_output="xml:./test_openolt_report_xunit.xml" |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 144 | |
| 145 | clean: |
Girish Gowdra | b0337eb | 2022-03-25 16:44:21 -0700 | [diff] [blame^] | 146 | rm -f src/*.o lib/*.a ../src/*.o ../common/*.o ../device/device.o ./test_openolt ./test_openolt_report_xunit.xml |