-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
162 lines (137 loc) · 4.39 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
#
# 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 (c) 2019, Joyent, Inc.
# Copyright 2023 MNX Cloud, Inc.
#
NAME = waferlock
#
# Tools
#
TAPE := ./node_modules/.bin/tape
#
# Makefile.defs defines variables used as part of the build process.
#
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.)
SAPI_MANIFESTS_IN = sapi_manifests/$(NAME)/manifest.json.in
SAPI_MANIFESTS += $(SAPI_MANIFESTS_IN:%.in=%)
CLEAN_FILES += $(SAPI_MANIFESTS_IN:%.in=%)
#
# Configuration used by Makefile.defs and Makefile.targ to generate
# "check" and "docs" targets.
#
#DOC_FILES = index.md boilerplateapi.md
JSON_FILES = package.json $(SAPI_MANIFESTS)
JS_FILES := $(shell find lib -name '*.js') server.js
ESLINT_FILES = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -f tools/jsstyle.conf
PREFIX ?= /opt/smartdc/$(NAME)
#
# Configuration used by Makefile.smf.defs to generate "check" and "all" targets
# for SMF manifest files.
#
SMF_MANIFESTS = smf/manifests/$(NAME).xml
include ./deps/eng/tools/mk/Makefile.smf.defs
#
# Historically, Node packages that make use of binary add-ons must ship their
# own Node built with the same compiler, compiler options, and Node version that
# the add-on was built with. On SmartOS systems, we use prebuilt Node images
# via Makefile.node_prebuilt.defs. On other systems, we build our own Node
# binary as part of the build process. Other options are possible -- it depends
# on the need of your repository.
#
NODE_PREBUILT_VERSION = v6.17.0
NODE_PREBUILT_IMAGE = 18b094b0-eb01-11e5-80c1-175dac7ddf02
ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_TAG = gz
include ./deps/eng/tools/mk/Makefile.node_prebuilt.defs
else
NODE := $(shell which node)
NPM := $(shell which npm)
NPM_EXEC=$(NPM)
endif
#
# Makefile.node_modules.defs provides a common target for installing modules
# with NPM from a dependency specification in a "package.json" file. By
# including this Makefile, we can depend on $(STAMP_NODE_MODULES) to drive "npm
# install" correctly.
#
include ./deps/eng/tools/mk/Makefile.node_modules.defs
#
# MG Variables
#
RELEASE_TARBALL := $(NAME)-pkg-$(STAMP).tar.gz
ROOT := $(shell pwd)
RELSTAGEDIR := /tmp/$(NAME)-$(STAMP)
#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) $(STAMP_NODE_MODULES) $(SAPI_MANIFESTS) | $(REPO_DEPS)
#
# This example Makefile defines a special target for building manual pages. You
# may want to make these dependencies part of "all" instead.
#
.PHONY: manpages
manpages: $(MAN_OUTPUTS)
.PHONY: test
test: $(STAMP_NODE_MODULES)
$(NODE) $(TAPE) test/*.test.js
#
# MG targets
#
.PHONY: release
release: all
@echo "Building $(RELEASE_TARBALL)"
mkdir -p $(RELSTAGEDIR)/root/$(PREFIX)
mkdir -p $(RELSTAGEDIR)/site
touch $(RELSTAGEDIR)/site/.do-not-delete-me
mkdir -p $(RELSTAGEDIR)/root
mkdir -p $(RELSTAGEDIR)/root/$(PREFIX)/etc
cp $(ROOT)/etc/pg_hba.conf \
$(RELSTAGEDIR)/root/$(PREFIX)/etc
cp -r $(ROOT)/lib \
$(ROOT)/server.js \
$(ROOT)/node_modules \
$(ROOT)/package.json \
$(ROOT)/smf \
$(ROOT)/sapi_manifests \
$(RELSTAGEDIR)/root/$(PREFIX)
mkdir -p $(RELSTAGEDIR)/root/$(PREFIX)/build
cp -r \
$(ROOT)/build/node \
$(RELSTAGEDIR)/root/$(PREFIX)/build
(cd $(RELSTAGEDIR) && $(TAR) -I pigz -cf $(ROOT)/$(RELEASE_TARBALL) root site)
rm -rf $(RELSTAGEDIR)
.PHONY: publish
publish: release
@if [[ -z "$(ENGBLD_BITS_DIR)" ]]; then \
echo "error: 'ENGBLD_BITS_DIR' must be set for 'publish' target"; \
exit 1; \
fi
mkdir -p $(ENGBLD_BITS_DIR)/$(NAME)
cp $(ROOT)/$(RELEASE_TARBALL) $(ENGBLD_BITS_DIR)/$(NAME)/$(RELEASE_TARBALL)
#
# Target definitions. This is where we include the target Makefiles for
# the "defs" Makefiles we included above.
#
include ./deps/eng/tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./deps/eng/tools/mk/Makefile.node_prebuilt.targ
else
include ./deps/eng/tools/mk/Makefile.node.targ
endif
include ./deps/eng/tools/mk/Makefile.smf.targ
include ./deps/eng/tools/mk/Makefile.node_modules.targ
include ./deps/eng/tools/mk/Makefile.targ
$(SAPI_MANIFESTS): %: %.in
$(SED) \
-e 's#@@NODE@@#@@PREFIX@@/$(NODE_INSTALL)/bin/node#g' \
-e 's#@@PREFIX@@#$(PREFIX)#g' \
$< > $@