Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 # -*- Mode: makefile -*-
2 #
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 ifndef .PYMAKE
8 ifeq (,$(MAKE_VERSION))
9 $(error GNU Make is required)
10 endif
11 make_min_ver := 3.81
12 ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION))))
13 $(error GNU Make $(make_min_ver) or higher is required)
14 endif
15 endif
17 TOPLEVEL_BUILD := 1
19 run_for_side_effects := $(shell echo 'MAKE: $(MAKE)')
20 STATIC_LIBRARY_NAME = js_static
21 LIBS = $(NSPR_LIBS)
23 DIST_INSTALL = 1
25 ifdef JS_STANDALONE
26 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,mfbt,$(DEPTH)/mfbt)
27 endif
29 ifdef JS_HAS_CTYPES
30 ifdef MOZ_NATIVE_FFI
31 LOCAL_INCLUDES = $(MOZ_FFI_CFLAGS)
32 endif
34 ifdef MOZ_NATIVE_FFI
35 EXTRA_DSO_LDOPTS += $(MOZ_FFI_LIBS)
36 else
37 SHARED_LIBRARY_LIBS += \
38 ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \
39 $(NULL)
40 endif
42 endif # JS_HAS_CTYPES
44 DASH_R = -r
46 ifneq (,$(filter WINNT,$(OS_ARCH)))
47 SDK_LIBRARY = $(IMPORT_LIBRARY)
48 else
49 SDK_LIBRARY = $(SHARED_LIBRARY)
50 endif
52 EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
54 # Define keyword generator before rules.mk, see bug 323979 comment 50
56 GARBAGE += jsautokw.h host_jskwgen$(HOST_BIN_SUFFIX)
58 GARBAGE += selfhosted.out.h
60 USE_HOST_CXX = 1
62 ifdef HAVE_DTRACE
63 ifneq ($(OS_ARCH),Darwin)
64 DTRACE_PROBE_OBJ = $(LIBRARY_NAME)-dtrace.$(OBJ_SUFFIX)
65 endif
66 MOZILLA_DTRACE_SRC = $(srcdir)/devtools/javascript-trace.d
67 endif
69 # Ensure symbol versions of shared library on Linux do not conflict
70 # with those in libxul.
71 ifeq (Linux,$(OS_TARGET))
72 EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript
74 symverscript: symverscript.in
75 $(call py_action,preprocessor, \
76 -DVERSION='$(subst -,_,$(LIBRARY_NAME))' $< -o $@)
78 EXTRA_DEPS += symverscript
79 endif
81 export_files = js-config.h
82 ifdef HAVE_DTRACE
83 export_files += $(CURDIR)/javascript-trace.h
84 endif
86 INSTALL_TARGETS += jsconfig
87 jsconfig_FILES = $(export_files)
88 jsconfig_DEST = $(DIST)/include
89 jsconfig_TARGET := export
91 include $(topsrcdir)/config/rules.mk
93 #############################################
94 # BEGIN ECMAScript Internationalization API
95 #
97 # ICU headers need to be available whether we build with the complete
98 # Internationalization API or not - ICU stubs rely on them.
100 LOCAL_INCLUDES += $(MOZ_ICU_CFLAGS)
102 ifdef ENABLE_INTL_API
103 ifndef MOZ_NATIVE_ICU
105 endif
106 endif
108 #
109 # END ECMAScript Internationalization API
110 #############################################
113 # check_vanilla_allocations.py is tailored to Linux, so only run it there.
114 # That should be enough to catch any problems.
115 check-vanilla-allocations:
116 $(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py $(REAL_LIBRARY)
118 # The "aggressive" variant will likely fail on some compiler/platform
119 # combinations, but is worth running by hand every once in a while.
120 check-vanilla-allocations-aggressive:
121 $(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py --aggressive $(REAL_LIBRARY)
123 ifeq ($(OS_ARCH),Linux)
124 check:: check-vanilla-allocations
125 endif
127 # Help ensure that the number of OOM errors in SpiderMonkey doesn't increase.
128 # If the number of OOM errors changes, update the number below. We intend this
129 # number to go down over time, by fixing OOMs.
130 check-ooms:
131 $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(topsrcdir)/config/find_OOM_errors.py --regression 125
133 ifeq ($(MOZ_DEBUG),1)
134 #check:: check-ooms
135 endif
137 ifdef MOZ_VALGRIND
138 ifndef MOZ_ASAN
139 JITTEST_VALGRIND_FLAG = --valgrind
140 endif
141 endif
143 ifdef MOZ_ASAN
144 ifneq ($(LLVM_SYMBOLIZER),)
145 # Use the LLVM symbolizer when running jit-tests under ASan, if available
146 JITTEST_ASAN_ENV=ASAN_SYMBOLIZER_PATH='$(LLVM_SYMBOLIZER)'
147 endif
148 endif
150 check-style::
151 (cd $(srcdir) && $(PYTHON) $(topsrcdir)/config/check_spidermonkey_style.py);
153 check-jit-test::
154 $(JITTEST_ASAN_ENV) $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/jit-test/jit_test.py \
155 --no-slow --no-progress --tinderbox --tbpl $(JITTEST_VALGRIND_FLAG) \
156 $(DIST)/bin/$(JS_SHELL_NAME)$(BIN_SUFFIX)
158 check:: check-style
160 # jstests doesn't have a --jitflags option, so we need to loop, updating the
161 # exit code (RC) after each invocation.
162 # FIXME: MethodJIT doesn't work for 1 test case (bug 644393), so
163 # --no-extensions is set to skip that test. Remove as soon as possible.
164 check-jstests:
165 RC=0; \
166 for f in `echo '$(JITFLAGS)' | tr ',' '\n'`; \
167 do \
168 $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/tests/jstests.py \
169 --tinderbox --no-progress \
170 --no-extensions \
171 --timeout 300 \
172 --args="`echo $$f | sed 's/\(.\)/ -\1/g'`" \
173 $(DIST)/bin/$(JS_SHELL_NAME)$(BIN_SUFFIX); \
174 RC=$$(( $$RC || $$?)); \
175 done; \
176 exit $$RC
178 # FIXME:
179 # We want to run check-jstests as part of |make check| on all platforms, on
180 # tinderbox. However, some configurations don't work quite right just yet.
181 # Rather than risking regressions in major configurations while fixing these
182 # secondary configuration, we work around them and fix the bugs later.
183 #
184 # Bug 652154: On Windows, SM(!m !t) don't work because of path problems with
185 # their unusual directory layout
186 #
187 # Bug 652155: On Mac, SM(d) doesn't work for unknown reasons
189 ifneq ($(OS_ARCH),WINNT)
190 ifndef HAVE_DTRACE
191 #check:: check-jstests
192 endif
193 endif
195 DIST_GARBAGE = config.cache config.log config.status* \
196 config/autoconf.mk config/emptyvars.mk \
197 js-config.h js-confdefs.h \
198 backend.mk config/backend.mk devtools/backend.mk editline/backend.mk \
199 gdb/backend.mk jsapi-tests/backend.mk shell/backend.mk tests/backend.mk \
200 backend.RecursiveMakeBackend backend.RecursiveMakeBackend.pp \
201 devtools/rootAnalysis/Makefile
203 distclean::
204 $(RM) $(DIST_GARBAGE)
206 ifneq ($(findstring -L,$(NSPR_LIBS)),)
207 NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
208 else
209 NSPR_STATIC_PATH = $(DIST)/lib
210 endif
212 # HP-UX does not require the extra linking of "-lm"
213 ifeq (,$(filter HP-UX WINNT,$(OS_ARCH)))
214 EXTRA_LIBS += -lm
215 endif
217 CFLAGS += $(MOZ_ZLIB_CFLAGS)
218 EXTRA_LIBS += $(MOZ_ZLIB_LIBS)
219 # Enable zlib usage if zlib has been located. When building the browser on
220 # Windows, MOZ_ZLIB_LIBS is empty because zlib is part of libmozglue. We thus
221 # also enable zlib if mozglue is present.
222 ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS))
223 DEFINES += -DUSE_ZLIB
224 endif
226 ifdef MOZ_SHARED_ICU
227 EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
228 else
229 SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS)
230 endif
232 # Prevent floating point errors caused by VC++ optimizations
233 ifdef _MSC_VER
234 # XXX We should add this to CXXFLAGS, too?
235 CFLAGS += -fp:precise
236 endif # _MSC_VER
238 ifeq ($(OS_ARCH),FreeBSD)
239 EXTRA_LIBS += -pthread
240 endif
241 ifeq ($(OS_ARCH),Linux)
242 EXTRA_LIBS += -ldl
243 endif
244 # Silence warnings on AIX/HP-UX from non-GNU compilers
245 ifndef GNU_CC
246 ifeq ($(OS_ARCH),AIX)
247 # Suppress warnings from xlC
248 # 1540-1281: offsetof() on null non-POD types
249 # 1540-1608: anonymous unions using static data members
250 CFLAGS += -qsuppress=1540-1281 -qsuppress=1540-1608
251 CXXFLAGS += -qsuppress=1540-1281 -qsuppress=1540-1608
252 endif
253 ifeq ($(OS_ARCH),HP-UX)
254 # Suppress warnings from aCC
255 # 3055: anonymous unions declaring types
256 # 4189: offsetof() on non-POD types
257 CFLAGS += +W3055,4189
258 CXXFLAGS += +W3055,4189
259 endif
260 endif
261 ifeq ($(OS_ARCH),SunOS)
262 ifeq ($(TARGET_CPU),sparc)
264 ifdef GNU_CC
265 CFLAGS += -mcpu=v9
266 CXXFLAGS += -mcpu=v9
267 endif # GNU_CC
269 endif
270 EXTRA_LIBS += -lposix4 -ldl -lnsl -lsocket
271 endif
273 SCRIPTS = $(JS_CONFIG_NAME)
274 SDK_BINARY = $(JS_CONFIG_NAME)
276 $(LIBRARY_NAME).pc: js.pc
277 cp $^ $@
279 install:: $(LIBRARY_NAME).pc
280 $(SYSINSTALL) $^ $(DESTDIR)$(libdir)/pkgconfig
282 ######################################################
283 # BEGIN SpiderMonkey header installation
284 #
285 # Mozilla/Gecko/Firefox mostly doesn't concern itself with defining a sensible
286 # install target, because it's shipping primarily packaged builds. And even if
287 # it did, those builds wouldn't really have reason to include header files. So
288 # we have to install public headers ourselves, rather than using something from
289 # config/rules.mk or similar.
290 #
291 # The overall directory structure of the installed headers looks like so:
292 #
293 # $(includedir)/
294 # $(LIBRARY_NAME)/
295 # jsapi.h, jspubtd.h, etc. (all of EXPORTS)
296 # js/
297 # js/public/* headers (all are public)
298 # ds/
299 # js/src/ds/* public headers
300 # gc/
301 # js/src/gc/* public headers
302 # mozilla/
303 # mfbt headers
304 #
306 install::
307 $(call py_action,process_install_manifest,--no-remove $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include)
309 #
310 # END SpiderMonkey header installation
311 #############################################
313 install:: $(SCRIPTS)
314 $(SYSINSTALL) $^ $(DESTDIR)$(bindir)
316 install:: $(REAL_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
317 ifneq (,$(REAL_LIBRARY))
318 $(SYSINSTALL) $(REAL_LIBRARY) $(DESTDIR)$(libdir)
319 mv -f $(DESTDIR)$(libdir)/$(REAL_LIBRARY) $(subst $(STATIC_LIBRARY_NAME),$(LIBRARY_NAME),$(DESTDIR)$(libdir)/$(REAL_LIBRARY))
320 endif
321 ifneq (,$(SHARED_LIBRARY))
322 $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir)
323 endif
324 ifneq (,$(IMPORT_LIBRARY))
325 $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir)
326 endif
327 $(MAKE) -C shell install
329 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
330 # previous build?) via VPATH when we're building in a separate tree.
331 $(CURDIR)/jsautokw.h: host_jskwgen$(HOST_BIN_SUFFIX)
332 ./host_jskwgen$(HOST_BIN_SUFFIX) $@
334 # Force auto-header generation before compiling any source that may use them
335 $(OBJS): $(CURDIR)/jsautokw.h
337 ifdef MOZ_ETW
338 ETWProvider.h ETWProvider.rc ETWProvider.mof: ETWProvider.man
339 $(MC) -um -mof $^
341 ETWProvider.res: ETWProvider.rc
342 $(RC) -r -i '$(SDKDIR)Include' $^
344 export:: ETWProvider.res
346 install:: ETWProvider.mof ETWProvider.man
347 $(SYSINSTALL) $^ $(DESTDIR)$(bindir)
349 endif
351 ifdef HAVE_DTRACE
352 $(CURDIR)/javascript-trace.h: $(srcdir)/devtools/javascript-trace.d
353 dtrace -h -s $(srcdir)/devtools/javascript-trace.d -o javascript-trace.h.in
354 sed -e 's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
355 -e '/const/!s/char \*/const char */g' \
356 javascript-trace.h.in > javascript-trace.h
358 # We can't automatically generate dependencies on auto-generated headers;
359 # we have to list them explicitly.
360 $(addsuffix .$(OBJ_SUFFIX),Probes jsinterp jsobj): $(CURDIR)/javascript-trace.h
361 endif
363 # Prepare self-hosted JS code for embedding
364 export:: selfhosting
365 selfhosting:: selfhosted.out.h
367 selfhosting_srcs := \
368 $(srcdir)/builtin/Utilities.js \
369 $(srcdir)/builtin/ParallelUtilities.js \
370 $(srcdir)/builtin/Array.js \
371 $(srcdir)/builtin/Date.js \
372 $(srcdir)/builtin/Intl.js \
373 $(srcdir)/builtin/IntlData.js \
374 $(srcdir)/builtin/Iterator.js \
375 $(srcdir)/builtin/Map.js \
376 $(srcdir)/builtin/Number.js \
377 $(srcdir)/builtin/String.js \
378 $(srcdir)/builtin/Set.js \
379 $(srcdir)/builtin/TypedObject.js \
380 $(NULL)
382 selfhosted_out_h_deps := \
383 $(selfhosting_srcs) \
384 $(srcdir)/js.msg \
385 $(srcdir)/builtin/embedjs.py \
386 $(srcdir)/builtin/TypedObjectConstants.h \
387 $(NULL)
389 SELFHOSTED_DEFINES += $(DEFINES) $(ACDEFINES)
390 ifdef MOZ_DEBUG
391 SELFHOSTED_DEFINES += $(MOZ_DEBUG_ENABLE_DEFS)
392 else
393 SELFHOSTED_DEFINES += $(MOZ_DEBUG_DISABLE_DEFS)
394 endif
396 selfhosted.out.h: $(selfhosted_out_h_deps)
397 $(PYTHON) $(srcdir)/builtin/embedjs.py $(SELFHOSTED_DEFINES) \
398 -p '$(CPP)' -m $(srcdir)/js.msg -o $@ $(selfhosting_srcs)
400 ###############################################
401 # Generating source package tarballs
402 # (only possible when tar is found)
403 ifneq (,$(TAR))
405 source-package:
406 SRCDIR=$(srcdir) \
407 DIST=$(DIST) \
408 MAKE=$(MAKE) \
409 MKDIR=$(MKDIR) \
410 TAR=$(TAR) \
411 MOZJS_MAJOR_VERSION=$(MOZJS_MAJOR_VERSION) \
412 MOZJS_MINOR_VERSION=$(MOZJS_MINOR_VERSION) \
413 MOZJS_PATCH_VERSION=$(MOZJS_PATCH_VERSION) \
414 MOZJS_ALPHA=$(MOZJS_ALPHA) \
415 $(srcdir)/make-source-package.sh
417 clean::
418 DIST=$(DIST) \
419 MOZJS_MAJOR_VERSION=$(MOZJS_MAJOR_VERSION) \
420 MOZJS_MINOR_VERSION=$(MOZJS_MINOR_VERSION) \
421 MOZJS_PATCH_VERSION=$(MOZJS_PATCH_VERSION) \
422 MOZJS_ALPHA=$(MOZJS_ALPHA) \
423 $(srcdir)/make-source-package.sh clean
425 endif