|
| 1 | +################################################################################ |
| 2 | +# # |
| 3 | +# Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or # |
| 4 | +# its subsidiaries. # |
| 5 | +# # |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); # |
| 7 | +# you may not use this file except in compliance with the License. # |
| 8 | +# You may obtain a copy of the License at # |
| 9 | +# # |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 # |
| 11 | +# # |
| 12 | +# Unless required by applicable law or agreed to in writing, software # |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, # |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # |
| 15 | +# See the License for the specific language governing permissions and # |
| 16 | +# limitations under the License. # |
| 17 | +# # |
| 18 | +################################################################################ |
| 19 | + |
| 20 | +.PHONY: all clean cleanall codegen rest-server rest-clean yamlGen cli |
| 21 | + |
| 22 | +TOPDIR := $(abspath .) |
| 23 | +BUILD_DIR := $(TOPDIR)/build |
| 24 | +export TOPDIR |
| 25 | + |
| 26 | +ifeq ($(BUILD_GOPATH),) |
| 27 | +export BUILD_GOPATH=$(TOPDIR)/gopkgs |
| 28 | +endif |
| 29 | + |
| 30 | +export GOPATH=$(BUILD_GOPATH):$(TOPDIR) |
| 31 | + |
| 32 | +ifeq ($(GO),) |
| 33 | +GO := /usr/local/go/bin/go |
| 34 | +export GO |
| 35 | +endif |
| 36 | + |
| 37 | +INSTALL := /usr/bin/install |
| 38 | + |
| 39 | +MAIN_TARGET = sonic-mgmt-framework_1.0-01_amd64.deb |
| 40 | + |
| 41 | +GO_DEPS_LIST = github.com/gorilla/mux \ |
| 42 | + github.com/Workiva/go-datastructures/queue \ |
| 43 | + github.com/openconfig/goyang \ |
| 44 | + github.com/openconfig/ygot/ygot \ |
| 45 | + github.com/go-redis/redis \ |
| 46 | + github.com/golang/glog \ |
| 47 | + github.com/pkg/profile \ |
| 48 | + gopkg.in/go-playground/validator.v9 \ |
| 49 | + golang.org/x/crypto/ssh \ |
| 50 | + github.com/antchfx/jsonquery \ |
| 51 | + github.com/antchfx/xmlquery \ |
| 52 | + github.com/facette/natsort \ |
| 53 | + github.com/philopon/go-toposort |
| 54 | + |
| 55 | + |
| 56 | +REST_BIN = $(BUILD_DIR)/rest_server/main |
| 57 | +CERTGEN_BIN = $(BUILD_DIR)/rest_server/generate_cert |
| 58 | + |
| 59 | + |
| 60 | +all: build-deps go-deps go-pkg-version go-patch translib rest-server cli |
| 61 | + |
| 62 | +build-deps: |
| 63 | + mkdir -p $(BUILD_DIR) |
| 64 | + |
| 65 | +go-deps: $(GO_DEPS_LIST) |
| 66 | + |
| 67 | +go-pkg-version: go-deps |
| 68 | + cd $(BUILD_GOPATH)/src/github.com/go-redis/redis; git checkout d19aba07b47683ef19378c4a4d43959672b7cec8 2>/dev/null ; true; \ |
| 69 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/go-redis/redis; \ |
| 70 | +cd $(BUILD_GOPATH)/src/github.com/gorilla/mux; git checkout 49c01487a141b49f8ffe06277f3dca3ee80a55fa 2>/dev/null ; true; \ |
| 71 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/gorilla/mux; \ |
| 72 | +cd $(BUILD_GOPATH)/src/github.com/Workiva/go-datastructures; git checkout f07cbe3f82ca2fd6e5ab94afce65fe43319f675f 2>/dev/null ; true; \ |
| 73 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/Workiva/go-datastructures; \ |
| 74 | +cd $(BUILD_GOPATH)/src/github.com/golang/glog; git checkout 23def4e6c14b4da8ac2ed8007337bc5eb5007998 2>/dev/null ; true; \ |
| 75 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/golang/glog; \ |
| 76 | +cd $(BUILD_GOPATH)/src/github.com/pkg/profile; git checkout acd64d450fd45fb2afa41f833f3788c8a7797219 2>/dev/null ; true; \ |
| 77 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/pkg/profile; \ |
| 78 | +cd $(BUILD_GOPATH)/src/github.com/antchfx/xmlquery; git checkout 16f1e6cdc5fe44a7f8e2a8c9faf659a1b3a8fd9b 2>/dev/null ; true; \ |
| 79 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/antchfx/xmlquery; \ |
| 80 | +cd $(BUILD_GOPATH)/src/github.com/facette/natsort; git checkout 2cd4dd1e2dcba4d85d6d3ead4adf4cfd2b70caf2 2>/dev/null ; true; \ |
| 81 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/facette/natsort; \ |
| 82 | +cd $(BUILD_GOPATH)/src/github.com/philopon/go-toposort; git checkout 9be86dbd762f98b5b9a4eca110a3f40ef31d0375 2>/dev/null ; true; \ |
| 83 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/philopon/go-toposort |
| 84 | + |
| 85 | +$(GO_DEPS_LIST): |
| 86 | + $(GO) get -v $@ |
| 87 | + |
| 88 | +cli: rest-server |
| 89 | + $(MAKE) -C src/CLI |
| 90 | + |
| 91 | +cvl: go-deps go-patch go-pkg-version |
| 92 | + $(MAKE) -C src/cvl |
| 93 | + $(MAKE) -C src/cvl/schema |
| 94 | + $(MAKE) -C src/cvl/testdata/schema |
| 95 | + |
| 96 | +cvl-test: |
| 97 | + $(MAKE) -C src/cvl gotest |
| 98 | + |
| 99 | +rest-server: translib |
| 100 | + $(MAKE) -C src/rest |
| 101 | + |
| 102 | +rest-clean: |
| 103 | + $(MAKE) -C src/rest clean |
| 104 | + |
| 105 | +translib: cvl |
| 106 | + $(MAKE) -C src/translib |
| 107 | + |
| 108 | +codegen: |
| 109 | + $(MAKE) -C models |
| 110 | + |
| 111 | +yamlGen: |
| 112 | + $(MAKE) -C models/yang |
| 113 | + $(MAKE) -C models/yang/sonic |
| 114 | + |
| 115 | +go-patch: go-deps |
| 116 | + cd $(BUILD_GOPATH)/src/github.com/openconfig/ygot/; git reset --hard HEAD; git clean -f -d; git checkout 724a6b18a9224343ef04fe49199dfb6020ce132a 2>/dev/null ; true; \ |
| 117 | +cd ../; cp $(TOPDIR)/ygot-modified-files/ygot.patch .; \ |
| 118 | +patch -p1 < ygot.patch; rm -f ygot.patch; \ |
| 119 | +$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/openconfig/ygot/ygot; \ |
| 120 | + cd $(BUILD_GOPATH)/src/github.com/openconfig/goyang/; git reset --hard HEAD; git clean -f -d; git checkout 064f9690516f4f72db189f4690b84622c13b7296 >/dev/null ; true; \ |
| 121 | + cp $(TOPDIR)/goyang-modified-files/goyang.patch .; \ |
| 122 | + patch -p1 < goyang.patch; rm -f goyang.patch; \ |
| 123 | + $(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/openconfig/goyang; \ |
| 124 | + cd $(BUILD_GOPATH)/src/github.com/antchfx/jsonquery; git reset --hard HEAD; \ |
| 125 | + git checkout 3535127d6ca5885dbf650204eb08eabf8374a274 2>/dev/null ; \ |
| 126 | + git apply $(TOPDIR)/patches/jsonquery.patch; \ |
| 127 | + $(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/antchfx/jsonquery |
| 128 | + |
| 129 | +install: |
| 130 | + $(INSTALL) -D $(REST_BIN) $(DESTDIR)/usr/sbin/rest_server |
| 131 | + $(INSTALL) -D $(CERTGEN_BIN) $(DESTDIR)/usr/sbin/generate_cert |
| 132 | + $(INSTALL) -d $(DESTDIR)/usr/sbin/schema/ |
| 133 | + $(INSTALL) -d $(DESTDIR)/usr/sbin/lib/ |
| 134 | + $(INSTALL) -d $(DESTDIR)/usr/models/yang/ |
| 135 | + $(INSTALL) -D $(TOPDIR)/models/yang/sonic/*.yang $(DESTDIR)/usr/models/yang/ |
| 136 | + $(INSTALL) -D $(TOPDIR)/models/yang/sonic/common/*.yang $(DESTDIR)/usr/models/yang/ |
| 137 | + $(INSTALL) -D $(TOPDIR)/src/cvl/schema/*.yin $(DESTDIR)/usr/sbin/schema/ |
| 138 | + $(INSTALL) -D $(TOPDIR)/src/cvl/testdata/schema/*.yin $(DESTDIR)/usr/sbin/schema/ |
| 139 | + $(INSTALL) -D $(TOPDIR)/models/yang/*.yang $(DESTDIR)/usr/models/yang/ |
| 140 | + $(INSTALL) -D $(TOPDIR)/config/transformer/models_list $(DESTDIR)/usr/models/yang/ |
| 141 | + $(INSTALL) -D $(TOPDIR)/models/yang/common/*.yang $(DESTDIR)/usr/models/yang/ |
| 142 | + $(INSTALL) -D $(TOPDIR)/models/yang/annotations/*.yang $(DESTDIR)/usr/models/yang/ |
| 143 | + cp -rf $(TOPDIR)/build/rest_server/dist/ui/ $(DESTDIR)/rest_ui/ |
| 144 | + cp -rf $(TOPDIR)/build/cli $(DESTDIR)/usr/sbin/ |
| 145 | + cp -rf $(TOPDIR)/build/swagger_client_py/ $(DESTDIR)/usr/sbin/lib/ |
| 146 | + cp -rf $(TOPDIR)/src/cvl/conf/cvl_cfg.json $(DESTDIR)/usr/sbin/cvl_cfg.json |
| 147 | + |
| 148 | +ifeq ($(SONIC_COVERAGE_ON),y) |
| 149 | + echo "" > $(DESTDIR)/usr/sbin/.test |
| 150 | +endif |
| 151 | + |
| 152 | +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : |
| 153 | + mv $* $(DEST)/ |
| 154 | + |
| 155 | +clean: rest-clean |
| 156 | + $(MAKE) -C src/cvl clean |
| 157 | + $(MAKE) -C src/translib clean |
| 158 | + $(MAKE) -C src/cvl/schema clean |
| 159 | + $(MAKE) -C src/cvl cleanall |
| 160 | + rm -rf build/* |
| 161 | + rm -rf debian/.debhelper |
| 162 | + rm -rf $(BUILD_GOPATH)/src/github.com/openconfig/goyang/annotate.go |
| 163 | + |
| 164 | +cleanall: |
| 165 | + $(MAKE) -C src/cvl cleanall |
| 166 | + rm -rf build/* |
0 commit comments