Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / js / src / Makefile.in
blobb4eec90db5faf7871977ea265d04175cf33dc6a5
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
14 # License.
16 # The Original Code is Mozilla Communicator client code, released
17 # March 31, 1998.
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.
24 # Contributor(s):
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 *****
40 DEPTH = .
41 topsrcdir = @top_srcdir@
42 srcdir = @srcdir@
44 run_for_side_effects := $(shell echo "MAKE: $(MAKE)")
45 include $(DEPTH)/config/autoconf.mk
47 DIRS = config
49 ifdef DEHYDRA_PATH
50 DIRS += analysis-tests
51 endif
53 ifdef JS_NATIVE_EDITLINE
54 DIRS += editline
55 endif
57 # editline needs to get built before the shell
58 ifndef JS_DISABLE_SHELL
59 DIRS += shell
60 endif
62 # FIXME: bug 515383 covers getting these working on wince
63 # bug 530688 covers Android
64 ifneq (,$(filter-out WINCE ANDROID,$(OS_ARCH)))
65 ifdef ENABLE_TESTS
66 DIRS += jsapi-tests
67 endif
68 endif
70 ifdef ENABLE_TESTS
71 DIRS += tests
72 endif
74 MODULE = js
75 LIBRARY_NAME = mozjs
76 STATIC_LIBRARY_NAME = js_static
77 GRE_MODULE = 1
79 LIBS = $(NSPR_LIBS)
81 ifdef GNU_CXX
82 ifdef INTEL_CXX
83 # icc gets special optimize flags
84 ifdef MOZ_PROFILE_GENERATE
85 MODULE_OPTIMIZE_FLAGS = -O0
86 else
87 MODULE_OPTIMIZE_FLAGS = -O2 -ip
88 endif
89 else # not INTEL_CXX
91 MODULE_OPTIMIZE_FLAGS = -O3 -fstrict-aliasing
93 # We normally want -fomit-frame-pointer, but we want an explicit
94 # -fno-omit-frame-pointer if we're using a sampling profiler.
95 ifndef MOZ_PROFILING
96 MODULE_OPTIMIZE_FLAGS += -fomit-frame-pointer
97 else
98 MODULE_OPTIMIZE_FLAGS += -fno-omit-frame-pointer
99 endif
101 endif
102 else # not GNU_CXX
103 ifeq ($(OS_ARCH),SunOS)
104 MODULE_OPTIMIZE_FLAGS = -xO4
105 endif
106 ifeq ($(OS_ARCH),WINNT)
107 MODULE_OPTIMIZE_FLAGS = -O2
108 endif
109 endif
112 # JavaScript must be built shared, even for static builds, as it is used by
113 # other modules which are always built shared. Failure to do so results in
114 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
115 # and then the static data cells used for locking no longer work.
117 # In fact, we now build both a static and a shared library, as the
118 # JS shell would like to link to the static library.
120 ifdef JS_SHARED_LIBRARY
121 FORCE_SHARED_LIB = 1
122 endif
123 FORCE_STATIC_LIB = 1
124 DIST_INSTALL = 1
126 VPATH = $(srcdir)
128 CPPSRCS = \
129 jsanalyze.cpp \
130 jsapi.cpp \
131 jsarena.cpp \
132 jsarray.cpp \
133 jsatom.cpp \
134 jsbool.cpp \
135 jsclone.cpp \
136 jscntxt.cpp \
137 jscompartment.cpp \
138 jsdate.cpp \
139 jsdbgapi.cpp \
140 jsdhash.cpp \
141 jsdtoa.cpp \
142 jsemit.cpp \
143 jsexn.cpp \
144 jsfriendapi.cpp \
145 jsfun.cpp \
146 jsgc.cpp \
147 jsgcchunk.cpp \
148 jsgcstats.cpp \
149 jshash.cpp \
150 jsinterp.cpp \
151 jsinvoke.cpp \
152 jsiter.cpp \
153 jslock.cpp \
154 jslog2.cpp \
155 jsmath.cpp \
156 jsnativestack.cpp \
157 jsnum.cpp \
158 jsobj.cpp \
159 json.cpp \
160 jsopcode.cpp \
161 jsparse.cpp \
162 jsproxy.cpp \
163 jsprf.cpp \
164 jsprobes.cpp \
165 jspropertycache.cpp \
166 jspropertytree.cpp \
167 jsreflect.cpp \
168 jsregexp.cpp \
169 jsscan.cpp \
170 jsscope.cpp \
171 jsscript.cpp \
172 jsstr.cpp \
173 jstypedarray.cpp \
174 jsutil.cpp \
175 jswrapper.cpp \
176 jsxdrapi.cpp \
177 jsxml.cpp \
178 prmjtime.cpp \
179 sharkctl.cpp \
180 $(NULL)
182 INSTALLED_HEADERS = \
183 js-config.h \
184 jsautocfg.h \
185 $(CURDIR)/jsautokw.h \
186 js.msg \
187 jsanalyze.h \
188 jsapi.h \
189 jsarray.h \
190 jsarena.h \
191 jsatom.h \
192 jsbit.h \
193 jsbool.h \
194 jsclist.h \
195 jsclone.h \
196 jscntxt.h \
197 jscompat.h \
198 jsdate.h \
199 jsdbgapi.h \
200 jsdhash.h \
201 jsdtoa.h \
202 jsemit.h \
203 jsfun.h \
204 jsfriendapi.h \
205 jsgc.h \
206 jscell.h \
207 jsgcchunk.h \
208 jsgcstats.h \
209 jscompartment.h \
210 jshash.h \
211 jsinterp.h \
212 jsinttypes.h \
213 jsiter.h \
214 jslock.h \
215 jslong.h \
216 jsmath.h \
217 jsobj.h \
218 jsobjinlines.h \
219 json.h \
220 jsopcode.tbl \
221 jsopcode.h \
222 jsopcodeinlines.h \
223 jsotypes.h \
224 jsparse.h \
225 jsproxy.h \
226 jsprf.h \
227 jsprobes.h \
228 jspropertycache.h \
229 jspropertycacheinlines.h \
230 jspropertytree.h \
231 jsproto.tbl \
232 jsprvtd.h \
233 jspubtd.h \
234 jsreflect.h \
235 jsregexp.h \
236 jsscan.h \
237 jsscope.h \
238 jsscript.h \
239 jsscriptinlines.h \
240 jsstaticcheck.h \
241 jsstdint.h \
242 jsstr.h \
243 jstracer.h \
244 jshotloop.h \
245 jstypedarray.h \
246 jstypes.h \
247 jsutil.h \
248 jsvector.h \
249 jstl.h \
250 jshashtable.h \
251 jsversion.h \
252 jswrapper.h \
253 jsxdrapi.h \
254 jsxml.h \
255 jsval.h \
256 jsvalue.h \
257 prmjtime.h \
258 $(NULL)
260 ifdef ENABLE_TRACEJIT
261 VPATH += \
262 $(srcdir)/tracejit \
263 $(srcdir)/nanojit \
265 INSTALLED_HEADERS += \
266 jsbuiltins.h \
267 Assembler.h \
268 Allocator.h \
269 CodeAlloc.h \
270 Containers.h \
271 LIR.h \
272 LIRopcode.tbl \
273 avmplus.h \
274 Fragmento.h \
275 Native.h \
276 NativeCommon.h \
277 Native$(NANOJIT_ARCH).h \
278 njconfig.h \
279 njcpudetect.h \
280 RegAlloc.h \
281 nanojit.h \
282 VMPI.h \
283 Writer.h \
284 $(NULL)
286 CPPSRCS += \
287 jstracer.cpp \
288 Assembler.cpp \
289 Allocator.cpp \
290 CodeAlloc.cpp \
291 Containers.cpp \
292 Fragmento.cpp \
293 LIR.cpp \
294 njconfig.cpp \
295 RegAlloc.cpp \
296 avmplus.cpp \
297 Native$(NANOJIT_ARCH).cpp \
298 jsbuiltins.cpp \
299 VMPI.cpp \
300 Writer.cpp \
301 $(NULL)
303 ifdef WINCE
304 # don't need -c
305 AS_DASH_C_FLAG =
306 ASFLAGS += -arch 6
307 ASFILES += jswince.asm
308 endif
310 endif # ENABLE_TRACEJIT
311 ifdef ENABLE_METHODJIT
313 ###############################################
314 # BEGIN include sources for the method JIT
316 VPATH += $(srcdir)/methodjit
318 CPPSRCS += MethodJIT.cpp \
319 StubCalls.cpp \
320 Compiler.cpp \
321 FrameState.cpp \
322 FastArithmetic.cpp \
323 FastOps.cpp \
324 StubCompiler.cpp \
325 MonoIC.cpp \
326 PolyIC.cpp \
327 ImmutableSync.cpp \
328 InvokeHelpers.cpp \
329 Retcon.cpp \
330 TrampolineCompiler.cpp \
331 $(NULL)
332 # PICStubCompiler.cpp \
334 ifeq (86, $(findstring 86,$(TARGET_CPU)))
335 ifeq (x86_64, $(TARGET_CPU))
336 ifdef _MSC_VER
337 ASFILES += TrampolineMasmX64.asm
338 endif
339 ifdef SOLARIS_SUNPRO_CXX
340 ASFILES += TrampolineSUNWX64.s
341 endif
342 #CPPSRCS += only_on_x86_64.cpp
343 else
344 #CPPSRCS += only_on_x86.cpp
345 ifdef SOLARIS_SUNPRO_CXX
346 ASFILES += TrampolineSUNWX86.s
347 endif
348 endif
349 endif
350 ifeq (arm, $(TARGET_CPU))
351 #CPPSRCS += only_on_arm.cpp
352 endif
354 # END enclude sources for the method JIT
355 #############################################
357 endif
359 ###############################################
360 # BEGIN include sources for V8 dtoa
362 VPATH += $(srcdir)/v8-dtoa \
363 $(NONE)
365 CPPSRCS += checks.cc \
366 conversions.cc \
367 diy-fp.cc \
368 v8-dtoa.cc \
369 fast-dtoa.cc \
370 platform.cc \
371 utils.cc \
372 $(NONE)
375 # END enclude sources for V8 dtoa
376 #############################################
378 ifeq (,$(filter-out powerpc sparc,$(TARGET_CPU)))
380 VPATH += $(srcdir)/assembler \
381 $(srcdir)/assembler/wtf \
382 $(srcdir)/yarr/pcre \
383 $(NULL)
385 CPPSRCS += pcre_compile.cpp \
386 pcre_exec.cpp \
387 pcre_tables.cpp \
388 pcre_xclass.cpp \
389 pcre_ucp_searchfuncs.cpp \
390 $(NULL)
391 else
393 ###############################################
394 # BEGIN include sources for the Nitro assembler
396 VPATH += $(srcdir)/assembler \
397 $(srcdir)/assembler/wtf \
398 $(srcdir)/assembler/jit \
399 $(srcdir)/assembler/assembler \
400 $(srcdir)/methodjit \
401 $(srcdir)/yarr \
402 $(srcdir)/yarr/yarr \
403 $(srcdir)/yarr/pcre \
404 $(srcdir)/yarr/wtf \
405 $(NONE)
407 CPPSRCS += Assertions.cpp \
408 ExecutableAllocatorPosix.cpp \
409 ExecutableAllocatorWin.cpp \
410 ExecutableAllocatorOS2.cpp \
411 ExecutableAllocator.cpp \
412 ARMAssembler.cpp \
413 Logging.cpp \
414 MacroAssemblerARM.cpp \
415 MacroAssemblerX86Common.cpp \
416 RegexCompiler.cpp \
417 RegexJIT.cpp \
418 pcre_compile.cpp \
419 pcre_exec.cpp \
420 pcre_tables.cpp \
421 pcre_xclass.cpp \
422 pcre_ucp_searchfuncs.cpp \
423 $(NONE)
425 ifeq (86, $(findstring 86,$(TARGET_CPU)))
426 ifeq (x86_64, $(TARGET_CPU))
427 #CPPSRCS += only_on_x86_64.cpp
428 else
429 #CPPSRCS += only_on_x86.cpp
430 endif
431 endif
432 ifeq (arm, $(TARGET_CPU))
433 #CPPSRCS += only_on_arm.cpp
434 endif
436 # END enclude sources for the Nitro assembler
437 #############################################
439 endif
441 ifdef JS_HAS_CTYPES
442 VPATH += $(srcdir)/ctypes
444 CPPSRCS += \
445 CTypes.cpp \
446 Library.cpp \
447 $(NULL)
449 LOCAL_INCLUDES = \
450 -Ictypes/libffi/include \
451 -I. \
452 $(NULL)
454 ifeq ($(OS_ARCH),OS2)
455 SHARED_LIBRARY_LIBS += \
456 ctypes/libffi/.libs/ffi.a \
457 $(NULL)
458 else
459 SHARED_LIBRARY_LIBS += \
460 ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \
461 $(NULL)
462 endif
464 endif # JS_HAS_CTYPES
466 ifdef HAVE_DTRACE
467 INSTALLED_HEADERS += \
468 $(CURDIR)/javascript-trace.h \
469 $(NULL)
470 endif
472 # PerfMeasurement is available regardless of low-level support for it;
473 # it just doesn't necessarily do anything useful. There is one
474 # implementation source file per supported operating system, plus a stub
475 # for unsupported OSes, plus the Javascript wrapper.
476 VPATH += $(srcdir)/perf
477 INSTALLED_HEADERS += jsperf.h
478 CPPSRCS += jsperf.cpp
479 ifdef HAVE_LINUX_PERF_EVENT_H
480 CPPSRCS += pm_linux.cpp
481 else
482 CPPSRCS += pm_stub.cpp
483 endif
485 ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
486 INSTALLED_HEADERS += jscpucfg.h
487 endif
489 EXPORTS = $(INSTALLED_HEADERS)
491 DASH_R = -r
493 ifneq (,$(filter OS2 WINCE WINNT,$(OS_ARCH)))
494 SDK_LIBRARY = $(IMPORT_LIBRARY)
495 else
496 SDK_LIBRARY = $(SHARED_LIBRARY)
497 endif
499 include $(topsrcdir)/config/config.mk
501 EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
503 ifndef BUILD_OPT
504 MOCHAFILE = 1
505 endif
507 # Define keyword generator before rules.mk, see bug 323979 comment 50
509 HOST_SIMPLE_PROGRAMS += host_jskwgen$(HOST_BIN_SUFFIX)
510 GARBAGE += jsautokw.h host_jskwgen$(HOST_BIN_SUFFIX)
512 HOST_SIMPLE_PROGRAMS += host_jsoplengen$(HOST_BIN_SUFFIX)
513 GARBAGE += jsautooplen.h host_jsoplengen$(HOST_BIN_SUFFIX)
515 USE_HOST_CXX = 1
517 ifdef HAVE_DTRACE
518 ifneq ($(OS_ARCH),Darwin)
519 DTRACE_PROBE_OBJ = $(LIBRARY_NAME)-dtrace.$(OBJ_SUFFIX)
520 endif
521 MOZILLA_DTRACE_SRC = $(srcdir)/javascript-trace.d
522 endif
524 default::
526 ifneq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH)))
527 ifneq (,$(filter-out SYMBIAN WINCE,$(OS_ARCH)))
528 # nsinstall doesn't get built until we enter config/ in the exports phase,
529 # so we'll have to manually ensure it gets built here if we want to use
530 # $(EXPORTS)
531 export:: config/nsinstall$(HOST_BIN_SUFFIX)
532 $(PUBLIC) $(SDK_PUBLIC): config/nsinstall$(HOST_BIN_SUFFIX)
534 config/nsinstall$(HOST_BIN_SUFFIX): $(srcdir)/config/nsinstall.c $(srcdir)/config/pathsub.c
535 $(MAKE) -C config/ nsinstall$(HOST_BIN_SUFFIX)
536 endif
537 endif
539 include $(topsrcdir)/config/rules.mk
541 ifdef JS_HAS_CTYPES
542 # Build libffi proper as part of the 'exports' target, so things get built
543 # in the right order.
544 export::
545 $(call SUBMAKE,,ctypes/libffi)
547 distclean clean::
548 $(call SUBMAKE,$@,ctypes/libffi)
549 endif
551 ifdef MOZ_SYNC_BUILD_FILES
552 # Because the SpiderMonkey can be distributed and built independently
553 # of the Mozilla source tree, it contains its own copies of many of
554 # the files used by the top-level Mozilla build process, from the
555 # 'config' and 'build' subtrees.
557 # To make it simpler to keep the copies in sync, we follow the policy
558 # that the SpiderMonkey copies must always be exact copies of those in
559 # the containing Mozilla tree. If you've made a change in one, it
560 # belongs in the other as well. If the change isn't right for both
561 # places, then that's something to bring up with the other developers.
563 # Some files are reasonable to diverge; for example,
564 # js/config/autoconf.mk.in doesn't need most of the stuff in
565 # config/autoconf.mk.in.
566 check-sync-dirs = $(PYTHON) $(srcdir)/config/check-sync-dirs.py
567 check::
568 $(check-sync-dirs) $(srcdir)/config $(MOZ_SYNC_BUILD_FILES)/config
569 $(check-sync-dirs) $(srcdir)/build $(MOZ_SYNC_BUILD_FILES)/build
571 check-valgrind::
572 $(check-sync-dirs) $(srcdir)/config $(MOZ_SYNC_BUILD_FILES)/config
573 $(check-sync-dirs) $(srcdir)/build $(MOZ_SYNC_BUILD_FILES)/build
574 endif
576 # The "find any vanilla new/new[] calls" script is tailored to Linux, so
577 # only run it there. That should be enough to catch any such calls that
578 # creep in.
579 ifeq ($(OS_ARCH),Linux)
580 check::
581 $(srcdir)/config/find_vanilla_new_calls $(LIBRARY)
582 endif
584 ifdef ENABLE_TRACEJIT
585 ifndef WINCE
586 check::
587 $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/jit-test/jit_test.py \
588 --no-slow --no-progress --tinderbox --jitflags=m,j,mj,mjp,mjd $(DIST)/bin/js$(BIN_SUFFIX)
590 check-valgrind::
591 $(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(srcdir)/jit-test/jit_test.py \
592 --valgrind --no-slow --no-progress --tinderbox --jitflags=m,j,mj,mjp,mjd $(DIST)/bin/js$(BIN_SUFFIX)
593 endif
594 endif
596 DIST_GARBAGE = config.cache config.log config.status \
597 config/autoconf.mk \
598 unallmakefiles js-config js-config.h js-confdefs.h
600 distclean::
601 cat unallmakefiles | $(XARGS) rm -f
602 rm -f $(DIST_GARBAGE)
604 # our build system doesn't handle subdir srcs very gracefully today
605 export::
606 mkdir -p nanojit
608 DEFINES += -DEXPORT_JS_API
610 # Some platforms that have stdint.h include it in system headers. So
611 # to reliably get limit macros defined, we'd always have to define the
612 # one below before including any header, but that's obscure and
613 # fragile, so we do it here.
614 DEFINES += -D__STDC_LIMIT_MACROS
616 INCLUDES += -I$(srcdir)
618 GARBAGE += jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg
620 ifneq (,$(CROSS_COMPILE)$(filter-out WINNT,$(OS_ARCH)))
621 TARGETS += jscpucfg$(HOST_BIN_SUFFIX)
622 endif
624 ifdef JS_THREADSAFE
625 DEFINES += -DJS_THREADSAFE
626 endif
628 ifdef JS_HAS_CTYPES
629 DEFINES += -DJS_HAS_CTYPES
630 DEFINES += -DDLL_PREFIX=\"$(DLL_PREFIX)\" -DDLL_SUFFIX=\"$(DLL_SUFFIX)\"
631 endif
633 ifdef JS_NO_THIN_LOCKS
634 DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
635 endif
637 ifdef JS_VERSION
638 DEFINES += -DJS_VERSION=$(JS_VERSION)
639 endif
641 ifneq ($(findstring -L,$(NSPR_LIBS)),)
642 NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
643 else
644 NSPR_STATIC_PATH = $(DIST)/lib
645 endif
647 ifdef MOZ_VTUNE
648 CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
649 EXTRA_DSO_LDOPTS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
650 LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
651 endif
653 # BeOS and HP-UX do not require the extra linking of "-lm"
654 ifeq (,$(filter BeOS HP-UX WINNT WINCE OpenVMS OS2,$(OS_ARCH)))
655 EXTRA_LIBS += -lm
656 endif
658 # Prevent floating point errors caused by VC++ optimizations
659 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
660 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
661 CFLAGS += -Op
662 else
663 CFLAGS += -fp:precise
664 endif
665 endif # WINNT
667 ifeq ($(OS_ARCH),FreeBSD)
668 EXTRA_LIBS += -pthread
669 endif
670 ifeq ($(OS_ARCH),IRIX)
671 ifdef USE_N32
672 DASH_R += -n32
673 endif
674 endif
675 ifeq ($(OS_ARCH),Linux)
676 EXTRA_LIBS += -ldl
677 endif
678 ifeq ($(OS_ARCH),OSF1)
679 EXTRA_LIBS += -lc_r
680 endif
681 ifeq ($(OS_ARCH),SunOS)
682 ifeq ($(TARGET_CPU),sparc)
684 ifdef GNU_CC
685 CFLAGS += -mcpu=v9
686 CXXFLAGS += -mcpu=v9
687 endif # GNU_CC
689 endif
690 ifeq ($(OS_RELEASE),4.1)
691 EXTRA_LIBS += -ldl -lnsl
692 else
693 EXTRA_LIBS += -lposix4 -ldl -lnsl -lsocket
694 endif
695 endif
697 ifdef MOZ_MEMORY
698 ifeq ($(OS_ARCH),Darwin)
699 LDFLAGS += -ljemalloc
700 endif
701 endif
703 ifdef SOLARIS_SUNPRO_CXX
704 ifeq ($(TARGET_CPU),sparc)
705 # Sun Studio SPARC doesn't work well with gcc inline asm, use lock_SunOS_sparc*.il
706 jslock.o: jslock.cpp Makefile.in lock_sparcv8plus.il lock_sparcv9.il
707 $(REPORT_BUILD)
708 @$(MAKE_DEPS_AUTO_CXX)
709 ifeq (sparcv9,$(findstring sparcv9,$(OS_TEST)))
710 $(CXX) -o $@ -c $(COMPILE_CFLAGS) $(srcdir)/lock_sparcv9.il $<
711 else
712 $(CXX) -o $@ -c $(COMPILE_CFLAGS) $(srcdir)/lock_sparcv8plus.il $<
713 endif # sparcv9
714 endif # sparc
715 endif # SOLARIS_SUNPRO_CXX
717 ifeq ($(OS_ARCH),IRIX)
718 ifndef GNU_CC
719 _COMPILE_CFLAGS = $(patsubst -O%,-O1,$(COMPILE_CFLAGS))
720 jsapi.o jsxdrapi.o jsarena.o jsarray.o jsatom.o jsemit.o jsfun.o jsinterp.o jsreflect.o jsregexp.o jsparse.o jsopcode.o jsscript.o: %.o: %.cpp Makefile.in
721 $(REPORT_BUILD)
722 @$(MAKE_DEPS_AUTO_CXX)
723 $(CXX) -o $@ -c $(_COMPILE_CFLAGS) $<
724 endif
725 endif
727 # An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
728 # This suppresses optimization for this single compilation unit.
729 ifeq ($(OS_ARCH),AIX)
730 jsatom.o: jsatom.cpp Makefile.in
731 $(REPORT_BUILD)
732 @$(MAKE_DEPS_AUTO_CXX)
733 $(CXX) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
734 jsdtoa.o: jsdtoa.cpp Makefile.in
735 $(REPORT_BUILD)
736 @$(MAKE_DEPS_AUTO_CXX)
737 $(CXX) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
738 endif
740 export:: jsautocfg.h
742 ifeq (,$(CROSS_COMPILE)$(GNU_CC)$(filter-out WINNT,$(OS_ARCH)))
743 jsautocfg.h:
744 touch $@
745 else
746 ifeq ($(OS_ARCH),WINCE)
747 jsautocfg.h:
748 touch $@
749 else
750 jsautocfg.h: jscpucfg$(HOST_BIN_SUFFIX)
751 @rm -f $@ jsautocfg.tmp
752 ./jscpucfg > jsautocfg.tmp
753 mv jsautocfg.tmp $@
754 endif
755 endif
757 # jscpucfg is a strange target
758 # Needs to be built with the host compiler but needs to include
759 # the mdcpucfg for the target so it needs the appropriate target defines
760 ifdef HOST_NSPR_MDCPUCFG
761 HOST_CXX := $(HOST_CXX) -DMDCPUCFG=$(TARGET_NSPR_MDCPUCFG)
762 HOST_CXXFLAGS := $(patsubst -DXP_%,,$(HOST_CXXFLAGS))
763 endif
765 ifdef CROSS_COMPILE
766 # jscpucfg needs to know when it's supposed to produce a config for the target
767 JSCPUCFG_DEFINES = $(ACDEFINES)
768 endif
770 ifeq ($(OS_ARCH),QNX)
771 ifneq ($(OS_TARGET),NTO)
772 # QNX's compiler apparently can't build a binary directly from a source file.
773 jscpucfg.o: jscpucfg.cpp Makefile.in
774 $(HOST_CXX) $(HOST_CXXFLAGS) -c $(JSCPUCFG_DEFINES) $(DEFINES) $(NSPR_CFLAGS) -o $@ $<
776 jscpucfg: jscpucfg.o
777 $(HOST_CXX) $(HOST_CXXFLAGS) $(JSCPUCFG_DEFINES) $(DEFINES) -o $@ $<
778 endif
779 else
780 ifeq ($(OS_ARCH),WINCE)
781 jscpucfg$(HOST_BIN_SUFFIX):
782 echo no need to build jscpucfg $<
783 else
784 jscpucfg$(HOST_BIN_SUFFIX): jscpucfg.cpp Makefile.in
785 $(HOST_CXX) $(HOST_CXXFLAGS) $(JSCPUCFG_DEFINES) $(DEFINES) $(NSPR_CFLAGS) $(HOST_OUTOPTION)$@ $<
786 endif
787 endif
789 # Compute the linker flags that programs linking against SpiderMonkey should
790 # pass to get SpiderMonkey and its dependencies, beyond just the -L and -l
791 # for the SpiderMonkey library itself.
792 # - EXTRA_DSO_LDOPTS includes the NSPR -L and -l flags.
793 # - OS_LIBS includes libraries selected by the configure script.
794 # - EXTRA_LIBS includes libraries selected by this Makefile.
795 JS_CONFIG_LIBS=$(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS)
797 # The configure script invokes this rule explicitly at configure time!
798 # It's important that js-config be ready by the time we're done
799 # configuring, because we may be running other configure scripts that
800 # would like to run js-config themselves, before js is built.
802 # This file and rules.mk go through a certain amount of work to decide
803 # which libraries to build, what to name them, and what flags to pass
804 # when linking them (and thus what flags its own clients must pass).
805 # All this information needs to go into the js-config script. To
806 # avoid trying to re-compute all that in the configure script, we just
807 # have the configure script generate this Makefile, and then invoke
808 # this rule.
809 at=@
810 js-config: js-config.in Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk $(topsrcdir)/config/rules.mk
811 rm -f js-config.tmp
812 sed < $< > js-config.tmp \
813 -e 's|$(at)prefix$(at)|$(prefix)|' \
814 -e 's|$(at)exec_prefix$(at)|$(exec_prefix)|' \
815 -e 's|$(at)includedir$(at)|$(includedir)|' \
816 -e 's|$(at)libdir$(at)|$(libdir)|' \
817 -e 's|$(at)MOZILLA_VERSION$(at)|$(MOZILLA_VERSION)|' \
818 -e 's|$(at)LIBRARY_NAME$(at)|$(LIBRARY_NAME)|' \
819 -e 's|$(at)NSPR_CFLAGS$(at)|$(NSPR_CFLAGS)|' \
820 -e 's|$(at)JS_CONFIG_LIBS$(at)|$(JS_CONFIG_LIBS)|' \
821 -e 's|$(at)MOZ_JS_LIBS$(at)|$(MOZ_JS_LIBS)|' \
822 && mv js-config.tmp $@ && chmod +x $@
824 SCRIPTS = js-config
825 SDK_BINARY = js-config
827 install:: $(INSTALLED_HEADERS)
828 $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE)
830 install:: $(SCRIPTS)
831 $(SYSINSTALL) $^ $(DESTDIR)$(bindir)
833 install:: $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
834 ifneq (,$(LIBRARY))
835 $(SYSINSTALL) $(LIBRARY) $(DESTDIR)$(libdir)
836 endif
837 ifneq (,$(SHARED_LIBRARY))
838 $(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir)
839 endif
840 ifneq (,$(IMPORT_LIBRARY))
841 $(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir)
842 endif
844 # Extra dependancies and rules for auto-generated headers
845 host_jskwgen.$(OBJ_SUFFIX): jsversion.h jskeyword.tbl
847 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
848 # previous build?) via VPATH when we're building in a separate tree.
849 $(CURDIR)/jsautokw.h: host_jskwgen$(HOST_BIN_SUFFIX)
850 ./host_jskwgen$(HOST_BIN_SUFFIX) $@
852 host_jsoplengen.$(OBJ_SUFFIX): jsopcode.tbl
854 # Use CURDIR to avoid finding a jsautooplen.h in the source tree (from
855 # a previous build?) via VPATH when we're building in a separate tree.
856 $(CURDIR)/jsautooplen.h: host_jsoplengen$(HOST_BIN_SUFFIX)
857 ./host_jsoplengen$(HOST_BIN_SUFFIX) $@
859 # Force auto-header generation before compiling any source that may use them
860 $(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:%.cpp=%.$(OBJ_SUFFIX))): $(CURDIR)/jsautokw.h $(CURDIR)/jsautooplen.h
862 ifdef HAVE_DTRACE
863 $(CURDIR)/javascript-trace.h: $(srcdir)/javascript-trace.d
864 dtrace -h -s $(srcdir)/javascript-trace.d -o javascript-trace.h.in
865 sed -e 's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
866 -e '/const/!s/char \*/const char */g' \
867 javascript-trace.h.in > javascript-trace.h
869 # We can't automatically generate dependencies on auto-generated headers;
870 # we have to list them explicitly.
871 $(addsuffix .$(OBJ_SUFFIX),jsprobes jsinterp jsobj): $(CURDIR)/javascript-trace.h
872 endif
874 ifdef ENABLE_TRACEJIT
875 # Imacro compilation.
876 $(CURDIR)/imacros.c.out: $(srcdir)/imacro_asm.py $(srcdir)/imacros.jsasm jsopcode.tbl
877 $(PYTHON) $< $(srcdir)/imacros.jsasm $(CURDIR)/imacros.c.out
878 $(addsuffix .$(OBJ_SUFFIX),jstracer): $(CURDIR)/imacros.c.out
880 # Code for importing the nanojit subtree from its repository.
881 NANOJIT_CENTRAL_REV=$(shell cat $(srcdir)/nanojit-import-rev)
882 NANOJIT_CENTRAL_REPO=http://hg.mozilla.org/projects/nanojit-central
883 NANOJIT_CENTRAL_LOCAL=$(CURDIR)/nanojit-central
884 CUR_REPO=$(srcdir)/../..
886 update-nanojit:
887 rm -Rf $(NANOJIT_CENTRAL_LOCAL) import-splicemap import-revmap
888 hg clone $(NANOJIT_CENTRAL_REPO) $(NANOJIT_CENTRAL_LOCAL)
889 python $(srcdir)/find-child.py \
890 --src=$(NANOJIT_CENTRAL_LOCAL) \
891 --dst=$(CUR_REPO) \
892 --start=$(NANOJIT_CENTRAL_REV) \
893 --filemap=$(srcdir)/nanojit-import-filemap \
894 >import-splicemap
895 hg convert --config convert.hg.saverev=True \
896 --config convert.hg.startrev=`cut -d ' ' -f 1 import-splicemap` \
897 --filemap=$(srcdir)/nanojit-import-filemap \
898 --splicemap=import-splicemap \
899 $(NANOJIT_CENTRAL_LOCAL) \
900 $(CUR_REPO) \
901 import-revmap
902 (cd $(srcdir) && hg up)
903 (cd $(NANOJIT_CENTRAL_LOCAL) && hg log -r tip --template "{node}\n") >$(srcdir)/nanojit-import-rev
904 (cd $(srcdir) && hg commit --message="Update nanojit-import-rev stamp." nanojit-import-rev)
906 .PHONY: update-nanojit
907 endif
909 ###############################################
910 # BEGIN kludges for the Nitro assembler
913 # Needed to "configure" it correctly. Unfortunately these
914 # flags wind up being applied to all code in js/src, not just
915 # the code in js/src/assembler.
916 CXXFLAGS += -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -DENABLE_JIT=1
918 INCLUDES += -I$(srcdir)/assembler -I$(srcdir)/yarr
920 ifdef ENABLE_METHODJIT
921 # Build a standalone test program that exercises the assembler
922 # sources a bit.
923 TESTMAIN_OBJS = \
924 Assertions.$(OBJ_SUFFIX) \
925 ExecutableAllocatorPosix.$(OBJ_SUFFIX) \
926 ExecutableAllocatorWin.$(OBJ_SUFFIX) \
927 ExecutableAllocator.$(OBJ_SUFFIX) \
928 ARMAssembler.$(OBJ_SUFFIX) \
929 MacroAssemblerARM.$(OBJ_SUFFIX) \
930 TestMain.$(OBJ_SUFFIX) \
931 jsutil.$(OBJ_SUFFIX) \
932 jslog2.$(OBJ_SUFFIX)
933 TestMain$(HOST_BIN_SUFFIX): $(TESTMAIN_OBJS)
934 $(CXX) -o TestMain$(HOST_BIN_SUFFIX) $(TESTMAIN_OBJS)
935 endif
938 # END kludges for the Nitro assembler
939 ###############################################