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.
168 INSTALLED_HEADERS
= \
171 $(CURDIR
)/jsautokw.h \
227 ifdef ENABLE_TRACEJIT
228 VPATH
+= $(srcdir)/nanojit
230 INSTALLED_HEADERS
+= \
240 Native
$(NANOJIT_ARCH
).h \
256 Native
$(NANOJIT_ARCH
).
cpp \
265 ASFILES
+= jswince.asm
268 endif # ENABLE_TRACEJIT
271 INSTALLED_HEADERS
+= \
273 $(CURDIR
)/javascript-trace.h \
277 ifeq (,$(filter-out WINNT WINCE
,$(OS_ARCH
)))
278 INSTALLED_HEADERS
+= jscpucfg.h
281 EXPORTS
= $(INSTALLED_HEADERS
)
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
)
305 # Define keyword generator before rules.mk, see bug 323979 comment 50
307 HOST_SIMPLE_PROGRAMS
+= host_jskwgen
$(HOST_BIN_SUFFIX
)
308 GARBAGE
+= jsautokw.h host_jskwgen
$(HOST_BIN_SUFFIX
)
310 HOST_SIMPLE_PROGRAMS
+= host_jsoplengen
$(HOST_BIN_SUFFIX
)
311 GARBAGE
+= jsautooplen.h host_jsoplengen
$(HOST_BIN_SUFFIX
)
316 ifneq ($(OS_ARCH
),Darwin
)
317 DTRACE_PROBE_OBJ
= $(LIBRARY_NAME
)-dtrace.
$(OBJ_SUFFIX
)
319 MOZILLA_DTRACE_SRC
= $(srcdir)/javascript-trace.d
324 ifneq (,$(CROSS_COMPILE
)$(filter-out WINNT OS2
,$(OS_ARCH
)))
325 ifneq (,$(filter-out SYMBIAN WINCE
,$(OS_ARCH
)))
326 # nsinstall doesn't get built until we enter config/ in the exports phase,
327 # so we'll have to manually ensure it gets built here if we want to use
329 export:: config
/nsinstall
$(HOST_BIN_SUFFIX
)
330 $(PUBLIC
) $(SDK_PUBLIC
): config
/nsinstall
$(HOST_BIN_SUFFIX
)
332 config
/nsinstall
$(HOST_BIN_SUFFIX
): $(srcdir)/config
/nsinstall.c
$(srcdir)/config
/pathsub.c
333 $(MAKE
) -C config
/ nsinstall
$(HOST_BIN_SUFFIX
)
337 include $(topsrcdir
)/config
/rules.mk
339 ifdef MOZ_SYNC_BUILD_FILES
340 # Because the SpiderMonkey can be distributed and built independently
341 # of the Mozilla source tree, it contains its own copies of many of
342 # the files used by the top-level Mozilla build process, from the
343 # 'config' and 'build' subtrees.
345 # To make it simpler to keep the copies in sync, we follow the policy
346 # that the SpiderMonkey copies must always be exact copies of those in
347 # the containing Mozilla tree. If you've made a change in one, it
348 # belongs in the other as well. If the change isn't right for both
349 # places, then that's something to bring up with the other developers.
351 # Some files are reasonable to diverge; for example,
352 # js/config/autoconf.mk.in doesn't need most of the stuff in
353 # config/autoconf.mk.in.
354 check-sync-dirs
= $(PYTHON
) $(srcdir)/config
/check-sync-dirs.py
356 $(check-sync-dirs
) $(srcdir)/config
$(MOZ_SYNC_BUILD_FILES
)/config
357 $(check-sync-dirs
) $(srcdir)/build
$(MOZ_SYNC_BUILD_FILES
)/build
360 $(check-sync-dirs
) $(srcdir)/config
$(MOZ_SYNC_BUILD_FILES
)/config
361 $(check-sync-dirs
) $(srcdir)/build
$(MOZ_SYNC_BUILD_FILES
)/build
364 ifdef ENABLE_TRACEJIT
366 $(wildcard $(RUN_TEST_PROGRAM
)) $(PYTHON
) -u
$(srcdir)/trace-test
/trace-test.py \
367 --no-slow
--no-progress
--tinderbox
$(DIST
)/bin
/js
$(BIN_SUFFIX
)
370 $(wildcard $(RUN_TEST_PROGRAM
)) $(PYTHON
) -u
$(srcdir)/trace-test
/trace-test.py \
371 --valgrind
--no-slow
--no-progress
--tinderbox
$(DIST
)/bin
/js
$(BIN_SUFFIX
)
374 DIST_GARBAGE
= config.cache config.log config.status \
375 config
/myrules.mk config
/myconfig.mk \
376 unallmakefiles js-config js-config.h js-confdefs.h
379 cat unallmakefiles |
$(XARGS
) rm -f
380 rm -f
$(DIST_GARBAGE
)
382 # our build system doesn't handle subdir srcs very gracefully today
386 DEFINES
+= -DEXPORT_JS_API
388 INCLUDES
+= -I
$(srcdir)
390 GARBAGE
+= jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg
392 ifneq (,$(CROSS_COMPILE
)$(filter-out WINNT
,$(OS_ARCH
)))
393 TARGETS
+= jscpucfg
$(HOST_BIN_SUFFIX
)
397 DEFINES
+= -DJS_THREADSAFE
400 ifdef JS_NO_THIN_LOCKS
401 DEFINES
+= -DJS_USE_ONLY_NSPR_LOCKS
405 DEFINES
+= -DJS_VERSION
=$(JS_VERSION
)
408 ifneq ($(findstring -L
,$(NSPR_LIBS
)),)
409 NSPR_STATIC_PATH
= $(subst -L
,,$(findstring -L
,$(NSPR_LIBS
)))
411 NSPR_STATIC_PATH
= $(DIST
)/lib
415 CFLAGS
+= -F
/System
/Library
/PrivateFrameworks
416 CXXFLAGS
+= -F
/System
/Library
/PrivateFrameworks
417 LDFLAGS
+= -F
/System
/Library
/PrivateFrameworks
-framework CHUD
421 CXXFLAGS
+= -IC
:/Program\ Files
/Intel
/VTune
/Analyzer
/Include
422 EXTRA_DSO_LDOPTS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
423 LIBS
+= C
:/Program\ Files
/Intel
/VTune
/Analyzer
/Lib
/VtuneApi.lib
426 # BeOS and HP-UX do not require the extra linking of "-lm"
427 ifeq (,$(filter BeOS HP-UX WINNT WINCE OpenVMS OS2
,$(OS_ARCH
)))
431 # Prevent floating point errors caused by VC++ optimizations
432 ifeq ($(OS_ARCH
)_
$(GNU_CC
),WINNT_
)
433 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER
)))
436 CFLAGS
+= -fp
:precise
440 ifeq ($(OS_ARCH
),FreeBSD
)
441 EXTRA_LIBS
+= -pthread
443 ifeq ($(OS_ARCH
),IRIX
)
448 ifeq ($(OS_ARCH
),Linux
)
451 ifeq ($(OS_ARCH
),OSF1
)
454 ifeq ($(OS_ARCH
),SunOS
)
455 ifeq ($(TARGET_CPU
),sparc
)
463 ifeq ($(OS_RELEASE
),4.1)
464 EXTRA_LIBS
+= -ldl
-lnsl
466 EXTRA_LIBS
+= -lposix4
-ldl
-lnsl
-lsocket
471 ifeq ($(OS_ARCH
),Darwin
)
472 LDFLAGS
+= -ljemalloc
476 ifdef SOLARIS_SUNPRO_CXX
477 # Sun Studio SPARC doesn't work well with gcc inline asm, use lock_SunOS_sparc*.il
478 jslock.o
: jslock.
cpp Makefile.in lock_sparcv8plus.il lock_sparcv9.il
480 @
$(MAKE_DEPS_AUTO_CXX
)
481 ifeq (sparcv9
,$(findstring sparcv9
,$(OS_TEST
)))
482 $(CXX
) -o
$@
-c
$(COMPILE_CFLAGS
) $(srcdir)/lock_sparcv9.il
$<
484 $(CXX
) -o
$@
-c
$(COMPILE_CFLAGS
) $(srcdir)/lock_sparcv8plus.il
$<
486 endif # SOLARIS_SUNPRO_CXX
488 # Allow building jsinterp.c with special optimization flags
489 ifdef INTERP_OPTIMIZER
490 jsinterp.
$(OBJ_SUFFIX
): MODULE_OPTIMIZE_FLAGS
=$(INTERP_OPTIMIZER
)
493 ifeq ($(OS_ARCH
),IRIX
)
495 _COMPILE_CFLAGS
= $(patsubst -O
%,-O1
,$(COMPILE_CFLAGS
))
496 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
498 @
$(MAKE_DEPS_AUTO_CXX
)
499 $(CXX
) -o
$@
-c
$(_COMPILE_CFLAGS
) $<
503 # An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
504 # This suppresses optimization for this single compilation unit.
505 ifeq ($(OS_ARCH
),AIX
)
506 jsatom.o
: jsatom.
cpp Makefile.in
508 @
$(MAKE_DEPS_AUTO_CXX
)
509 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
510 jsdtoa.o
: jsdtoa.
cpp Makefile.in
512 @
$(MAKE_DEPS_AUTO_CXX
)
513 $(CXX
) -o
$@
-c
$(filter-out $(MOZ_OPTIMIZE_FLAGS
), $(COMPILE_CFLAGS
)) $<
518 ifeq (,$(CROSS_COMPILE
)$(GNU_CC
)$(filter-out WINNT
,$(OS_ARCH
)))
522 ifeq ($(OS_ARCH
),WINCE
)
526 jsautocfg.h
: jscpucfg
$(HOST_BIN_SUFFIX
)
527 @
rm -f
$@ jsautocfg.tmp
528 .
/jscpucfg
> jsautocfg.tmp
533 # jscpucfg is a strange target
534 # Needs to be built with the host compiler but needs to include
535 # the mdcpucfg for the target so it needs the appropriate target defines
536 ifdef HOST_NSPR_MDCPUCFG
537 HOST_CXX
:= $(HOST_CXX
) -DMDCPUCFG
=$(TARGET_NSPR_MDCPUCFG
)
538 HOST_CXXFLAGS
:= $(patsubst -DXP_
%,,$(HOST_CXXFLAGS
))
542 # jscpucfg needs to know when it's supposed to produce a config for the target
543 JSCPUCFG_DEFINES
= $(ACDEFINES
)
546 ifeq ($(OS_ARCH
),QNX
)
547 ifneq ($(OS_TARGET
),NTO
)
548 # QNX's compiler apparently can't build a binary directly from a source file.
549 jscpucfg.o
: jscpucfg.
cpp Makefile.in
550 $(HOST_CXX
) $(HOST_CXXFLAGS
) -c
$(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) -o
$@
$<
553 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) -o
$@
$<
556 ifeq ($(OS_ARCH
),WINCE
)
557 jscpucfg
$(HOST_BIN_SUFFIX
):
558 echo no need to build jscpucfg
$<
560 jscpucfg
$(HOST_BIN_SUFFIX
): jscpucfg.
cpp Makefile.in
561 $(HOST_CXX
) $(HOST_CXXFLAGS
) $(JSCPUCFG_DEFINES
) $(DEFINES
) $(NSPR_CFLAGS
) $(HOST_OUTOPTION
)$@
$<
565 # Compute the linker flags that programs linking against SpiderMonkey should
566 # pass to get SpiderMonkey and its dependencies, beyond just the -L and -l
567 # for the SpiderMonkey library itself.
568 # - EXTRA_DSO_LDOPTS includes the NSPR -L and -l flags.
569 # - OS_LIBS includes libraries selected by the configure script.
570 # - EXTRA_LIBS includes libraries selected by this Makefile.
571 JS_CONFIG_LIBS
=$(EXTRA_DSO_LDOPTS
) $(OS_LIBS
) $(EXTRA_LIBS
)
573 # The configure script invokes this rule explicitly at configure time!
574 # It's important that js-config be ready by the time we're done
575 # configuring, because we may be running other configure scripts that
576 # would like to run js-config themselves, before js is built.
578 # This file and rules.mk go through a certain amount of work to decide
579 # which libraries to build, what to name them, and what flags to pass
580 # when linking them (and thus what flags its own clients must pass).
581 # All this information needs to go into the js-config script. To
582 # avoid trying to re-compute all that in the configure script, we just
583 # have the configure script generate this Makefile, and then invoke
586 js-config
: js-config.in Makefile
$(DEPTH
)/config
/autoconf.mk
$(topsrcdir
)/config
/config.mk
$(topsrcdir
)/config
/rules.mk
588 sed
< $< > js-config.tmp \
589 -e
's|$(at)prefix$(at)|$(prefix)|' \
590 -e
's|$(at)exec_prefix$(at)|$(exec_prefix)|' \
591 -e
's|$(at)includedir$(at)|$(includedir)|' \
592 -e
's|$(at)libdir$(at)|$(libdir)|' \
593 -e
's|$(at)MOZILLA_VERSION$(at)|$(MOZILLA_VERSION)|' \
594 -e
's|$(at)LIBRARY_NAME$(at)|$(LIBRARY_NAME)|' \
595 -e
's|$(at)NSPR_CFLAGS$(at)|$(NSPR_CFLAGS)|' \
596 -e
's|$(at)JS_CONFIG_LIBS$(at)|$(JS_CONFIG_LIBS)|' \
597 -e
's|$(at)MOZ_JS_LIBS$(at)|$(MOZ_JS_LIBS)|' \
598 && mv js-config.tmp
$@
&& chmod
+x
$@
601 SDK_BINARY
= js-config
603 install:: $(INSTALLED_HEADERS
)
604 $(SYSINSTALL
) $^
$(DESTDIR
)$(includedir)/$(MODULE
)
607 $(SYSINSTALL
) $^
$(DESTDIR
)$(bindir)
609 install:: $(LIBRARY
) $(SHARED_LIBRARY
) $(IMPORT_LIBRARY
)
611 $(SYSINSTALL
) $(LIBRARY
) $(DESTDIR
)$(libdir)
613 ifneq (,$(SHARED_LIBRARY
))
614 $(SYSINSTALL
) $(SHARED_LIBRARY
) $(DESTDIR
)$(libdir)
616 ifneq (,$(IMPORT_LIBRARY
))
617 $(SYSINSTALL
) $(IMPORT_LIBRARY
) $(DESTDIR
)$(libdir)
620 # Extra dependancies and rules for auto-generated headers
621 host_jskwgen.
$(OBJ_SUFFIX
): jsversion.h jskeyword.tbl
623 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
624 # previous build?) via VPATH when we're building in a separate tree.
625 $(CURDIR
)/jsautokw.h
: host_jskwgen
$(HOST_BIN_SUFFIX
)
626 .
/host_jskwgen
$(HOST_BIN_SUFFIX
) $@
628 host_jsoplengen.
$(OBJ_SUFFIX
): jsopcode.tbl
630 # Use CURDIR to avoid finding a jsautooplen.h in the source tree (from
631 # a previous build?) via VPATH when we're building in a separate tree.
632 $(CURDIR
)/jsautooplen.h
: host_jsoplengen
$(HOST_BIN_SUFFIX
)
633 .
/host_jsoplengen
$(HOST_BIN_SUFFIX
) $@
635 # Force auto-header generation before compiling any source that may use them
636 $(CPPSRCS
:%.
cpp=%.
$(OBJ_SUFFIX
)): $(CURDIR
)/jsautokw.h
$(CURDIR
)/jsautooplen.h
639 $(CURDIR
)/javascript-trace.h
: $(srcdir)/javascript-trace.d
640 dtrace
-h
-s
$(srcdir)/javascript-trace.d
-o javascript-trace.h.in
641 sed
's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
642 javascript-trace.h.in
> javascript-trace.h
644 # We can't automatically generate dependencies on auto-generated headers;
645 # we have to list them explicitly.
646 $(addsuffix .
$(OBJ_SUFFIX
),jsdtracef jsinterp jsobj
): $(CURDIR
)/javascript-trace.h
651 # If we don't have run-mozilla.sh *and* we're linking against NSPR, we don't
652 # know how to run the JS binary. Oh well
654 imacro_asm.js
: imacro_asm.js.in jsopcode.tbl
655 $(CC
) -c
-x c
-E
-P
-I
$(srcdir) $< > $@
657 GARBAGE
+= imacros.c.tmp imacro_asm.js
659 ifneq (,$(wildcard $(RUN_TEST_PROGRAM
))$(if
$(NSPR_LIBS
),,1))
660 libs
:: imacro_asm.js
$(srcdir)/imacros.jsasm
661 $(wildcard $(RUN_TEST_PROGRAM
)) $(DIST
)/bin
/js
$(BIN_SUFFIX
) $< $(srcdir)/imacros.jsasm
> imacros.c.tmp
662 @cmp
-s imacros.c.tmp
$(srcdir)/imacros.c.out || \
663 (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)
664 @echo
"imacros.c.out is up to date"
666 update-imacros
: imacros.c.tmp
667 cp
$< $(srcdir)/imacros.c.out
669 # Code for importing the nanojit subtree from its repository.
671 NANOJIT_CENTRAL_REV
=$(shell cat
$(srcdir)/nanojit-import-rev
)
672 NANOJIT_CENTRAL_REPO
=http
://hg.mozilla.org
/projects
/nanojit-central
673 NANOJIT_CENTRAL_LOCAL
=$(CURDIR
)/nanojit-central
674 CUR_REPO
=$(srcdir)/..
/..
677 rm -Rf
$(NANOJIT_CENTRAL_LOCAL
) import-splicemap import-revmap
678 hg clone
$(NANOJIT_CENTRAL_REPO
) $(NANOJIT_CENTRAL_LOCAL
)
679 python
$(srcdir)/find-child.py \
680 --src
=$(NANOJIT_CENTRAL_LOCAL
) \
682 --start
=$(NANOJIT_CENTRAL_REV
) \
683 --filemap
=$(srcdir)/nanojit-import-filemap \
685 hg convert
--config convert.hg.saverev
=True \
686 --config convert.hg.startrev
=`cut -d ' ' -f 1 import-splicemap` \
687 --filemap
=$(srcdir)/nanojit-import-filemap \
688 --splicemap
=import-splicemap \
689 $(NANOJIT_CENTRAL_LOCAL
) \
692 (cd
$(srcdir) && hg up
)
693 (cd
$(NANOJIT_CENTRAL_LOCAL
) && hg log
-r tip
--template
"{node}\n") >$(srcdir)/nanojit-import-rev
694 (cd
$(srcdir) && hg commit
--message
="Update nanojit-import-rev stamp." nanojit-import-rev
)
696 .PHONY
: update-imacros update-nanojit