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