1 # -*- Mode: makefile -*-
4 # ***** BEGIN LICENSE BLOCK *****
5 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 # The contents of this file are subject to the Mozilla Public License Version
8 # 1.1 (the "License"); you may not use this file except in compliance with
9 # the License. You may obtain a copy of the License at
10 # http://www.mozilla.org/MPL/
12 # Software distributed under the License is distributed on an "AS IS" basis,
13 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 # for the specific language governing rights and limitations under the
17 # The Original Code is Mozilla Communicator client code, released
20 # The Initial Developer of the Original Code is
21 # Netscape Communications Corporation.
22 # Portions created by the Initial Developer are Copyright (C) 1998
23 # the Initial Developer. All Rights Reserved.
26 # Michael Ang <mang@subcarrier.org>
27 # Kevin Buhr <buhr@stat.wisc.edu>
29 # Alternatively, the contents of this file may be used under the terms of
30 # either of the GNU General Public License Version 2 or later (the "GPL"),
31 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 # in which case the provisions of the GPL or the LGPL are applicable instead
33 # of those above. If you wish to allow use of your version of this file only
34 # under the terms of either the GPL or the LGPL, and not to allow others to
35 # use your version of this file under the terms of the MPL, indicate your
36 # decision by deleting the provisions above and replace them with the notice
37 # and other provisions required by the GPL or the LGPL. If you do not delete
38 # the provisions above, a recipient may use your version of this file under
39 # the terms of any one of the MPL, the GPL or the LGPL.
41 # ***** END LICENSE BLOCK *****
44 # JSRef GNUmake makefile.
46 # Note: dependency rules are missing for some files (some
47 # .h, all .msg, etc.) Re-make clean if in doubt.
58 $(warning NANOJIT_ARCH not defined in config/$(OS_CONFIG).mk, JIT disabled)
61 $(warning disabling JIT per build specification)
68 DEFINES += -DJS_TRACER
69 DEFINES += -DFEATURE_NANOJIT
78 DEFINES += -DNARCISSUS
81 # Look in OBJDIR to find jsautocfg.h, jsautokw.h, and js-config.h
82 INCLUDES += -I. -I$(OBJDIR)
85 DEFINES += -DJS_THREADSAFE
86 INCLUDES += -I$(DIST)/include/nspr
88 OTHER_LIBS += $(DIST)/lib/libnspr$(NSPR_LIBSUFFIX).lib
90 OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX)
94 ifdef JS_NO_THIN_LOCKS
95 DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
98 ifdef JS_HAS_FILE_OBJECT
99 DEFINES += -DJS_HAS_FILE_OBJECT
103 DEFINES += -DJS_GC_ZEAL
107 # XCFLAGS may be set in the environment or on the gmake command line
109 #CFLAGS += -DDEBUG -DDEBUG_brendan -DJS_ARENAMETER -DJS_HASHMETER -DJS_DUMP_PROPTREE_STATS -DJS_DUMP_SCOPE_METERS -DJS_SCOPE_DEPTH_METER -DJS_BASIC_STATS
110 CFLAGS += $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
112 LDFLAGS = $(XLDFLAGS)
113 LDFLAGS += $(OS_LDFLAGS)
116 DEFINES += -DMOZ_SHARK
117 CFLAGS += -F/System/Library/PrivateFrameworks
118 LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
121 DEFINES += -DMOZ_CALLGRIND
124 DEFINES += -DMOZ_VTUNE
125 CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
126 OTHER_LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
133 # Prevent floating point errors caused by VC++ optimizations
134 ifeq ($(OS_ARCH),WINNT)
135 _MSC_VER = $(shell $(CXX) 2>&1 | sed -n 's/.*Compiler Version \([0-9]*\)\.\([0-9]*\).*/\1\2/p')
136 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
139 CFLAGS += -fp:precise
144 # Server-related changes :
151 # Line editing support.
152 # Define JS_READLINE or JS_EDITLINE to enable line editing in the
153 # js command-line interpreter.
156 # For those platforms with the readline library installed.
157 DEFINES += -DEDITLINE
158 PROG_LIBS += -lreadline -ltermcap
161 # Use the editline library, built locally.
163 DEFINES += -DEDITLINE
164 PROG_LIBS += $(OBJDIR)/editline/libedit.a
169 PURE_CFLAGS = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \
170 $(INCLUDES) $(XCFLAGS)
217 nanojit/Assembler.h \
219 nanojit/Native$(NANOJIT_ARCH).h \
222 nanojit/Fragmento.h \
226 nanojit/TraceTreeDrawer.h \
257 OTHER_HFILES += builtins.tbl
260 ifndef PREBUILT_CPUCFG
261 OTHER_HFILES += $(OBJDIR)/jsautocfg.h
263 OTHER_HFILES += $(OBJDIR)/jsautokw.h $(OBJDIR)/js-config.h
265 HFILES = $(JS_HFILES) $(API_HFILES) $(OTHER_HFILES)
311 nanojit/Assembler.cpp \
312 nanojit/Fragmento.cpp \
314 nanojit/Native$(NANOJIT_ARCH).cpp \
315 nanojit/RegAlloc.cpp \
316 nanojit/avmplus.cpp \
320 JS_CPPFILES += nanojit/TraceTreeDrawer.cpp
334 ifdef JS_HAS_FILE_OBJECT
335 JS_CPPFILES += jsfile.cpp
336 JS_HFILES += jsfile.h
339 LIB_CPPFILES = $(JS_CPPFILES)
340 LIB_ASFILES := $(wildcard *_$(OS_ARCH).s)
341 PROG_CPPFILES = js.cpp
344 LIBRARY = $(OBJDIR)/js32.lib
345 SHARED_LIBRARY = $(OBJDIR)/js32.dll
346 PROGRAM = $(OBJDIR)/js.exe
348 LIBRARY = $(OBJDIR)/libjs.a
349 SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX)
350 PROGRAM = $(OBJDIR)/js
359 cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR)
362 # Automatic header generation
366 $(OBJDIR)/jsautokw.h \
367 $(OBJDIR)/jsautooplen.h \
370 $(OBJDIR)/jsautokw.h: jskeyword.tbl
372 $(OBJDIR)/jsautooplen.h: jsopcode.tbl
374 GARBAGE += $(AUTO_HEADERS)
375 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen$(HOST_BIN_SUFFIX))
379 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.obj)
381 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
383 $(CXX) -Fo$(OBJDIR)/ -c $(CFLAGS) $(OPTIMIZER) $<
384 link.exe -out:"$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX)" $(EXE_LINK_FLAGS) $(OBJDIR)/js$*gen.obj
385 $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
388 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.d)
389 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
391 $(CXX) -o $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $(CFLAGS) $(OPTIMIZER) $(LDFLAGS) $<
392 $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
396 # force creation of autoheaders before compiling any source that may use them
397 $(LIB_OBJS) : $(AUTO_HEADERS)
400 # An installed header file describing configuration options that affect
404 # Avoid rebuilding unless js-config.h's contents actually change. The
405 # timestamp on js-config.h.stamp corresponds to the last time we
406 # checked that js-config.h was up to date. If the stamp changes but
407 # js-config.h does not, then make concludes that targets depending on
408 # js-config.h don't need to be rebuilt. The dummy '@true' rule here
409 # keeps make from concluding that js-config.h never changes.
410 $(OBJDIR)/js-config.h: $(OBJDIR)/js-config.h.stamp
413 js-config-switch=$(if $(value $($1)),-e 's/\#undef $1/\#define $1/')
414 $(OBJDIR)/js-config.h.stamp: js-config.h.in Makefile.ref
415 sed < $< > $(@:.stamp=.tmp) \
416 $(call js-config-switch,JS_THREADSAFE) \
417 $(call js-config-switch,JS_GC_ZEAL) \
419 if ! [ -f $(@:.stamp=) ] || ! cmp $(@:.stamp=.tmp) $(@:.stamp=); then \
420 mv $(@:.stamp=.tmp) $(@:.stamp=); \
424 GARBAGE += $(OBJDIR)/js-config.h $(OBJDIR)/js-config.h.stamp
426 # Force creation of js-config.h before compiling any source that may use it.
427 $(LIB_OBJS) : $(OBJDIR)/js-config.h
430 # JS shell executable
434 $(PROGRAM): $(PROG_OBJS) $(LIBRARY)
435 link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
437 $(PROGRAM): $(PROG_OBJS) $(LIBRARY)
438 $(CXX) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \
442 $(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY)
443 purify $(PUREFLAGS) \
444 $(CXX) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) \
445 $(OTHER_LIBS) $(PROG_LIBS)
447 ifndef PREBUILT_CPUCFG
448 $(filter-out jscpucfg.h $(OBJDIR)/jsautocfg.h, $(HFILES)) $(CPPFILES): $(OBJDIR)/jsautocfg.h
450 $(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
452 $(OBJDIR)/jscpucfg > $@
454 $(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
455 $(CXX) $(OS_LDFLAGS) -o $@ $(OBJDIR)/jscpucfg.o
457 GARBAGE += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \
458 $(OBJDIR)/jscpucfg.o $(OBJDIR)/jscpucfg.d
461 # Automatic make dependencies files
462 DEPENDENCIES = $(CPPFILES:%.cpp=$(OBJDIR)/%.d)
465 # Hardwire dependencies for some files
473 $(OBJDIR)/jsinvoke.$(OBJ): jsinterp.h jsinterp.cpp
474 $(OBJDIR)/jsinvoke.obj : jsinterp.h jsinterp.cpp
476 -include $(DEPENDENCIES)
479 TARFILES = files `cat files`
483 $(CXX) -C -E $(CFLAGS) $< > $*.i