-
Notifications
You must be signed in to change notification settings - Fork 18
/
GNUmakefile
196 lines (163 loc) · 5.13 KB
/
GNUmakefile
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
#
# 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) 2018, Joyent, Inc.
#
#
# Makefile for the V8 MDB dmod. This build produces 32-bit and 64-bit binaries
# for mdb_v8 in the "build" directory.
#
# Targets:
#
# all builds the mdb_v8.so shared objects
#
# check run style checker on source files
#
# clean removes all generated files
#
# This Makefile has been designed to work out of the box (without manual or
# automatic configuration) on illumos systems. Other systems do not support
# MDB, so the build will not work there. In principle, you can change most
# of the items under the CONFIGURATION sections, but you should not need to.
#
#
# CONFIGURATION FOR BUILDERS
#
# Directory for output objects
MDBV8_BUILD = build
# Output object name
MDBV8_SONAME = mdb_v8.so
# Tag binaries with "dev" or "release". This should be a valid C string.
MDBV8_VERS_TAG = "dev"
#
# CONFIGURATION FOR DEVELOPERS
#
#
# List of source files that will become objects. (These entries do not include
# the "src/" directory prefix.)
#
MDBV8_SOURCES = \
mdb_v8.c \
mdb_v8_array.c \
mdb_v8_cfg.c \
mdb_v8_dbi.c \
mdb_v8_function.c \
mdb_v8_strbuf.c \
mdb_v8_string.c \
mdb_v8_subr.c \
mdb_v8_whatis.c
MDBV8_GENSOURCES = mdb_v8_version.c
# List of source files to run through cstyle. This includes header files.
MDBV8_CSTYLE_SOURCES = $(wildcard src/*.c src/*.h)
# Compiler flags
CFLAGS += -Werror -Wall -Wextra -fPIC -fno-omit-frame-pointer
# Including DWARF information allows us to debug the dmod using MDB's support
# for runtime conversion of DWARF to CTF.
CFLAGS += -g -O
CPPFLAGS += -DMDBV8_VERS_TAG='$(MDBV8_VERS_TAG)'
# XXX These should be removed.
CFLAGS += -Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-sign-compare
# This is necessary for including avl_impl.h.
CFLAGS += -Wno-unknown-pragmas
# Linker flags (including dependent libraries)
LDFLAGS += -lproc
LDFLAGS.64 += -lproc
SOFLAGS = -Wl,-soname=$(MDBV8_SONAME)
# Path to cstyle.pl tool
CSTYLE = tools/cstyle.pl
CSTYLE_FLAGS += -cCp
# Path to catest tool
CATEST = tools/catest
# JavaScript source files (used in test code)
JS_FILES = $(wildcard test/standalone/*.js) \
$(wildcard tools/mdbv8diff/*.js) \
$(wildcard tools/mdbv8diff/issues/*.js) \
tools/mdbv8diff/mdbv8diff
JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSL_CONF_NODE = tools/jsl.node.conf
#
# INTERNAL DEFINITIONS
#
MDBV8_ARCH = ia32
include Makefile.arch.defs
MDBV8_ARCH = amd64
include Makefile.arch.defs
LIBAVL_SUBMODULE = deps/illumos-libavl
CPPFLAGS += -I$(LIBAVL_SUBMODULE)/include
$(LIBAVL_amd64): CFLAGS_ARCH += -m64
$(MDBV8_TARGETS_amd64): CFLAGS += -m64
$(MDBV8_TARGETS_amd64): SOFLAGS += -m64
$(LIBAVL_ia32): CFLAGS_ARCH += -m32
$(MDBV8_TARGETS_ia32): CFLAGS += -m32
$(MDBV8_TARGETS_ia32): SOFLAGS += -m32
#
# DEFINITIONS USED AS RECIPES
#
MKDIRP = mkdir -p $@
COMPILE.c = $(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $^
MAKESO_ia32 = $(CC) -o $@ -shared $(SOFLAGS) $(LDFLAGS) $^
MAKESO_amd64 = $(CC) -o $@ -shared $(SOFLAGS) $(LDFLAGS.64) $^
GITDESCRIBE = $(shell git describe --all --long --dirty | \
awk -F'-g' '{print $$NF}')
#
# Include eng.git Makefile for managing "node_modules" directory. A number of
# items that are normally provided by Makefile.defs are specified here directly.
#
TOP = $(shell pwd)
NPM = npm
MAKE_STAMPS_DIR = make_stamps
CLEAN_FILES += $(MAKE_STAMPS_DIR)
MAKE_STAMP_REMOVE = mkdir -p $(@D); rm -f $(@)
MAKE_STAMP_CREATE = mkdir -p $(@D); touch $(@)
include ./tools/mk/Makefile.node_modules.defs
#
# TARGETS
#
.PHONY: all
all: $(MDBV8_ALLTARGETS)
check: check-cstyle
.PHONY: check-cstyle
check-cstyle:
$(CSTYLE) $(CSTYLE_FLAGS) $(MDBV8_CSTYLE_SOURCES)
CLEAN_FILES += $(MDBV8_BUILD)
.PHONY: test
test: $(MDBV8_ALLTARGETS) $(STAMP_NODE_MODULES)
$(CATEST) -a
.PHONY: prepush
prepush: check test
.PHONY: release
release: MDBV8_VERS_TAG := "release, from $(GITDESCRIBE)"
release: clean $(MDBV8_ALLTARGETS)
#
# Makefile.arch.targ is parametrized by MDBV8_ARCH. It defines a group of
# the current value of MDBV8_ARCH. When we include it the first time, it
# defines targets for the 32-bit object files and shared object file. The
# second time, it defines targets for the 64-bit object files and shared object
# file. This avoids duplicating Makefile snippets, though admittedly today
# these snippets are short enough that it hardly makes much difference.
#
MDBV8_ARCH=ia32
include Makefile.arch.targ
MDBV8_ARCH=amd64
include Makefile.arch.targ
#
# mdb_v8_version.c is generated based on the "version" file. The version number
# is baked into the binary itself (so the dmod can report its version) and also
# used in the publish target.
#
$(MDBV8_BUILD)/mdb_v8_version.c: version | $(MDBV8_BUILD)
tools/mkversion < $^ > $@
$(MDBV8_BUILD):
$(MKDIRP)
#
# Include common Joyent Makefile for JavaScript "check" targets and
# "node_modules" management targets.
#
include ./Makefile.targ
include ./tools/mk/Makefile.node_modules.targ