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@
46 include $(DEPTH
)/config
/autoconf.mk
49 # This is the appropriate behavior for GNU-style 'make install'. For
50 # Mozilla in-tree behavior, leaving NSDISTMODE unset is the right
51 # thing; config/js/Makefile.in sets JS_MOZ_INSTALL in that case.
59 PROGRAM
= js
$(BIN_SUFFIX
)
60 # The shell uses some 'HIDDEN' symbols to produce statistics, so we
61 # link directly against the .o files, not against the JS shared
63 PROGOBJS
= js.
$(OBJ_SUFFIX
) $(OBJS
)
68 # icc gets special optimize flags
69 ifdef MOZ_PROFILE_GENERATE
70 MODULE_OPTIMIZE_FLAGS
= -O0
72 MODULE_OPTIMIZE_FLAGS
= -O2
-ip
73 #XXX: do we want different INTERP_OPTIMIZER flags here?
76 MODULE_OPTIMIZE_FLAGS
= -Os
-fstrict-aliasing
$(MOZ_OPTIMIZE_SIZE_TWEAK
)
77 # Special optimization flags for jsinterp.c
78 INTERP_OPTIMIZER
= -O3
-fstrict-aliasing
81 ifeq ($(OS_ARCH
),SunOS
)
82 MODULE_OPTIMIZE_FLAGS
= -xO4
84 ifeq ($(OS_ARCH
),WINNT
)
86 # -GL is not supported on windows mobile while we are using the arm-wince-link command
87 MODULE_OPTIMIZE_FLAGS
= -O2
89 MODULE_OPTIMIZE_FLAGS
= -O2
-GL
95 ifeq (,$(filter-out WINNT WINCE
,$(OS_ARCH
)))
96 LIBRARY_NAME
= js
$(MOZ_BITS
)$(VERSION_NUMBER
)
99 # JavaScript must be built shared, even for static builds, as it is used by
100 # other modules which are always built shared. Failure to do so results in
101 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
102 # and then the static data cells used for locking no longer work.
104 ifndef JS_STATIC_BUILD
108 ifeq (86,$(findstring 86,$(OS_TEST
)))
109 ifeq (64,$(findstring 64,$(OS_TEST
)))
111 DEFINES
+= -DAVMPLUS_IA32
117 ifeq (arm
,$(findstring arm
,$(OS_TEST
)))
118 DEFINES
+= -DAVMPLUS_ARM
123 ifneq (,$(filter Linux Darwin SunOS FreeBSD
,$(OS_ARCH
)))
124 DEFINES
+= -DAVMPLUS_UNIX
127 ifeq ($(OS_ARCH
),Linux
)
128 DEFINES
+= -DAVMPLUS_LINUX
131 ifeq ($(OS_ARCH
),WINNT
)
132 DEFINES
+= -DAVMPLUS_WIN32
182 INSTALLED_HEADERS
= \
236 VPATH
+= $(srcdir)/nanojit
238 INSTALLED_HEADERS
+= \
246 Native
$(NANOJIT_ARCH
).h \
259 Native
$(NANOJIT_ARCH
).
cpp \
264 CPPSRCS
+= TraceTreeDrawer.
cpp
267 DEFINES
+= -DFEATURE_NANOJIT
-DJS_TRACER
271 INSTALLED_HEADERS
+= \
273 $(CURDIR
)/javascript-trace.h \
277 ifeq (,$(filter-out WINNT WINCE
,$(OS_ARCH
)))
278 INSTALLED_HEADERS
+= jscpucfg.h
285 ifneq (,$(filter OS2 WINCE WINNT
,$(OS_ARCH
)))
286 SDK_LIBRARY
= $(IMPORT_LIBRARY
)
288 SDK_LIBRARY
= $(SHARED_LIBRARY
)
291 include $(topsrcdir
)/config
/config.mk
293 EXTRA_DSO_LDOPTS
+= $(NSPR_LIBS
)
296 ifeq ($(OS_ARCH
),SunOS
)
297 EXTRA_DSO_LDOPTS
+= $(call EXPAND_LIBNAME_PATH
,jemalloc
,$(DIST
)/lib
)
301 # When using gcc the assembly is inlined in the C-file (see jslock.cpp)
302 ifeq ($(OS_ARCH
),SunOS
)
303 ifneq (86,$(findstring 86,$(OS_TEST
)))
305 ASFILES
= lock_
$(OS_ARCH
).s
315 JSJAVA_STUBHEADERS
= \
316 -I
$(topsrcdir
)/sun-java
/include/_gen \
317 -I
$(topsrcdir
)/sun-java
/netscape
/javascript
/_jri \
318 -I
$(topsrcdir
)/sun-java
/netscape
/security
/_jri
320 JSJAVA_STUBHEADERS
= -I
$(JRI_GEN_DIR
) -I
$(JDK_GEN_DIR
)
324 -I
$(topsrcdir
)/sun-java
/md-include \
325 -I
$(topsrcdir
)/sun-java
/include \
326 $(JSJAVA_STUBHEADERS
)
328 # Define keyword generator before rules.mk, see bug 323979 comment 50
330 HOST_SIMPLE_PROGRAMS
+= host_jskwgen
$(HOST_BIN_SUFFIX
)
331 GARBAGE
+= jsautokw.h host_jskwgen
$(HOST_BIN_SUFFIX
)
333 HOST_SIMPLE_PROGRAMS
+= host_jsoplengen
$(HOST_BIN_SUFFIX
)
334 GARBAGE
+= jsautooplen.h host_jsoplengen
$(HOST_BIN_SUFFIX
)
339 ifneq ($(OS_ARCH
),Darwin
)
340 DTRACE_PROBE_OBJ
= $(LIBRARY_NAME
)-dtrace.
$(OBJ_SUFFIX
)
342 MOZILLA_DTRACE_SRC
= $(srcdir)/javascript-trace.d
345 include $(topsrcdir
)/config
/rules.mk
347 ifdef MOZ_SYNC_BUILD_FILES
348 # Because the SpiderMonkey can be distributed and built independently
349 # of the Mozilla source tree, it contains its own copies of many of
350 # the files used by the top-level Mozilla build process, from the
351 # 'config' and 'build' subtrees.
353 # To make it simpler to keep the copies in sync, we follow the policy
354 # that the SpiderMonkey copies must always be exact copies of those in
355 # the containing Mozilla tree. If you've made a change in one, it
356 # belongs in the other as well. If the change isn't right for both
357 # places, then that's something to bring up with the other developers.
359 # Some files are reasonable to diverge; for example,
360 # js/config/autoconf.mk.in doesn't need most of the stuff in
361 # config/autoconf.mk.in.
362 check-sync-dirs
= $(PYTHON
) $(srcdir)/config
/check-sync-dirs.py
364 $(check-sync-dirs
) $(srcdir)/config
$(MOZ_SYNC_BUILD_FILES
)/config
365 $(check-sync-dirs
) $(srcdir)/build
$(MOZ_SYNC_BUILD_FILES
)/build
368 # our build system doesn't handle subdir srcs very gracefully today
372 DEFINES
+= -DEXPORT_JS_API
374 INCLUDES
+= -I
$(srcdir)
376 # MSVC '-Gy' cc flag and '/OPT:REF' linker flag cause JS_GetArgument and
377 # JS_GetLocalVariable to be folded to the same address by the linker,
378 # leading to a crash on startup. See bug 151066. So, in optimized builds,
379 # add the /OPT:NOICF flag, which turns off 'identical COMDAT folding'.
381 # N.B.: 'identical COMDAT folding' that folds functions whose addresses
382 # are taken violates the ISO C and C++ standards.
384 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
385 LDFLAGS
+= -OPT
:NOICF
389 GARBAGE
+= jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg
391 ifneq (,$(CROSS_COMPILE
)$(filter-out WINNT
,$(OS_ARCH
)))
392 TARGETS
+= jscpucfg
$(HOST_BIN_SUFFIX
)
396 DEFINES
+= -DJS_USE_SAFE_ARENA
400 DEFINES
+= -DJS_THREADSAFE
403 ifdef JS_NO_THIN_LOCKS
404 DEFINES
+= -DJS_USE_ONLY_NSPR_LOCKS
408 DEFINES
+= -DJS_VERSION
=$(JS_VERSION
)
411 ifneq ($(findstring -L
,$(NSPR_LIBS
)),)
412 NSPR_STATIC_PATH
= $(subst -L
,,$(findstring -L
,$(NSPR_LIBS
)))
414 NSPR_STATIC_PATH
= $(DIST
)/lib
418 CFLAGS
+= -F
/System
/Library
/PrivateFrameworks
419 CXXFLAGS
+= -F
/System
/Library
/PrivateFrameworks
420 LDFLAGS
+= -F
/System
/Library
/PrivateFrameworks
-framework CHUD
424 CXXFLAGS
+= -IC
:/Program\ Files
/Intel
/VTune
/Analyzer
/Include
425 EXTRA_DSO_LDOPTS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
426 LIBS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
429 # BeOS and HP-UX do not require the extra linking of "-lm"
430 ifeq (,$(filter BeOS HP-UX WINNT WINCE OpenVMS
,$(OS_ARCH
)))
434 # Prevent floating point errors caused by VC++ optimizations
435 ifeq ($(OS_ARCH
)_
$(GNU_CC
),WINNT_
)
436 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER
)))
439 CFLAGS
+= -fp
:precise
443 ifeq ($(OS_ARCH
),FreeBSD
)
444 EXTRA_LIBS
+= -pthread
446 ifeq ($(OS_ARCH
),IRIX
)
451 ifeq ($(OS_ARCH
),Linux
)
454 ifeq ($(OS_ARCH
),OSF1
)
457 ifeq ($(OS_ARCH
),SunOS
)
458 ifeq ($(TARGET_CPU
),sparc
)
460 ifdef JS_ULTRASPARC_OPTS
461 DEFINES
+= -DULTRA_SPARC
463 CFLAGS
+= -Wa
,-xarch
=v8plus
,-DULTRA_SPARC
,-P
,-L
,-D_ASM
,-D__STDC__
=0
464 CXXFLAGS
+= -Wa
,-xarch
=v8plus
,-DULTRA_SPARC
,-P
,-L
,-D_ASM
,-D__STDC__
=0,-K
,PIC
466 ASFLAGS
+= -xarch
=v8plus
-DULTRA_SPARC
-P
-L
-D_ASM
-D__STDC__
=0 -K PIC
468 endif # JS_ULTRASPARC_OPTS
471 ifeq ($(OS_RELEASE
),4.1)
472 EXTRA_LIBS
+= -ldl
-lnsl
474 EXTRA_LIBS
+= -lposix4
-ldl
-lnsl
-lsocket
479 ifeq ($(OS_ARCH
),Darwin
)
480 LDFLAGS
+= -ljemalloc
484 # Sun Studio x86 has an optimization bug with LIR.cpp, use -xO2 instead.
485 ifeq ($(OS_ARCH
),SunOS
)
486 ifeq (86,$(findstring 86,$(OS_TEST
)))
488 LIR.o
: LIR.
cpp Makefile.in
490 @
$(MAKE_DEPS_AUTO_CXX
)
491 $(CXX
) -o
$@
-c
$(patsubst -xO
%,-xO2
,$(COMPILE_CFLAGS
)) $<
496 # Allow building jsinterp.c with special optimization flags
497 ifdef INTERP_OPTIMIZER
498 jsinterp.
$(OBJ_SUFFIX
): MODULE_OPTIMIZE_FLAGS
=$(INTERP_OPTIMIZER
)
501 ifeq ($(OS_ARCH
),IRIX
)
503 _COMPILE_CFLAGS
= $(patsubst -O
%,-O1
,$(COMPILE_CFLAGS
))
504 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
506 @
$(MAKE_DEPS_AUTO_CXX
)
507 $(CXX
) -o
$@
-c
$(_COMPILE_CFLAGS
) $<
511 # An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
512 # This suppresses optimization for this single compilation unit.
513 ifeq ($(OS_ARCH
),AIX
)
514 jsatom.o
: jsatom.
cpp Makefile.in
516 @
$(MAKE_DEPS_AUTO_CXX
)
517 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
518 jsdtoa.o
: jsdtoa.
cpp Makefile.in
520 @
$(MAKE_DEPS_AUTO_CXX
)
521 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
524 jsopcode.h jsopcode.
cpp: jsopcode.tbl
528 ifeq (,$(CROSS_COMPILE
)$(filter-out WINNT
,$(OS_ARCH
)))
532 ifeq ($(OS_ARCH
),WINCE
)
536 jsautocfg.h
: jscpucfg
$(HOST_BIN_SUFFIX
)
537 @
rm -f
$@ jsautocfg.tmp
538 .
/jscpucfg
> jsautocfg.tmp
543 # jscpucfg is a strange target
544 # Needs to be built with the host compiler but needs to include
545 # the mdcpucfg for the target so it needs the appropriate target defines
546 ifdef HOST_NSPR_MDCPUCFG
547 HOST_CXX
:= $(HOST_CXX
) -DMDCPUCFG
=$(TARGET_NSPR_MDCPUCFG
)
548 HOST_CXXFLAGS
:= $(patsubst -DXP_
%,,$(HOST_CXXFLAGS
))
552 # jscpucfg needs to know when it's supposed to produce a config for the target
553 JSCPUCFG_DEFINES
= $(ACDEFINES
)
556 ifeq ($(OS_ARCH
),QNX
)
557 ifneq ($(OS_TARGET
),NTO
)
558 # QNX's compiler apparently can't build a binary directly from a source file.
559 jscpucfg.o
: jscpucfg.
cpp Makefile.in
560 $(HOST_CXX
) $(HOST_CXXFLAGS
) -c
$(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) -o
$@
$<
563 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) -o
$@
$<
566 ifeq ($(OS_ARCH
),WINCE
)
567 jscpucfg
$(HOST_BIN_SUFFIX
):
568 echo no need to build jscpucfg
$<
570 jscpucfg
$(HOST_BIN_SUFFIX
): jscpucfg.
cpp Makefile.in
571 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) $(HOST_OUTOPTION
)$@
$<
575 # Compute the linker flags that programs linking against SpiderMonkey should
576 # pass to get SpiderMonkey and its dependencies, beyond just the -L and -l
577 # for the SpiderMonkey library itself.
578 # - EXTRA_DSO_LDOPTS includes the NSPR -L and -l flags.
579 # - OS_LIBS includes libraries selected by the configure script.
580 # - EXTRA_LIBS includes libraries selected by this Makefile.
581 JS_CONFIG_LIBS
=$(EXTRA_DSO_LDOPTS
) $(OS_LIBS
) $(EXTRA_LIBS
)
583 # The configure script invokes this rule explicitly at configure time!
584 # It's important that js-config be ready by the time we're done
585 # configuring, because we may be running other configure scripts that
586 # would like to run js-config themselves, before js is built.
588 # This file and rules.mk go through a certain amount of work to decide
589 # which libraries to build, what to name them, and what flags to pass
590 # when linking them (and thus what flags its own clients must pass).
591 # All this information needs to go into the js-config script. To
592 # avoid trying to re-compute all that in the configure script, we just
593 # have the configure script generate this Makefile, and then invoke
596 js-config
: js-config.in Makefile
$(DEPTH
)/config
/autoconf.mk
$(topsrcdir
)/config
/config.mk
$(topsrcdir
)/config
/rules.mk
598 sed
< $< > js-config.tmp \
599 -e
's|$(at)prefix$(at)|$(prefix)|' \
600 -e
's|$(at)exec_prefix$(at)|$(exec_prefix)|' \
601 -e
's|$(at)includedir$(at)|$(includedir)|' \
602 -e
's|$(at)libdir$(at)|$(libdir)|' \
603 -e
's|$(at)MOZILLA_VERSION$(at)|$(MOZILLA_VERSION)|' \
604 -e
's|$(at)LIBRARY_NAME$(at)|$(LIBRARY_NAME)|' \
605 -e
's|$(at)NSPR_CFLAGS$(at)|$(NSPR_CFLAGS)|' \
606 -e
's|$(at)JS_CONFIG_LIBS$(at)|$(JS_CONFIG_LIBS)|' \
607 -e
's|$(at)MOZ_JS_LIBS$(at)|$(MOZ_JS_LIBS)|' \
608 && mv js-config.tmp
$@
&& chmod
+x
$@
612 install:: $(INSTALLED_HEADERS
)
613 $(INSTALL
) $(IFLAGS1
) $^
$(includedir)/$(MODULE
)
615 install:: $(SCRIPTS
) $(PROGRAM
)
616 $(INSTALL
) $(IFLAGS2
) $^
$(bindir)
618 # The Mozilla top-level makefiles use install-runtime-libs directly to
619 # place an additional copy of the libraries in the 'dist/bin'
621 install:: install-runtime-libs
622 install-runtime-libs
:: $(LIBRARY
) $(SHARED_LIBRARY
) $(IMPORT_LIBRARY
)
624 $(INSTALL
) $(IFLAGS1
) $(LIBRARY
) $(libdir)
626 ifneq (,$(SHARED_LIBRARY
))
627 $(INSTALL
) $(IFLAGS2
) $(SHARED_LIBRARY
) $(libdir)
629 ifneq (,$(IMPORT_LIBRARY
))
630 $(INSTALL
) $(IFLAGS2
) $(IMPORT_LIBRARY
) $(libdir)
633 # Extra dependancies and rules for auto-generated headers
634 host_jskwgen.
$(OBJ_SUFFIX
): jsversion.h jskeyword.tbl
636 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
637 # previous build?) via VPATH when we're building in a separate tree.
638 $(CURDIR
)/jsautokw.h
: host_jskwgen
$(HOST_BIN_SUFFIX
)
639 .
/host_jskwgen
$(HOST_BIN_SUFFIX
) $@
641 host_jsoplengen.
$(OBJ_SUFFIX
): jsopcode.tbl
643 # Use CURDIR to avoid finding a jsautooplen.h in the source tree (from
644 # a previous build?) via VPATH when we're building in a separate tree.
645 $(CURDIR
)/jsautooplen.h
: host_jsoplengen
$(HOST_BIN_SUFFIX
)
646 .
/host_jsoplengen
$(HOST_BIN_SUFFIX
) $@
648 # Force auto-header generation before compiling any source that may use them
649 $(CPPSRCS
:%.
cpp=%.
$(OBJ_SUFFIX
)): $(CURDIR
)/jsautokw.h
$(CURDIR
)/jsautooplen.h
652 $(CURDIR
)/javascript-trace.h
: $(srcdir)/javascript-trace.d
653 dtrace
-h
-s
$(srcdir)/javascript-trace.d
-o javascript-trace.h.in
654 sed
's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
655 javascript-trace.h.in
> javascript-trace.h
657 # We can't automatically generate dependencies on auto-generated headers;
658 # we have to list them explicitly.
659 $(addsuffix .
$(OBJ_SUFFIX
),jsdtracef jsinterp jsobj
): $(CURDIR
)/javascript-trace.h