-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
189 lines (164 loc) · 5.64 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
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#
# Copyright 2020 Joyent, Inc.
# Copyright 2023 MNX Cloud, Inc.
#
#
# Makefile: basic Makefile for template API service
#
# This Makefile is a template for new repos. It contains only repo-specific
# logic and uses included makefiles to supply common targets (javascriptlint,
# jsstyle, restdown, etc.), which are used by other repos as well. You may well
# need to rewrite most of this file, but you shouldn't need to touch the
# included makefiles.
#
# If you find yourself adding support for new targets that could be useful for
# other projects too, you should add these to the original versions of the
# included Makefiles (in eng.git) so that other teams can use them too.
#
#
# Tools
#
NGXSYMCHECK = tools/ngx_symcheck
#
# Files
#
DOC_FILES =
BASH_FILES = bin/manta-mako-adm $(NGXSYMCHECK)
SMF_MANIFESTS = smf/manifests/nginx.xml
ESLINT_FILES := $(shell find bin lib test -name '*.js')
#
# Variables
#
RUST_TOOLCHAIN = 1.40.0
# Rust < 1.49 must specify sun-solaris target:
RUST_BOOTSTRAP_TARGET = x86_64-sun-solaris
NAME = mako
NODE_PREBUILT_VERSION = v8.17.0
NODE_PREBUILT_TAG = zone64
# minimal-64 19.4.0
NODE_PREBUILT_IMAGE = 5417ab20-3156-11ea-8b19-2b66f5e7a439
#
# Stuff used for buildimage
#
# triton-origin-x86_64-19.4.0
BASE_IMAGE_UUID = 59ba2e5e-976f-4e09-8aac-a4a7ef0395f5
BUILDIMAGE_NAME = mantav2-storage
BUILDIMAGE_DESC = Manta Storage
BUILDIMAGE_PKGSRC = pcre-8.43 findutils-4.6.0nb2 gawk-5.0.1
AGENTS = amon config minnow registrar rebalancer
ENGBLD_USE_BUILDIMAGE = true
ENGBLD_REQUIRE := $(shell git submodule update --init deps/eng)
include ./deps/eng/tools/mk/Makefile.defs
TOP ?= $(error Unable to access eng.git submodule Makefiles.)
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.defs
include ./deps/eng/tools/mk/Makefile.agent_prebuilt.defs
else
NPM=npm
NODE=node
NPM_EXEC=$(shell which npm)
NODE_EXEC=$(shell which node)
endif
include ./deps/eng/tools/mk/Makefile.node_modules.defs
include ./deps/eng/tools/mk/Makefile.smf.defs
include ./tools/mk/Makefile.nginx.defs
include ./deps/eng/tools/mk/Makefile.rust.defs
#
# MG Variables
#
ROOT := $(shell pwd)
RELEASE_TARBALL := $(NAME)-pkg-$(STAMP).tar.gz
RELSTAGEDIR := /tmp/$(NAME)-$(STAMP)
#
# v8plus uses the CTF tools as part of its build, but they can safely be
# overridden here so that this works in dev zones without them.
# See marlin.git Makefile.
#
NPM_ENV = NODE_ENV=production MAKE_OVERRIDES="CTFCONVERT=/bin/true CTFMERGE=/bin/true"
#
# Repo-specific targets
#
.PHONY: all
all: $(NODE_EXEC) $(NGINX_EXEC) $(REPO_DEPS) scripts build-rollup
$(NPM) install --production
CLEAN_FILES += ./node_modules/ build
check:: | $(NODE_EXEC)
# Just lint check (no style)
.PHONY: lint
lint: | $(ESLINT)
$(ESLINT) --rule 'prettier/prettier: off' $(ESLINT_FILES)
.PHONY: fmt
fmt: | $(ESLINT)
$(ESLINT) --fix $(ESLINT_FILES)
check-bash: $(NODE_EXEC)
.PHONY: test
test:
@echo "To run tests, run:"
@echo ""
@echo " ./test/runtests"
@echo ""
@echo "from the /opt/smartdc/mako directory on a storage instance."
.PHONY: scripts
scripts: deps/manta-scripts/.git
mkdir -p $(BUILD)/scripts
cp deps/manta-scripts/*.sh $(BUILD)/scripts
.PHONY: check-nginx
check-nginx: $(NGINX_EXEC)
$(NGXSYMCHECK) $(NGINX_EXEC)
prepush: check-nginx
.PHONY: release
release: all deps docs $(SMF_MANIFESTS) check-nginx
@echo "Building $(RELEASE_TARBALL)"
@$(ROOT)/build/node/bin/node ./node_modules/.bin/kthxbai
@mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/mako
@mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/boot
@mkdir -p $(RELSTAGEDIR)/site
@touch $(RELSTAGEDIR)/site/.do-not-delete-me
cp -r $(ROOT)/bin \
$(ROOT)/boot \
$(ROOT)/build/nginx \
$(ROOT)/lib \
$(ROOT)/node_modules \
$(ROOT)/sapi_manifests \
$(ROOT)/smf \
$(ROOT)/test \
$(RELSTAGEDIR)/root/opt/smartdc/mako/
mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/mako/build
cp -r $(ROOT)/build/scripts $(RELSTAGEDIR)/root/opt/smartdc/mako/build/
mkdir -p $(RELSTAGEDIR)/root/opt/smartdc/mako/build/node/bin \
$(RELSTAGEDIR)/root/opt/smartdc/mako/build/node/lib
cp -r $(ROOT)/build/node/lib/dtrace $(RELSTAGEDIR)/root/opt/smartdc/mako/build/node/lib/
cp $(ROOT)/build/node/bin/node $(RELSTAGEDIR)/root/opt/smartdc/mako/build/node/bin/
chmod 755 $(RELSTAGEDIR)/root/opt/smartdc/mako/build/node/bin/node
cp $(ROOT)/mako_rollup/target/release/mako_rollup \
$(RELSTAGEDIR)/root/opt/smartdc/mako/bin/mako_rollup
chmod 755 $(RELSTAGEDIR)/root/opt/smartdc/mako/bin/mako_rollup
cp -r $(ROOT)/build/scripts $(RELSTAGEDIR)/root/opt/smartdc/mako/boot
ln -s /opt/smartdc/mako/boot/setup.sh \
$(RELSTAGEDIR)/root/opt/smartdc/boot/setup.sh
chmod 755 $(RELSTAGEDIR)/root/opt/smartdc/mako/boot/setup.sh
rm $(RELSTAGEDIR)/root/opt/smartdc/mako/nginx/conf/*.default
(cd $(RELSTAGEDIR) && $(TAR) -I pigz -cf $(ROOT)/$(RELEASE_TARBALL) root site)
@rm -rf $(RELSTAGEDIR)
.PHONY: build-rollup
build-rollup: | $(CARGO_EXEC)
(cd mako_rollup && $(CARGO) build --release)
find mako_rollup -ls
.PHONY: publish
publish: release
mkdir -p $(ENGBLD_BITS_DIR)/$(NAME)
cp $(ROOT)/$(RELEASE_TARBALL) $(ENGBLD_BITS_DIR)/$(NAME)/$(RELEASE_TARBALL)
include ./deps/eng/tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.targ
include ./deps/eng/tools/mk/Makefile.agent_prebuilt.targ
endif
include ./deps/eng/tools/mk/Makefile.smf.targ
include ./tools/mk/Makefile.nginx.targ
include ./deps/eng/tools/mk/Makefile.targ
include ./deps/eng/tools/mk/Makefile.rust.targ