forked from TritonDataCenter/eng
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (164 loc) · 6.3 KB
/
Makefile
File metadata and controls
189 lines (164 loc) · 6.3 KB
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 (c) 2014, Joyent, Inc.
#
#
# Makefile: annotated sample Makefile using eng.git Makefile system
#
# The eng.git repository contains a system of Makefile components that provide
# pluggable Makefile functionality (the way is typically done for other
# programming environments, but isn't commonly done for Makefiles). Makefiles
# defined in this repository generate targets for:
#
# * building the current repository as an npm package
# * checking syntax and style for JavaScript, JSON, bash files,
# and SMF manifests
# * generating API documentation from restdown sources
# * generating manual pages from Markdown sources
# * building a copy of Node with this repository
# * loading a prebuilt copy of Node in this repository
# * fetching git submodules as they are needed
#
# This top-level Makefile is both a sample Makefile for new repositories and
# a demo for how to use each of the Makefile components here. If you find this
# comment in a Makefile outside of eng.git, that's a bug and should be fixed.
# Repos are expected to completely rewrite this file (possibly using it as a
# template).
#
# Writing new Makefile components is not hard, but requires thinking through how
# they may need to be customized. Here are some guidelines:
#
# * "Callers" (top-level Makefiles) should be able to use Makefile
# components by setting specific Make variables ("input variables" for the
# component) and then including the Makefile. The component works by
# defining output variables and (optionally) targets. See existing
# components for examples. Document clearly the input and output
# variables for each new Makefile component.
#
# * Most components actually consist of two files: a "defs" file that
# consumes input variables and produces output variables, and a separate
# "targ" file that defines targets. Consumers include the "defs" Makefile
# towards the top of their Makefile, before they've defined their own
# repo-specific targets. If components define targets at this point,
# they'd become default targets, and can also lead to dependency problems.
# Consumers include the "targ" Makefile after all definitions have been
# made.
#
# * Usually, a component should not define phony top-level targets (like
# "check" or "manpages"). Instead, just define variables (like
# MY_COMPONENTS_CHECK_TARGETS or MAN_OUTPUTS) that the caller can use to
# trivially define such a target themselves.
#
# * If you want to be able to use this Makefile more than once (e.g., with
# different parameters), that's possible, but tricky. See
# Makefile.manpages.{defs,targ} for an example.
#
#
# IMPORTANT: This sample Makefile should consist solely of repo-specific
# configuration, plus "include" directives for the common Makefile components,
# plus trivial, repo-specific targets. Repo-specific targets and recipes are
# okay, but generic targets and recipes do NOT belong here. If you find
# yourself wanting to add support for new targets here, you should add them to a
# new or existing pluggable Makefile component, document it clearly, and include
# that Makefile here.
#
#
# Tools
#
TAP := ./node_modules/.bin/tap
#
# Makefile.defs defines variables used as part of the build process.
#
include ./tools/mk/Makefile.defs
#
# Configuration used by Makefile.defs and Makefile.targ to generate
# "check" and "docs" targets.
#
DOC_FILES = index.md boilerplateapi.md
JSON_FILES = package.json
JS_FILES := $(shell find lib test -name '*.js')
JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSL_CONF_NODE = tools/jsl.node.conf
JSSTYLE_FLAGS = -f tools/jsstyle.conf
#
# Configuration used by Makefile.node_deps.defs to generate targets for
# installing Node modules contained within this repo (in this case, the
# "node-dummy" module).
#
REPO_MODULES = src/node-dummy
include ./tools/mk/Makefile.node_deps.defs
#
# Configuration used by Makefile.smf.defs to generate "check" and "all" targets
# for SMF manifest files.
#
SMF_MANIFESTS_IN = smf/manifests/bapi.xml.in
include ./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=v0.8.28
ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_CC_VERSION=4.6.2
NODE_PREBUILT_TAG=zone
include ./tools/mk/Makefile.node_prebuilt.defs
else
include ./tools/mk/Makefile.node.defs
endif
#
# Configuration used by Makefile.manpages.defs to generate manual pages.
# See that Makefile for details. MAN_SECTION must be eagerly defined (with
# ":="), but the Makefile can be used multiple times to build manual pages for
# different sections.
#
MAN_INROOT = docs/man
MAN_OUTROOT = man
CLEAN_FILES += $(MAN_OUTROOT)
MAN_SECTION := 1
include tools/mk/Makefile.manpages.defs
MAN_SECTION := 3bapi
include tools/mk/Makefile.manpages.defs
#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) | $(TAP) $(REPO_DEPS)
$(NPM) rebuild
#
# 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)
$(TAP): | $(NPM_EXEC)
$(NPM) install
CLEAN_FILES += $(TAP) ./node_modules/tap
.PHONY: test
test: $(TAP)
TAP=1 $(TAP) test/*.test.js
#
# Target definitions. This is where we include the target Makefiles for
# the "defs" Makefiles we included above.
#
include ./tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.targ
else
include ./tools/mk/Makefile.node.targ
endif
MAN_SECTION := 1
include tools/mk/Makefile.manpages.targ
MAN_SECTION := 3bapi
include tools/mk/Makefile.manpages.targ
include ./tools/mk/Makefile.smf.targ
include ./tools/mk/Makefile.node_deps.targ
include ./tools/mk/Makefile.targ