forked from sonic-net/sonic-mgmt-framework
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
220 lines (175 loc) · 8.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
################################################################################
# #
# Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or #
# its subsidiaries. #
# #
# 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. #
# #
################################################################################
.PHONY: all clean cleanall codegen rest-server rest-clean yamlGen cli clitree ham clidocgen clidocgen-clean
TOPDIR := $(abspath .)
BUILD_DIR := $(TOPDIR)/build
export TOPDIR
ifeq ($(BUILD_GOPATH),)
export BUILD_GOPATH=$(TOPDIR)/build/gopkgs
endif
export GOPATH=$(BUILD_GOPATH):$(TOPDIR)
ifeq ($(GO),)
GO := /usr/local/go/bin/go
export GO
endif
INSTALL := /usr/bin/install
MAIN_TARGET = sonic-mgmt-framework_1.0-01_amd64.deb
GO_DEPS_LIST = github.com/gorilla/mux \
github.com/Workiva/go-datastructures/queue \
github.com/openconfig/goyang \
github.com/openconfig/ygot/ygot \
github.com/go-redis/redis \
github.com/golang/glog \
github.com/pkg/profile \
gopkg.in/go-playground/validator.v9 \
golang.org/x/crypto/ssh \
github.com/antchfx/xpath \
github.com/antchfx/jsonquery \
github.com/antchfx/xmlquery \
github.com/facette/natsort \
github.com/philopon/go-toposort \
gopkg.in/godbus/dbus.v5 \
github.com/dgrijalva/jwt-go \
github.com/msteinert/pam
REST_BIN = $(BUILD_DIR)/rest_server/main
CERTGEN_BIN = $(BUILD_DIR)/rest_server/generate_cert
go-deps = $(BUILD_DIR)/gopkgs/.done
go-patch = $(BUILD_DIR)/gopkgs/.patch_done
go-redis-patch = $(BUILD_DIR)/gopkgs/.redis_patch_done
all: build-deps $(go-deps) $(go-redis-patch) $(go-patch) translib rest-server cli ham
build-deps:
mkdir -p $(BUILD_DIR)/gopkgs
$(BUILD_DIR)/gopkgs/.done: $(MAKEFILE_LIST)
$(GO) get -v $(GO_DEPS_LIST)
touch $@
$(go-redis-patch): $(go-deps)
cd $(BUILD_GOPATH)/src/github.com/go-redis/redis; git checkout d19aba07b47683ef19378c4a4d43959672b7cec8 2>/dev/null ; true; \
$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/go-redis/redis
touch $@
cli:
$(MAKE) -C src/CLI
clish:
SONIC_CLI_ROOT=$(BUILD_DIR) $(MAKE) -C src/CLI/klish
clitree:
TGT_DIR=$(BUILD_DIR)/cli $(MAKE) -C src/CLI/clitree
clidocgen:
TGT_DIR=$(BUILD_DIR)/cli $(MAKE) -C src/CLI/clitree doc_gen
clidocgen-clean:
TGT_DIR=$(BUILD_DIR)/cli $(MAKE) -C src/CLI/clitree doc_gen_clean
cvl: $(go-deps) $(go-patch) $(go-redis-patch)
$(MAKE) -C src/cvl
cvl-test:
$(MAKE) -C src/cvl gotest
rest-server: build-deps translib
$(MAKE) -C src/rest
rest-clean:
$(MAKE) -C src/rest clean
translib: cvl
$(MAKE) -C src/translib
codegen:
$(MAKE) -C models
yamlGen:
$(MAKE) -C models/yang
$(MAKE) -C models/yang/sonic
ham:
(cd src/ham; ./build.sh)
$(go-patch): $(go-deps)
cd $(BUILD_GOPATH)/src/github.com/openconfig/goyang/; git reset --hard HEAD;git clean -f -d;git checkout 064f9690516f4f72db189f4690b84622c13b7296 >/dev/null ; true; \
cp $(TOPDIR)/goyang-modified-files/goyang.patch .; \
patch -p1 < goyang.patch; rm -f goyang.patch; \
$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/openconfig/goyang; \
cd $(BUILD_GOPATH)/src/github.com/openconfig/ygot/; git reset --hard HEAD;git clean -f -d;git checkout 724a6b18a9224343ef04fe49199dfb6020ce132a 2>/dev/null ; true; \
cd ../; cp $(TOPDIR)/ygot-modified-files/ygot.patch .; \
patch -p1 < ygot.patch; rm -f ygot.patch; \
$(GO) install -v -gcflags "-N -l" $(BUILD_GOPATH)/src/github.com/openconfig/ygot/ygot
#Apply CVL related patches
$(apply_cvl_dep_patches)
touch $@
install:
$(INSTALL) -D $(REST_BIN) $(DESTDIR)/usr/sbin/rest_server
$(INSTALL) -D $(CERTGEN_BIN) $(DESTDIR)/usr/sbin/generate_cert
$(INSTALL) -d $(DESTDIR)/usr/sbin/schema/
$(INSTALL) -d $(DESTDIR)/usr/sbin/lib/
$(INSTALL) -d $(DESTDIR)/usr/bin/
$(INSTALL) -d $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/sonic/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/sonic/common/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/config/transformer/models_list $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/config/transformer/sonic_table_info.json $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/common/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/annotations/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/models/yang/extensions/*.yang $(DESTDIR)/usr/models/yang/
$(INSTALL) -D $(TOPDIR)/build/yaml/api_ignore $(DESTDIR)/usr/models/yang/
cp -rf $(TOPDIR)/build/rest_server/dist/ui/ $(DESTDIR)/rest_ui/
cp -rf $(TOPDIR)/build/cli $(DESTDIR)/usr/sbin/
rsync -a --exclude="test" --exclude="docs" build/swagger_client_py $(DESTDIR)/usr/sbin/lib/
cp -rf $(TOPDIR)/src/cvl/conf/cvl_cfg.json $(DESTDIR)/usr/sbin/cvl_cfg.json
# Copy all CVL schema files
cp -aT build/cvl/schema $(DESTDIR)/usr/sbin/schema
# Scripts for host service
$(INSTALL) -d $(DESTDIR)/usr/lib/sonic_host_service/host_modules
$(INSTALL) -D $(TOPDIR)/scripts/sonic_host_server.py $(DESTDIR)/usr/lib/sonic_host_service
$(INSTALL) -D $(TOPDIR)/scripts/host_modules/*.py $(DESTDIR)/usr/lib/sonic_host_service/host_modules
ifneq ($(ENABLE_ZTP),y)
$(RM) -f $(DESTDIR)/usr/lib/sonic_host_service/host_modules/ztp_handler.py
endif
$(INSTALL) -d $(DESTDIR)/etc/dbus-1/system.d
$(INSTALL) -D $(TOPDIR)/scripts/org.sonic.hostservice.conf $(DESTDIR)/etc/dbus-1/system.d
$(INSTALL) -d $(DESTDIR)/lib/systemd/system
$(INSTALL) -D $(TOPDIR)/scripts/sonic-hostservice.service $(DESTDIR)/lib/systemd/system
$(INSTALL) -d $(DESTDIR)/etc/sonic/
$(INSTALL) -D $(TOPDIR)/config/cfg_mgmt.json $(DESTDIR)/etc/sonic/
# Scripts for Host Account Management (HAM)
$(INSTALL) -D $(TOPDIR)/src/ham/hamd/etc/dbus-1/system.d/* $(DESTDIR)/etc/dbus-1/system.d/
$(INSTALL) -d $(DESTDIR)/etc/sonic/hamd/
$(INSTALL) -D $(TOPDIR)/src/ham/hamd/etc/sonic/hamd/* $(DESTDIR)/etc/sonic/hamd/
$(INSTALL) -D $(TOPDIR)/src/ham/hamd/lib/systemd/system/* $(DESTDIR)/lib/systemd/system/
$(INSTALL) -D $(TOPDIR)/src/ham/hamd/usr/bin/* $(DESTDIR)/usr/bin/
$(INSTALL) -D $(TOPDIR)/src/ham/hamd/hamd $(DESTDIR)/usr/sbin/.
$(INSTALL) -D $(TOPDIR)/src/ham/hamctl/hamctl $(DESTDIR)/usr/bin/.
$(INSTALL) -d $(DESTDIR)/lib/x86_64-linux-gnu/
$(INSTALL) -D $(TOPDIR)/src/ham/libnss_ham/libnss_ham.so.2 $(DESTDIR)/lib/x86_64-linux-gnu/.
# Scripts for the certificate fixer oneshot service
$(INSTALL) -D $(TOPDIR)/src/certfix/usr/sbin/* $(DESTDIR)/usr/sbin/
$(INSTALL) -D $(TOPDIR)/src/certfix/lib/systemd/system/* $(DESTDIR)/lib/systemd/system/
ifeq ($(SONIC_COVERAGE_ON),y)
echo "" > $(DESTDIR)/usr/sbin/.test
endif
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
mv $* $(DEST)/
clean: rest-clean
$(MAKE) -C src/translib clean
$(MAKE) -C src/cvl clean
(cd src/ham; ./build.sh clean)
rm -rf debian/.debhelper
(cd build && find . -maxdepth 1 -name "gopkgs" -prune -o -not -name '.' -exec rm -rf {} +) || true
(cd src/ham && ./build.sh clean || true)
cleanall:
$(MAKE) -C src/cvl cleanall
rm -rf build/*
#Function to apply CVL related patches
define apply_cvl_dep_patches
cd $(BUILD_GOPATH)/src/github.com/antchfx/xpath; git reset --hard HEAD; \
git checkout d9ad276609987dd73ce5cd7d6265fe82189b10b6; git apply $(TOPDIR)/patches/xpath.patch
cd $(BUILD_GOPATH)/src/github.com/antchfx/jsonquery; git reset --hard HEAD; \
git checkout 3b69d31134d889b501e166a035a4d5ecb8c6c367; git apply $(TOPDIR)/patches/jsonquery.patch
cd $(BUILD_GOPATH)/src/github.com/antchfx/xmlquery; git reset --hard HEAD; \
git checkout fe009d4cc63c3011f05e1dfa75a27899acccdf11; git apply $(TOPDIR)/patches/xmlquery.patch
endef