michael@0: # -*- Mode: makefile -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ifndef .PYMAKE michael@0: ifeq (,$(MAKE_VERSION)) michael@0: $(error GNU Make is required) michael@0: endif michael@0: make_min_ver := 3.81 michael@0: ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION)))) michael@0: $(error GNU Make $(make_min_ver) or higher is required) michael@0: endif michael@0: endif michael@0: michael@0: TOPLEVEL_BUILD := 1 michael@0: michael@0: run_for_side_effects := $(shell echo 'MAKE: $(MAKE)') michael@0: STATIC_LIBRARY_NAME = js_static michael@0: LIBS = $(NSPR_LIBS) michael@0: michael@0: DIST_INSTALL = 1 michael@0: michael@0: ifdef JS_STANDALONE michael@0: SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,mfbt,$(DEPTH)/mfbt) michael@0: endif michael@0: michael@0: ifdef JS_HAS_CTYPES michael@0: ifdef MOZ_NATIVE_FFI michael@0: LOCAL_INCLUDES = $(MOZ_FFI_CFLAGS) michael@0: endif michael@0: michael@0: ifdef MOZ_NATIVE_FFI michael@0: EXTRA_DSO_LDOPTS += $(MOZ_FFI_LIBS) michael@0: else michael@0: SHARED_LIBRARY_LIBS += \ michael@0: ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \ michael@0: $(NULL) michael@0: endif michael@0: michael@0: endif # JS_HAS_CTYPES michael@0: michael@0: DASH_R = -r michael@0: michael@0: ifneq (,$(filter WINNT,$(OS_ARCH))) michael@0: SDK_LIBRARY = $(IMPORT_LIBRARY) michael@0: else michael@0: SDK_LIBRARY = $(SHARED_LIBRARY) michael@0: endif michael@0: michael@0: EXTRA_DSO_LDOPTS += $(NSPR_LIBS) michael@0: michael@0: # Define keyword generator before rules.mk, see bug 323979 comment 50 michael@0: michael@0: GARBAGE += jsautokw.h host_jskwgen$(HOST_BIN_SUFFIX) michael@0: michael@0: GARBAGE += selfhosted.out.h michael@0: michael@0: USE_HOST_CXX = 1 michael@0: michael@0: ifdef HAVE_DTRACE michael@0: ifneq ($(OS_ARCH),Darwin) michael@0: DTRACE_PROBE_OBJ = $(LIBRARY_NAME)-dtrace.$(OBJ_SUFFIX) michael@0: endif michael@0: MOZILLA_DTRACE_SRC = $(srcdir)/devtools/javascript-trace.d michael@0: endif michael@0: michael@0: # Ensure symbol versions of shared library on Linux do not conflict michael@0: # with those in libxul. michael@0: ifeq (Linux,$(OS_TARGET)) michael@0: EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript michael@0: michael@0: symverscript: symverscript.in michael@0: $(call py_action,preprocessor, \ michael@0: -DVERSION='$(subst -,_,$(LIBRARY_NAME))' $< -o $@) michael@0: michael@0: EXTRA_DEPS += symverscript michael@0: endif michael@0: michael@0: export_files = js-config.h michael@0: ifdef HAVE_DTRACE michael@0: export_files += $(CURDIR)/javascript-trace.h michael@0: endif michael@0: michael@0: INSTALL_TARGETS += jsconfig michael@0: jsconfig_FILES = $(export_files) michael@0: jsconfig_DEST = $(DIST)/include michael@0: jsconfig_TARGET := export michael@0: michael@0: include $(topsrcdir)/config/rules.mk michael@0: michael@0: ############################################# michael@0: # BEGIN ECMAScript Internationalization API michael@0: # michael@0: michael@0: # ICU headers need to be available whether we build with the complete michael@0: # Internationalization API or not - ICU stubs rely on them. michael@0: michael@0: LOCAL_INCLUDES += $(MOZ_ICU_CFLAGS) michael@0: michael@0: ifdef ENABLE_INTL_API michael@0: ifndef MOZ_NATIVE_ICU michael@0: michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # END ECMAScript Internationalization API michael@0: ############################################# michael@0: michael@0: michael@0: # check_vanilla_allocations.py is tailored to Linux, so only run it there. michael@0: # That should be enough to catch any problems. michael@0: check-vanilla-allocations: michael@0: $(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py $(REAL_LIBRARY) michael@0: michael@0: # The "aggressive" variant will likely fail on some compiler/platform michael@0: # combinations, but is worth running by hand every once in a while. michael@0: check-vanilla-allocations-aggressive: michael@0: $(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py --aggressive $(REAL_LIBRARY) michael@0: michael@0: ifeq ($(OS_ARCH),Linux) michael@0: check:: check-vanilla-allocations michael@0: endif michael@0: michael@0: # Help ensure that the number of OOM errors in SpiderMonkey doesn't increase. michael@0: # If the number of OOM errors changes, update the number below. We intend this michael@0: # number to go down over time, by fixing OOMs. michael@0: check-ooms: michael@0: $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(topsrcdir)/config/find_OOM_errors.py --regression 125 michael@0: michael@0: ifeq ($(MOZ_DEBUG),1) michael@0: #check:: check-ooms michael@0: endif michael@0: michael@0: ifdef MOZ_VALGRIND michael@0: ifndef MOZ_ASAN michael@0: JITTEST_VALGRIND_FLAG = --valgrind michael@0: endif michael@0: endif michael@0: michael@0: ifdef MOZ_ASAN michael@0: ifneq ($(LLVM_SYMBOLIZER),) michael@0: # Use the LLVM symbolizer when running jit-tests under ASan, if available michael@0: JITTEST_ASAN_ENV=ASAN_SYMBOLIZER_PATH='$(LLVM_SYMBOLIZER)' michael@0: endif michael@0: endif michael@0: michael@0: check-style:: michael@0: (cd $(srcdir) && $(PYTHON) $(topsrcdir)/config/check_spidermonkey_style.py); michael@0: michael@0: check-jit-test:: michael@0: $(JITTEST_ASAN_ENV) $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/jit-test/jit_test.py \ michael@0: --no-slow --no-progress --tinderbox --tbpl $(JITTEST_VALGRIND_FLAG) \ michael@0: $(DIST)/bin/$(JS_SHELL_NAME)$(BIN_SUFFIX) michael@0: michael@0: check:: check-style michael@0: michael@0: # jstests doesn't have a --jitflags option, so we need to loop, updating the michael@0: # exit code (RC) after each invocation. michael@0: # FIXME: MethodJIT doesn't work for 1 test case (bug 644393), so michael@0: # --no-extensions is set to skip that test. Remove as soon as possible. michael@0: check-jstests: michael@0: RC=0; \ michael@0: for f in `echo '$(JITFLAGS)' | tr ',' '\n'`; \ michael@0: do \ michael@0: $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/tests/jstests.py \ michael@0: --tinderbox --no-progress \ michael@0: --no-extensions \ michael@0: --timeout 300 \ michael@0: --args="`echo $$f | sed 's/\(.\)/ -\1/g'`" \ michael@0: $(DIST)/bin/$(JS_SHELL_NAME)$(BIN_SUFFIX); \ michael@0: RC=$$(( $$RC || $$?)); \ michael@0: done; \ michael@0: exit $$RC michael@0: michael@0: # FIXME: michael@0: # We want to run check-jstests as part of |make check| on all platforms, on michael@0: # tinderbox. However, some configurations don't work quite right just yet. michael@0: # Rather than risking regressions in major configurations while fixing these michael@0: # secondary configuration, we work around them and fix the bugs later. michael@0: # michael@0: # Bug 652154: On Windows, SM(!m !t) don't work because of path problems with michael@0: # their unusual directory layout michael@0: # michael@0: # Bug 652155: On Mac, SM(d) doesn't work for unknown reasons michael@0: michael@0: ifneq ($(OS_ARCH),WINNT) michael@0: ifndef HAVE_DTRACE michael@0: #check:: check-jstests michael@0: endif michael@0: endif michael@0: michael@0: DIST_GARBAGE = config.cache config.log config.status* \ michael@0: config/autoconf.mk config/emptyvars.mk \ michael@0: js-config.h js-confdefs.h \ michael@0: backend.mk config/backend.mk devtools/backend.mk editline/backend.mk \ michael@0: gdb/backend.mk jsapi-tests/backend.mk shell/backend.mk tests/backend.mk \ michael@0: backend.RecursiveMakeBackend backend.RecursiveMakeBackend.pp \ michael@0: devtools/rootAnalysis/Makefile michael@0: michael@0: distclean:: michael@0: $(RM) $(DIST_GARBAGE) michael@0: michael@0: ifneq ($(findstring -L,$(NSPR_LIBS)),) michael@0: NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS))) michael@0: else michael@0: NSPR_STATIC_PATH = $(DIST)/lib michael@0: endif michael@0: michael@0: # HP-UX does not require the extra linking of "-lm" michael@0: ifeq (,$(filter HP-UX WINNT,$(OS_ARCH))) michael@0: EXTRA_LIBS += -lm michael@0: endif michael@0: michael@0: CFLAGS += $(MOZ_ZLIB_CFLAGS) michael@0: EXTRA_LIBS += $(MOZ_ZLIB_LIBS) michael@0: # Enable zlib usage if zlib has been located. When building the browser on michael@0: # Windows, MOZ_ZLIB_LIBS is empty because zlib is part of libmozglue. We thus michael@0: # also enable zlib if mozglue is present. michael@0: ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS)) michael@0: DEFINES += -DUSE_ZLIB michael@0: endif michael@0: michael@0: ifdef MOZ_SHARED_ICU michael@0: EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS) michael@0: else michael@0: SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS) michael@0: endif michael@0: michael@0: # Prevent floating point errors caused by VC++ optimizations michael@0: ifdef _MSC_VER michael@0: # XXX We should add this to CXXFLAGS, too? michael@0: CFLAGS += -fp:precise michael@0: endif # _MSC_VER michael@0: michael@0: ifeq ($(OS_ARCH),FreeBSD) michael@0: EXTRA_LIBS += -pthread michael@0: endif michael@0: ifeq ($(OS_ARCH),Linux) michael@0: EXTRA_LIBS += -ldl michael@0: endif michael@0: # Silence warnings on AIX/HP-UX from non-GNU compilers michael@0: ifndef GNU_CC michael@0: ifeq ($(OS_ARCH),AIX) michael@0: # Suppress warnings from xlC michael@0: # 1540-1281: offsetof() on null non-POD types michael@0: # 1540-1608: anonymous unions using static data members michael@0: CFLAGS += -qsuppress=1540-1281 -qsuppress=1540-1608 michael@0: CXXFLAGS += -qsuppress=1540-1281 -qsuppress=1540-1608 michael@0: endif michael@0: ifeq ($(OS_ARCH),HP-UX) michael@0: # Suppress warnings from aCC michael@0: # 3055: anonymous unions declaring types michael@0: # 4189: offsetof() on non-POD types michael@0: CFLAGS += +W3055,4189 michael@0: CXXFLAGS += +W3055,4189 michael@0: endif michael@0: endif michael@0: ifeq ($(OS_ARCH),SunOS) michael@0: ifeq ($(TARGET_CPU),sparc) michael@0: michael@0: ifdef GNU_CC michael@0: CFLAGS += -mcpu=v9 michael@0: CXXFLAGS += -mcpu=v9 michael@0: endif # GNU_CC michael@0: michael@0: endif michael@0: EXTRA_LIBS += -lposix4 -ldl -lnsl -lsocket michael@0: endif michael@0: michael@0: SCRIPTS = $(JS_CONFIG_NAME) michael@0: SDK_BINARY = $(JS_CONFIG_NAME) michael@0: michael@0: $(LIBRARY_NAME).pc: js.pc michael@0: cp $^ $@ michael@0: michael@0: install:: $(LIBRARY_NAME).pc michael@0: $(SYSINSTALL) $^ $(DESTDIR)$(libdir)/pkgconfig michael@0: michael@0: ###################################################### michael@0: # BEGIN SpiderMonkey header installation michael@0: # michael@0: # Mozilla/Gecko/Firefox mostly doesn't concern itself with defining a sensible michael@0: # install target, because it's shipping primarily packaged builds. And even if michael@0: # it did, those builds wouldn't really have reason to include header files. So michael@0: # we have to install public headers ourselves, rather than using something from michael@0: # config/rules.mk or similar. michael@0: # michael@0: # The overall directory structure of the installed headers looks like so: michael@0: # michael@0: # $(includedir)/ michael@0: # $(LIBRARY_NAME)/ michael@0: # jsapi.h, jspubtd.h, etc. (all of EXPORTS) michael@0: # js/ michael@0: # js/public/* headers (all are public) michael@0: # ds/ michael@0: # js/src/ds/* public headers michael@0: # gc/ michael@0: # js/src/gc/* public headers michael@0: # mozilla/ michael@0: # mfbt headers michael@0: # michael@0: michael@0: install:: michael@0: $(call py_action,process_install_manifest,--no-remove $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include) michael@0: michael@0: # michael@0: # END SpiderMonkey header installation michael@0: ############################################# michael@0: michael@0: install:: $(SCRIPTS) michael@0: $(SYSINSTALL) $^ $(DESTDIR)$(bindir) michael@0: michael@0: install:: $(REAL_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) michael@0: ifneq (,$(REAL_LIBRARY)) michael@0: $(SYSINSTALL) $(REAL_LIBRARY) $(DESTDIR)$(libdir) michael@0: mv -f $(DESTDIR)$(libdir)/$(REAL_LIBRARY) $(subst $(STATIC_LIBRARY_NAME),$(LIBRARY_NAME),$(DESTDIR)$(libdir)/$(REAL_LIBRARY)) michael@0: endif michael@0: ifneq (,$(SHARED_LIBRARY)) michael@0: $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir) michael@0: endif michael@0: ifneq (,$(IMPORT_LIBRARY)) michael@0: $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir) michael@0: endif michael@0: $(MAKE) -C shell install michael@0: michael@0: # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a michael@0: # previous build?) via VPATH when we're building in a separate tree. michael@0: $(CURDIR)/jsautokw.h: host_jskwgen$(HOST_BIN_SUFFIX) michael@0: ./host_jskwgen$(HOST_BIN_SUFFIX) $@ michael@0: michael@0: # Force auto-header generation before compiling any source that may use them michael@0: $(OBJS): $(CURDIR)/jsautokw.h michael@0: michael@0: ifdef MOZ_ETW michael@0: ETWProvider.h ETWProvider.rc ETWProvider.mof: ETWProvider.man michael@0: $(MC) -um -mof $^ michael@0: michael@0: ETWProvider.res: ETWProvider.rc michael@0: $(RC) -r -i '$(SDKDIR)Include' $^ michael@0: michael@0: export:: ETWProvider.res michael@0: michael@0: install:: ETWProvider.mof ETWProvider.man michael@0: $(SYSINSTALL) $^ $(DESTDIR)$(bindir) michael@0: michael@0: endif michael@0: michael@0: ifdef HAVE_DTRACE michael@0: $(CURDIR)/javascript-trace.h: $(srcdir)/devtools/javascript-trace.d michael@0: dtrace -h -s $(srcdir)/devtools/javascript-trace.d -o javascript-trace.h.in michael@0: sed -e 's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \ michael@0: -e '/const/!s/char \*/const char */g' \ michael@0: javascript-trace.h.in > javascript-trace.h michael@0: michael@0: # We can't automatically generate dependencies on auto-generated headers; michael@0: # we have to list them explicitly. michael@0: $(addsuffix .$(OBJ_SUFFIX),Probes jsinterp jsobj): $(CURDIR)/javascript-trace.h michael@0: endif michael@0: michael@0: # Prepare self-hosted JS code for embedding michael@0: export:: selfhosting michael@0: selfhosting:: selfhosted.out.h michael@0: michael@0: selfhosting_srcs := \ michael@0: $(srcdir)/builtin/Utilities.js \ michael@0: $(srcdir)/builtin/ParallelUtilities.js \ michael@0: $(srcdir)/builtin/Array.js \ michael@0: $(srcdir)/builtin/Date.js \ michael@0: $(srcdir)/builtin/Intl.js \ michael@0: $(srcdir)/builtin/IntlData.js \ michael@0: $(srcdir)/builtin/Iterator.js \ michael@0: $(srcdir)/builtin/Map.js \ michael@0: $(srcdir)/builtin/Number.js \ michael@0: $(srcdir)/builtin/String.js \ michael@0: $(srcdir)/builtin/Set.js \ michael@0: $(srcdir)/builtin/TypedObject.js \ michael@0: $(NULL) michael@0: michael@0: selfhosted_out_h_deps := \ michael@0: $(selfhosting_srcs) \ michael@0: $(srcdir)/js.msg \ michael@0: $(srcdir)/builtin/embedjs.py \ michael@0: $(srcdir)/builtin/TypedObjectConstants.h \ michael@0: $(NULL) michael@0: michael@0: SELFHOSTED_DEFINES += $(DEFINES) $(ACDEFINES) michael@0: ifdef MOZ_DEBUG michael@0: SELFHOSTED_DEFINES += $(MOZ_DEBUG_ENABLE_DEFS) michael@0: else michael@0: SELFHOSTED_DEFINES += $(MOZ_DEBUG_DISABLE_DEFS) michael@0: endif michael@0: michael@0: selfhosted.out.h: $(selfhosted_out_h_deps) michael@0: $(PYTHON) $(srcdir)/builtin/embedjs.py $(SELFHOSTED_DEFINES) \ michael@0: -p '$(CPP)' -m $(srcdir)/js.msg -o $@ $(selfhosting_srcs) michael@0: michael@0: ############################################### michael@0: # Generating source package tarballs michael@0: # (only possible when tar is found) michael@0: ifneq (,$(TAR)) michael@0: michael@0: source-package: michael@0: SRCDIR=$(srcdir) \ michael@0: DIST=$(DIST) \ michael@0: MAKE=$(MAKE) \ michael@0: MKDIR=$(MKDIR) \ michael@0: TAR=$(TAR) \ michael@0: MOZJS_MAJOR_VERSION=$(MOZJS_MAJOR_VERSION) \ michael@0: MOZJS_MINOR_VERSION=$(MOZJS_MINOR_VERSION) \ michael@0: MOZJS_PATCH_VERSION=$(MOZJS_PATCH_VERSION) \ michael@0: MOZJS_ALPHA=$(MOZJS_ALPHA) \ michael@0: $(srcdir)/make-source-package.sh michael@0: michael@0: clean:: michael@0: DIST=$(DIST) \ michael@0: MOZJS_MAJOR_VERSION=$(MOZJS_MAJOR_VERSION) \ michael@0: MOZJS_MINOR_VERSION=$(MOZJS_MINOR_VERSION) \ michael@0: MOZJS_PATCH_VERSION=$(MOZJS_PATCH_VERSION) \ michael@0: MOZJS_ALPHA=$(MOZJS_ALPHA) \ michael@0: $(srcdir)/make-source-package.sh clean michael@0: michael@0: endif