1 # -*- Mode: makefile -*-
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is Mozilla Communicator client code, released
19 # The Initial Developer of the Original Code is
20 # Netscape Communications Corporation.
21 # Portions created by the Initial Developer are Copyright (C) 1998
22 # the Initial Developer. All Rights Reserved.
26 # Alternatively, the contents of this file may be used under the terms of
27 # either of the GNU General Public License Version 2 or later (the "GPL"),
28 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
41 topsrcdir
= @top_srcdir@
44 run_for_side_effects
:= $(shell echo
"MAKE: $(MAKE)")
45 include $(DEPTH
)/config
/autoconf.mk
50 DIRS
+= analysis-tests
53 ifdef JS_NATIVE_EDITLINE
57 # editline needs to get built before the shell
58 ifndef JS_DISABLE_SHELL
62 # FIXME: bug 515383 covers getting these working on wince
75 STATIC_LIBRARY_NAME
= js_static
82 # icc gets special optimize flags
83 ifdef MOZ_PROFILE_GENERATE
84 MODULE_OPTIMIZE_FLAGS
= -O0
86 MODULE_OPTIMIZE_FLAGS
= -O2
-ip
87 #XXX: do we want different INTERP_OPTIMIZER flags here?
90 MODULE_OPTIMIZE_FLAGS
= -O3
-fstrict-aliasing
$(MOZ_OPTIMIZE_SIZE_TWEAK
)
91 # Special optimization flags for jsinterp.c
92 INTERP_OPTIMIZER
= -O3
-fstrict-aliasing
95 ifeq ($(OS_ARCH
),SunOS
)
96 MODULE_OPTIMIZE_FLAGS
= -xO4
98 ifeq ($(OS_ARCH
),WINNT
)
100 # -GL is not supported on windows mobile while we are using the arm-wince-link command
101 MODULE_OPTIMIZE_FLAGS
= -O2
103 MODULE_OPTIMIZE_FLAGS
= -O2
-GL
109 # JavaScript must be built shared, even for static builds, as it is used by
110 # other modules which are always built shared. Failure to do so results in
111 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
112 # and then the static data cells used for locking no longer work.
114 # In fact, we now build both a static and a shared library, as the
115 # JS shell would like to link to the static library.
167 INSTALLED_HEADERS
= \
170 $(CURDIR
)/jsautokw.h \
226 VPATH
+= $(srcdir)/nanojit
228 INSTALLED_HEADERS
+= \
238 Native
$(NANOJIT_ARCH
).h \
254 Native
$(NANOJIT_ARCH
).
cpp \
263 ASFILES
+= jswince.asm
269 INSTALLED_HEADERS
+= \
271 $(CURDIR
)/javascript-trace.h \
275 ifeq (,$(filter-out WINNT WINCE
,$(OS_ARCH
)))
276 INSTALLED_HEADERS
+= jscpucfg.h
279 EXPORTS
= $(INSTALLED_HEADERS
)
283 ifneq (,$(filter OS2 WINCE WINNT
,$(OS_ARCH
)))
284 SDK_LIBRARY
= $(IMPORT_LIBRARY
)
286 SDK_LIBRARY
= $(SHARED_LIBRARY
)
289 include $(topsrcdir
)/config
/config.mk
291 EXTRA_DSO_LDOPTS
+= $(NSPR_LIBS
)
294 ifeq ($(OS_ARCH
),SunOS
)
295 EXTRA_DSO_LDOPTS
+= $(call EXPAND_LIBNAME_PATH
,jemalloc
,$(DIST
)/lib
)
303 # Define keyword generator before rules.mk, see bug 323979 comment 50
305 HOST_SIMPLE_PROGRAMS
+= host_jskwgen
$(HOST_BIN_SUFFIX
)
306 GARBAGE
+= jsautokw.h host_jskwgen
$(HOST_BIN_SUFFIX
)
308 HOST_SIMPLE_PROGRAMS
+= host_jsoplengen
$(HOST_BIN_SUFFIX
)
309 GARBAGE
+= jsautooplen.h host_jsoplengen
$(HOST_BIN_SUFFIX
)
314 ifneq ($(OS_ARCH
),Darwin
)
315 DTRACE_PROBE_OBJ
= $(LIBRARY_NAME
)-dtrace.
$(OBJ_SUFFIX
)
317 MOZILLA_DTRACE_SRC
= $(srcdir)/javascript-trace.d
322 ifneq (,$(CROSS_COMPILE
)$(filter-out WINNT OS2
,$(OS_ARCH
)))
323 ifneq (,$(filter-out SYMBIAN WINCE
,$(OS_ARCH
)))
324 # nsinstall doesn't get built until we enter config/ in the exports phase,
325 # so we'll have to manually ensure it gets built here if we want to use
327 export:: config
/nsinstall
$(HOST_BIN_SUFFIX
)
328 $(PUBLIC
) $(SDK_PUBLIC
): config
/nsinstall
$(HOST_BIN_SUFFIX
)
330 config
/nsinstall
$(HOST_BIN_SUFFIX
): $(srcdir)/config
/nsinstall.c
$(srcdir)/config
/pathsub.c
331 $(MAKE
) -C config
/ nsinstall
$(HOST_BIN_SUFFIX
)
335 include $(topsrcdir
)/config
/rules.mk
337 ifdef MOZ_SYNC_BUILD_FILES
338 # Because the SpiderMonkey can be distributed and built independently
339 # of the Mozilla source tree, it contains its own copies of many of
340 # the files used by the top-level Mozilla build process, from the
341 # 'config' and 'build' subtrees.
343 # To make it simpler to keep the copies in sync, we follow the policy
344 # that the SpiderMonkey copies must always be exact copies of those in
345 # the containing Mozilla tree. If you've made a change in one, it
346 # belongs in the other as well. If the change isn't right for both
347 # places, then that's something to bring up with the other developers.
349 # Some files are reasonable to diverge; for example,
350 # js/config/autoconf.mk.in doesn't need most of the stuff in
351 # config/autoconf.mk.in.
352 check-sync-dirs
= $(PYTHON
) $(srcdir)/config
/check-sync-dirs.py
354 $(check-sync-dirs
) $(srcdir)/config
$(MOZ_SYNC_BUILD_FILES
)/config
355 $(check-sync-dirs
) $(srcdir)/build
$(MOZ_SYNC_BUILD_FILES
)/build
358 $(check-sync-dirs
) $(srcdir)/config
$(MOZ_SYNC_BUILD_FILES
)/config
359 $(check-sync-dirs
) $(srcdir)/build
$(MOZ_SYNC_BUILD_FILES
)/build
364 $(wildcard $(RUN_TEST_PROGRAM
)) $(PYTHON
) -u
$(srcdir)/trace-test
/trace-test.py \
365 --no-slow
--no-progress
--tinderbox
$(DIST
)/bin
/js
$(BIN_SUFFIX
)
368 $(wildcard $(RUN_TEST_PROGRAM
)) $(PYTHON
) -u
$(srcdir)/trace-test
/trace-test.py \
369 --valgrind
--no-slow
--no-progress
--tinderbox
$(DIST
)/bin
/js
$(BIN_SUFFIX
)
372 DIST_GARBAGE
= config.cache config.log config.status \
373 config
/myrules.mk config
/myconfig.mk \
374 unallmakefiles js-config js-config.h js-confdefs.h
377 cat unallmakefiles |
$(XARGS
) rm -f
378 rm -f
$(DIST_GARBAGE
)
380 # our build system doesn't handle subdir srcs very gracefully today
384 DEFINES
+= -DEXPORT_JS_API
386 INCLUDES
+= -I
$(srcdir)
388 GARBAGE
+= jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg
390 ifneq (,$(CROSS_COMPILE
)$(filter-out WINNT
,$(OS_ARCH
)))
391 TARGETS
+= jscpucfg
$(HOST_BIN_SUFFIX
)
395 DEFINES
+= -DJS_THREADSAFE
398 ifdef JS_NO_THIN_LOCKS
399 DEFINES
+= -DJS_USE_ONLY_NSPR_LOCKS
403 DEFINES
+= -DJS_VERSION
=$(JS_VERSION
)
406 ifneq ($(findstring -L
,$(NSPR_LIBS
)),)
407 NSPR_STATIC_PATH
= $(subst -L
,,$(findstring -L
,$(NSPR_LIBS
)))
409 NSPR_STATIC_PATH
= $(DIST
)/lib
413 CFLAGS
+= -F
/System
/Library
/PrivateFrameworks
414 CXXFLAGS
+= -F
/System
/Library
/PrivateFrameworks
415 LDFLAGS
+= -F
/System
/Library
/PrivateFrameworks
-framework CHUD
419 CXXFLAGS
+= -IC
:/Program\ Files
/Intel
/VTune
/Analyzer
/Include
420 EXTRA_DSO_LDOPTS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
421 LIBS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
424 # BeOS and HP-UX do not require the extra linking of "-lm"
425 ifeq (,$(filter BeOS HP-UX WINNT WINCE OpenVMS OS2
,$(OS_ARCH
)))
429 # Prevent floating point errors caused by VC++ optimizations
430 ifeq ($(OS_ARCH
)_
$(GNU_CC
),WINNT_
)
431 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER
)))
434 CFLAGS
+= -fp
:precise
438 ifeq ($(OS_ARCH
),FreeBSD
)
439 EXTRA_LIBS
+= -pthread
441 ifeq ($(OS_ARCH
),IRIX
)
446 ifeq ($(OS_ARCH
),Linux
)
449 ifeq ($(OS_ARCH
),OSF1
)
452 ifeq ($(OS_ARCH
),SunOS
)
453 ifeq ($(TARGET_CPU
),sparc
)
461 ifeq ($(OS_RELEASE
),4.1)
462 EXTRA_LIBS
+= -ldl
-lnsl
464 EXTRA_LIBS
+= -lposix4
-ldl
-lnsl
-lsocket
469 ifeq ($(OS_ARCH
),Darwin
)
470 LDFLAGS
+= -ljemalloc
474 ifdef SOLARIS_SUNPRO_CXX
475 # Sun Studio x86 has an optimization bug with LIR.cpp, use -xO2 instead.
476 ifeq (86,$(findstring 86,$(OS_TEST
)))
477 LIR.o
: LIR.
cpp Makefile.in
479 @
$(MAKE_DEPS_AUTO_CXX
)
480 $(CXX
) -o
$@
-c
$(patsubst -xO
%,-xO2
,$(COMPILE_CFLAGS
)) $<
482 # Sun Studio SPARC doesn't work well with gcc inline asm, use lock_SunOS_sparc*.il
483 jslock.o
: jslock.
cpp Makefile.in lock_sparcv8plus.il lock_sparcv9.il
485 @
$(MAKE_DEPS_AUTO_CXX
)
486 ifeq (sparcv9
,$(findstring sparcv9
,$(OS_TEST
)))
487 $(CXX
) -o
$@
-c
$(COMPILE_CFLAGS
) $(srcdir)/lock_sparcv9.il
$<
489 $(CXX
) -o
$@
-c
$(COMPILE_CFLAGS
) $(srcdir)/lock_sparcv8plus.il
$<
492 endif # SOLARIS_SUNPRO_CXX
494 # Allow building jsinterp.c with special optimization flags
495 ifdef INTERP_OPTIMIZER
496 jsinterp.
$(OBJ_SUFFIX
): MODULE_OPTIMIZE_FLAGS
=$(INTERP_OPTIMIZER
)
499 ifeq ($(OS_ARCH
),IRIX
)
501 _COMPILE_CFLAGS
= $(patsubst -O
%,-O1
,$(COMPILE_CFLAGS
))
502 jsapi.o jsxdrapi.o jsarena.o jsarray.o jsatom.o jsemit.o jsfun.o jsinterp.o jsregexp.o jsparse.o jsopcode.o jsscript.o
: %.o
: %.
cpp Makefile.in
504 @
$(MAKE_DEPS_AUTO_CXX
)
505 $(CXX
) -o
$@
-c
$(_COMPILE_CFLAGS
) $<
509 # An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
510 # This suppresses optimization for this single compilation unit.
511 ifeq ($(OS_ARCH
),AIX
)
512 jsatom.o
: jsatom.
cpp Makefile.in
514 @
$(MAKE_DEPS_AUTO_CXX
)
515 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
516 jsdtoa.o
: jsdtoa.
cpp Makefile.in
518 @
$(MAKE_DEPS_AUTO_CXX
)
519 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
524 ifeq (,$(CROSS_COMPILE
)$(GNU_CC
)$(filter-out WINNT
,$(OS_ARCH
)))
528 ifeq ($(OS_ARCH
),WINCE
)
532 jsautocfg.h
: jscpucfg
$(HOST_BIN_SUFFIX
)
533 @
rm -f
$@ jsautocfg.tmp
534 .
/jscpucfg
> jsautocfg.tmp
539 # jscpucfg is a strange target
540 # Needs to be built with the host compiler but needs to include
541 # the mdcpucfg for the target so it needs the appropriate target defines
542 ifdef HOST_NSPR_MDCPUCFG
543 HOST_CXX
:= $(HOST_CXX
) -DMDCPUCFG
=$(TARGET_NSPR_MDCPUCFG
)
544 HOST_CXXFLAGS
:= $(patsubst -DXP_
%,,$(HOST_CXXFLAGS
))
548 # jscpucfg needs to know when it's supposed to produce a config for the target
549 JSCPUCFG_DEFINES
= $(ACDEFINES
)
552 ifeq ($(OS_ARCH
),QNX
)
553 ifneq ($(OS_TARGET
),NTO
)
554 # QNX's compiler apparently can't build a binary directly from a source file.
555 jscpucfg.o
: jscpucfg.
cpp Makefile.in
556 $(HOST_CXX
) $(HOST_CXXFLAGS
) -c
$(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) -o
$@
$<
559 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) -o
$@
$<
562 ifeq ($(OS_ARCH
),WINCE
)
563 jscpucfg
$(HOST_BIN_SUFFIX
):
564 echo no need to build jscpucfg
$<
566 jscpucfg
$(HOST_BIN_SUFFIX
): jscpucfg.
cpp Makefile.in
567 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) $(HOST_OUTOPTION
)$@
$<
571 # Compute the linker flags that programs linking against SpiderMonkey should
572 # pass to get SpiderMonkey and its dependencies, beyond just the -L and -l
573 # for the SpiderMonkey library itself.
574 # - EXTRA_DSO_LDOPTS includes the NSPR -L and -l flags.
575 # - OS_LIBS includes libraries selected by the configure script.
576 # - EXTRA_LIBS includes libraries selected by this Makefile.
577 JS_CONFIG_LIBS
=$(EXTRA_DSO_LDOPTS
) $(OS_LIBS
) $(EXTRA_LIBS
)
579 # The configure script invokes this rule explicitly at configure time!
580 # It's important that js-config be ready by the time we're done
581 # configuring, because we may be running other configure scripts that
582 # would like to run js-config themselves, before js is built.
584 # This file and rules.mk go through a certain amount of work to decide
585 # which libraries to build, what to name them, and what flags to pass
586 # when linking them (and thus what flags its own clients must pass).
587 # All this information needs to go into the js-config script. To
588 # avoid trying to re-compute all that in the configure script, we just
589 # have the configure script generate this Makefile, and then invoke
592 js-config
: js-config.in Makefile
$(DEPTH
)/config
/autoconf.mk
$(topsrcdir
)/config
/config.mk
$(topsrcdir
)/config
/rules.mk
594 sed
< $< > js-config.tmp \
595 -e
's|$(at)prefix$(at)|$(prefix)|' \
596 -e
's|$(at)exec_prefix$(at)|$(exec_prefix)|' \
597 -e
's|$(at)includedir$(at)|$(includedir)|' \
598 -e
's|$(at)libdir$(at)|$(libdir)|' \
599 -e
's|$(at)MOZILLA_VERSION$(at)|$(MOZILLA_VERSION)|' \
600 -e
's|$(at)LIBRARY_NAME$(at)|$(LIBRARY_NAME)|' \
601 -e
's|$(at)NSPR_CFLAGS$(at)|$(NSPR_CFLAGS)|' \
602 -e
's|$(at)JS_CONFIG_LIBS$(at)|$(JS_CONFIG_LIBS)|' \
603 -e
's|$(at)MOZ_JS_LIBS$(at)|$(MOZ_JS_LIBS)|' \
604 && mv js-config.tmp
$@
&& chmod
+x
$@
607 SDK_BINARY
= js-config
609 install:: $(INSTALLED_HEADERS
)
610 $(SYSINSTALL
) $^
$(DESTDIR
)$(includedir)/$(MODULE
)
613 $(SYSINSTALL
) $^
$(DESTDIR
)$(bindir)
615 install:: $(LIBRARY
) $(SHARED_LIBRARY
) $(IMPORT_LIBRARY
)
617 $(SYSINSTALL
) $(LIBRARY
) $(DESTDIR
)$(libdir)
619 ifneq (,$(SHARED_LIBRARY
))
620 $(SYSINSTALL
) $(SHARED_LIBRARY
) $(DESTDIR
)$(libdir)
622 ifneq (,$(IMPORT_LIBRARY
))
623 $(SYSINSTALL
) $(IMPORT_LIBRARY
) $(DESTDIR
)$(libdir)
626 # Extra dependancies and rules for auto-generated headers
627 host_jskwgen.
$(OBJ_SUFFIX
): jsversion.h jskeyword.tbl
629 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
630 # previous build?) via VPATH when we're building in a separate tree.
631 $(CURDIR
)/jsautokw.h
: host_jskwgen
$(HOST_BIN_SUFFIX
)
632 .
/host_jskwgen
$(HOST_BIN_SUFFIX
) $@
634 host_jsoplengen.
$(OBJ_SUFFIX
): jsopcode.tbl
636 # Use CURDIR to avoid finding a jsautooplen.h in the source tree (from
637 # a previous build?) via VPATH when we're building in a separate tree.
638 $(CURDIR
)/jsautooplen.h
: host_jsoplengen
$(HOST_BIN_SUFFIX
)
639 .
/host_jsoplengen
$(HOST_BIN_SUFFIX
) $@
641 # Force auto-header generation before compiling any source that may use them
642 $(CPPSRCS
:%.
cpp=%.
$(OBJ_SUFFIX
)): $(CURDIR
)/jsautokw.h
$(CURDIR
)/jsautooplen.h
645 $(CURDIR
)/javascript-trace.h
: $(srcdir)/javascript-trace.d
646 dtrace
-h
-s
$(srcdir)/javascript-trace.d
-o javascript-trace.h.in
647 sed
's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
648 javascript-trace.h.in
> javascript-trace.h
650 # We can't automatically generate dependencies on auto-generated headers;
651 # we have to list them explicitly.
652 $(addsuffix .
$(OBJ_SUFFIX
),jsdtracef jsinterp jsobj
): $(CURDIR
)/javascript-trace.h
657 # If we don't have run-mozilla.sh *and* we're linking against NSPR, we don't
658 # know how to run the JS binary. Oh well
660 imacro_asm.js
: imacro_asm.js.in jsopcode.tbl
661 $(CC
) -c
-x c
-E
-P
-I
$(srcdir) $< > $@
663 GARBAGE
+= imacros.c.tmp imacro_asm.js
665 ifneq (,$(wildcard $(RUN_TEST_PROGRAM
))$(if
$(NSPR_LIBS
),,1))
666 libs
:: imacro_asm.js
$(srcdir)/imacros.jsasm
667 $(wildcard $(RUN_TEST_PROGRAM
)) $(DIST
)/bin
/js
$(BIN_SUFFIX
) $< $(srcdir)/imacros.jsasm
> imacros.c.tmp
668 @cmp
-s imacros.c.tmp
$(srcdir)/imacros.c.out || \
669 (echo
"imacros.c.out is out of date. Run 'make update-imacros' to copy it to your source tree."; diff
-U
4 $(srcdir)/imacros.c.out imacros.c.out
; exit
1)
670 @echo
"imacros.c.out is up to date"
672 update-imacros
: imacros.c.tmp
673 cp
$< $(srcdir)/imacros.c.out
675 # Code for importing the nanojit subtree from its repository.
677 NANOJIT_CENTRAL_REV
=$(shell cat
$(srcdir)/nanojit-import-rev
)
678 NANOJIT_CENTRAL_REPO
=http
://hg.mozilla.org
/projects
/nanojit-central
679 NANOJIT_CENTRAL_LOCAL
=$(CURDIR
)/nanojit-central
680 CUR_REPO
=$(srcdir)/..
/..
683 rm -Rf
$(NANOJIT_CENTRAL_LOCAL
) import-splicemap import-revmap
684 hg clone
$(NANOJIT_CENTRAL_REPO
) $(NANOJIT_CENTRAL_LOCAL
)
685 python
$(srcdir)/find-child.py \
686 --src
=$(NANOJIT_CENTRAL_LOCAL
) \
688 --start
=$(NANOJIT_CENTRAL_REV
) \
689 --filemap
=$(srcdir)/nanojit-import-filemap \
691 hg convert
--config convert.hg.saverev
=True \
692 --config convert.hg.startrev
=`cut -d ' ' -f 1 import-splicemap` \
693 --filemap
=$(srcdir)/nanojit-import-filemap \
694 --splicemap
=import-splicemap \
695 $(NANOJIT_CENTRAL_LOCAL
) \
698 (cd
$(srcdir) && hg up
)
699 (cd
$(NANOJIT_CENTRAL_LOCAL
) && hg log
-r tip
--template
"{node}\n") >$(srcdir)/nanojit-import-rev
700 (cd
$(srcdir) && hg commit
--message
="Update nanojit-import-rev stamp." nanojit-import-rev
)
702 .PHONY
: update-imacros update-nanojit