Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / Makefile.ref
1 # -*- Mode: makefile -*-
2 # vim: ft=make
3 #
4 # ***** BEGIN LICENSE BLOCK *****
5 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 #
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/
11 #
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
15 # License.
16 #
17 # The Original Code is Mozilla Communicator client code, released
18 # March 31, 1998.
19 #
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.
24 #
25 # Contributor(s):
26 #   Michael Ang <mang@subcarrier.org>
27 #   Kevin Buhr <buhr@stat.wisc.edu>
28 #
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.
40 #
41 # ***** END LICENSE BLOCK *****
42
43 #
44 # JSRef GNUmake makefile.
45 #
46 # Note: dependency rules are missing for some files (some
47 #       .h, all .msg, etc.)  Re-make clean if in doubt.
48 #
49
50
51 DEPTH = .
52
53 include config.mk
54
55 #NS_USE_NATIVE = 1
56
57 ifndef NANOJIT_ARCH
58 $(warning NANOJIT_ARCH not defined in config/$(OS_CONFIG).mk, JIT disabled)
59 else
60 ifdef DISABLE_JIT
61 $(warning disabling JIT per build specification)
62 else
63 ENABLE_JIT=1
64 endif
65 endif
66
67 ifdef ENABLE_JIT
68 DEFINES += -DJS_TRACER
69 DEFINES += -DFEATURE_NANOJIT
70 INCLUDES += -Inanojit
71 endif
72
73 #ifndef BUILD_OPT
74 #DEFINES += -Ivprof
75 #endif
76
77 # Look in OBJDIR to find jsautocfg.h, jsautokw.h, and js-config.h
78 INCLUDES   += -I. -I$(OBJDIR)
79
80 ifdef JS_THREADSAFE
81 DEFINES += -DJS_THREADSAFE
82 INCLUDES += -I$(DIST)/include/nspr
83 ifdef USE_MSVC
84 OTHER_LIBS += $(DIST)/lib/libnspr$(NSPR_LIBSUFFIX).lib
85 else
86 OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX)
87 endif
88 endif
89
90 ifdef JS_HAS_CTYPES
91 DEFINES += -DJS_HAS_CTYPES
92 INCLUDES += -I$(DIST)/include/nspr
93 ifdef USE_MSVC
94 OTHER_LIBS += $(DIST)/lib/libnspr$(NSPR_LIBSUFFIX).lib
95 else
96 OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX)
97 endif
98 endif
99
100 ifdef JS_NO_THIN_LOCKS
101 DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
102 endif
103
104 ifdef JS_GC_ZEAL
105 DEFINES += -DJS_GC_ZEAL
106 endif
107
108 #
109 # XCFLAGS may be set in the environment or on the gmake command line
110 #
111 #CFLAGS += -DDEBUG -DDEBUG_brendan -DJS_ARENAMETER -DJS_HASHMETER -DJS_DUMP_PROPTREE_STATS -DJS_DUMP_SCOPE_METERS -DJS_SCOPE_DEPTH_METER -DJS_BASIC_STATS
112 CFLAGS          += $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
113
114 LDFLAGS         = $(XLDFLAGS)
115 LDFLAGS += $(OS_LDFLAGS)
116
117 ifdef MOZ_SHARK
118 DEFINES += -DMOZ_SHARK
119 CFLAGS += -F/System/Library/PrivateFrameworks
120 LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
121 endif
122 ifdef MOZ_CALLGRIND
123 DEFINES += -DMOZ_CALLGRIND
124 endif
125 ifdef MOZ_VTUNE
126 DEFINES += -DMOZ_VTUNE
127 CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
128 OTHER_LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
129 endif
130
131 ifndef NO_LIBM
132 LDFLAGS += -lm
133 endif
134
135 # Prevent floating point errors caused by VC++ optimizations
136 ifeq ($(OS_ARCH),WINNT)
137 _MSC_VER = $(shell $(CXX) 2>&1 | sed -n 's/.*Compiler Version \([0-9]*\)\.\([0-9]*\).*/\1\2/p')
138 ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
139 CFLAGS += -Op
140 else
141 CFLAGS += -fp:precise
142 endif
143 endif # WINNT
144
145 #
146 #       Server-related changes :
147 #
148 ifdef NES40
149 DEFINES += -DNES40
150 endif
151
152 #
153 # Line editing support.
154 # Define JS_READLINE or JS_EDITLINE to enable line editing in the
155 # js command-line interpreter.
156 #
157 ifdef JS_READLINE
158 # For those platforms with the readline library installed.
159 DEFINES += -DEDITLINE
160 PROG_LIBS += -lreadline -ltermcap
161 else
162 ifdef JS_EDITLINE
163 # Use the editline library, built locally.
164 PREDIRS += editline
165 DEFINES += -DEDITLINE
166 PROG_LIBS += $(OBJDIR)/editline/libedit.a
167 endif
168 endif
169
170 # For purify
171 PURE_CFLAGS     = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \
172                   $(INCLUDES) $(XCFLAGS)
173
174 #
175 # JS file lists
176 #
177 JS_HFILES =             \
178         jsarray.h       \
179         jsatom.h        \
180         jsbool.h        \
181         jscntxt.h       \
182         jsdate.h        \
183         jsemit.h        \
184         jsexn.h         \
185         jsfun.h         \
186         jsgc.h          \
187         jsinterp.h      \
188         jsiter.h        \
189         jslibmath.h     \
190         jslock.h        \
191         jsmath.h        \
192         jsnum.h         \
193         jsobj.h         \
194         json.h          \
195         jsopcode.h      \
196         jsparse.h       \
197         jsarena.h       \
198         jsclist.h       \
199         jsdhash.h       \
200         jsdtoa.h        \
201         jshash.h        \
202         jslong.h        \
203         jstypes.h       \
204         jsprvtd.h       \
205         jspubtd.h       \
206         jsregexp.h      \
207         jsscan.h        \
208         jsscope.h       \
209         jsscript.h      \
210         jsstr.h         \
211         jsversion.h     \
212         jsxdrapi.h      \
213         jsxml.h         \
214         $(NULL)
215
216 ifdef ENABLE_JIT
217 JS_HFILES +=                    \
218         jstracer.h              \
219         nanojit/Assembler.h     \
220         nanojit/LIR.h           \
221         nanojit/Native$(NANOJIT_ARCH).h \
222         nanojit/avmplus.h       \
223         nanojit/vm_fops.h       \
224         nanojit/Fragmento.h     \
225         nanojit/Native.h        \
226         nanojit/RegAlloc.h      \
227         nanojit/nanojit.h       \
228         $(NULL)
229 endif
230
231 ifndef BUILD_OPT
232 #JS_HFILES +=            \
233 #        vprof/vprof.h   \
234 #        $(NULL)
235 endif
236
237 API_HFILES =            \
238         jsapi.h         \
239         jsdbgapi.h      \
240         $(NULL)
241
242 OTHER_HFILES =          \
243         jsbit.h         \
244         jscompat.h      \
245         jscpucfg.h      \
246         jsotypes.h      \
247         prmjtime.h      \
248         resource.h      \
249         jsopcode.tbl    \
250         jsproto.tbl     \
251         js.msg          \
252         jsshell.msg     \
253         jskeyword.tbl   \
254         $(NULL)
255
256 ifndef PREBUILT_CPUCFG
257 OTHER_HFILES += $(OBJDIR)/jsautocfg.h
258 endif
259 OTHER_HFILES += $(OBJDIR)/jsautokw.h $(OBJDIR)/js-config.h
260
261 HFILES = $(JS_HFILES) $(API_HFILES) $(OTHER_HFILES)
262
263 JS_CPPFILES =           \
264         jsapi.cpp       \
265         jsarena.cpp     \
266         jsarray.cpp     \
267         jsatom.cpp      \
268         jsbool.cpp      \
269         jscntxt.cpp     \
270         jsdate.cpp      \
271         jsdbgapi.cpp    \
272         jsdhash.cpp     \
273         jsdtoa.cpp      \
274         jsemit.cpp      \
275         jsexn.cpp       \
276         jsfun.cpp       \
277         jsgc.cpp        \
278         jshash.cpp      \
279         jsinterp.cpp    \
280         jsinvoke.cpp    \
281         jsiter.cpp      \
282         jslock.cpp      \
283         jslog2.cpp      \
284         jslong.cpp      \
285         jsmath.cpp      \
286         jsnum.cpp       \
287         jsobj.cpp       \
288         json.cpp        \
289         jsopcode.cpp    \
290         jsparse.cpp     \
291         jsprf.cpp       \
292         jsregexp.cpp    \
293         jsscan.cpp      \
294         jsscope.cpp     \
295         jsscript.cpp    \
296         jsstr.cpp       \
297         jsutil.cpp      \
298         jsxdrapi.cpp    \
299         jsxml.cpp       \
300         prmjtime.cpp    \
301         $(NULL)
302
303 ifdef ENABLE_JIT
304 JS_CPPFILES +=                 \
305         jsbuiltins.cpp         \
306         jstracer.cpp           \
307         nanojit/Assembler.cpp  \
308         nanojit/Fragmento.cpp  \
309         nanojit/LIR.cpp        \
310         nanojit/Native$(NANOJIT_ARCH).cpp \
311         nanojit/RegAlloc.cpp   \
312         nanojit/avmplus.cpp    \
313         $(NULL)
314
315 endif
316
317 ifndef BUILD_OPT
318 #JS_CPPFILES +=                 \
319 #        vprof/vprof.cpp        \
320 #        $(NULL)
321 endif
322
323 LIB_CPPFILES  = $(JS_CPPFILES)
324 LIB_ASFILES := $(wildcard *_$(OS_ARCH).s)
325 PROG_CPPFILES = js.cpp
326
327 ifdef USE_MSVC
328 LIBRARY = $(OBJDIR)/js32.lib
329 SHARED_LIBRARY = $(OBJDIR)/js32.dll
330 PROGRAM = $(OBJDIR)/js.exe
331 else
332 LIBRARY = $(OBJDIR)/libjs.a
333 SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX)
334 PROGRAM = $(OBJDIR)/js
335 endif
336
337 include rules.mk
338
339 MOZ_DEPTH = ../..
340 include jsconfig.mk
341
342 nsinstall-target:
343         cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR)
344
345 #
346 # Automatic header generation
347 #
348
349 AUTO_HEADERS =                                  \
350         $(OBJDIR)/jsautokw.h                    \
351         $(OBJDIR)/jsautooplen.h                 \
352         $(NULL)
353
354 $(OBJDIR)/jsautokw.h: jskeyword.tbl
355
356 $(OBJDIR)/jsautooplen.h: jsopcode.tbl
357
358 GARBAGE += $(AUTO_HEADERS)
359 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen$(HOST_BIN_SUFFIX))
360
361 ifdef USE_MSVC
362
363 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.obj)
364
365 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
366         @$(MAKE_OBJDIR)
367         $(CXX) -Fo$(OBJDIR)/ -c $(CFLAGS) $(OPTIMIZER) $<
368         link.exe -out:"$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX)" $(EXE_LINK_FLAGS) $(OBJDIR)/js$*gen.obj
369         $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
370 else
371
372 GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.d)
373 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
374         @$(MAKE_OBJDIR)
375         $(CXX) -o $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $(CFLAGS) $(OPTIMIZER) $(LDFLAGS) $<
376         $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
377
378 endif
379
380 # force creation of autoheaders before compiling any source that may use them
381 $(LIB_OBJS) : $(AUTO_HEADERS)
382
383 #
384 # An installed header file describing configuration options that affect
385 # the API.
386 #
387
388 # Avoid rebuilding unless js-config.h's contents actually change.  The
389 # timestamp on js-config.h.stamp corresponds to the last time we
390 # checked that js-config.h was up to date.  If the stamp changes but
391 # js-config.h does not, then make concludes that targets depending on
392 # js-config.h don't need to be rebuilt.  The dummy '@true' rule here
393 # keeps make from concluding that js-config.h never changes.
394 $(OBJDIR)/js-config.h: $(OBJDIR)/js-config.h.stamp
395         @true
396
397 js-config-switch=$(if $(value $($1)),-e 's/\#undef $1/\#define $1/')
398 $(OBJDIR)/js-config.h.stamp: js-config.h.in Makefile.ref
399         sed < $< > $(@:.stamp=.tmp)                     \
400             $(call js-config-switch,JS_THREADSAFE)      \
401             $(call js-config-switch,JS_HAS_CTYPES)              \
402             $(call js-config-switch,JS_GC_ZEAL)         \
403             -e :dummy
404         if ! [ -f $(@:.stamp=) ] || ! cmp $(@:.stamp=.tmp) $(@:.stamp=); then \
405             mv $(@:.stamp=.tmp) $(@:.stamp=);                                 \
406         fi
407         touch $@
408
409 GARBAGE += $(OBJDIR)/js-config.h $(OBJDIR)/js-config.h.stamp
410
411 # Force creation of js-config.h before compiling any source that may use it.
412 $(LIB_OBJS) : $(OBJDIR)/js-config.h
413
414 #
415 # JS shell executable
416 #
417
418 ifdef USE_MSVC
419 $(PROGRAM): $(PROG_OBJS) $(LIBRARY)
420         link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
421 else
422 $(PROGRAM): $(PROG_OBJS) $(LIBRARY)
423         $(CXX) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \
424             $(PROG_LIBS)
425 endif
426
427 $(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY)
428         purify $(PUREFLAGS) \
429             $(CXX) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) \
430                 $(OTHER_LIBS) $(PROG_LIBS)
431
432 ifndef PREBUILT_CPUCFG
433 $(filter-out jscpucfg.h $(OBJDIR)/jsautocfg.h, $(HFILES)) $(CPPFILES): $(OBJDIR)/jsautocfg.h
434
435 $(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
436         rm -f $@
437         $(OBJDIR)/jscpucfg > $@
438
439 $(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
440         $(CXX) $(OS_LDFLAGS) -o $@ $(OBJDIR)/jscpucfg.o
441
442 GARBAGE += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \
443            $(OBJDIR)/jscpucfg.o $(OBJDIR)/jscpucfg.d
444 endif
445
446 # Automatic make dependencies files
447 DEPENDENCIES    = $(CPPFILES:%.cpp=$(OBJDIR)/%.d)
448
449 #
450 # Hardwire dependencies for some files 
451 #
452 ifdef USE_MSVC
453 OBJ=obj
454 else
455 OBJ=o
456 endif
457
458 $(OBJDIR)/jsinvoke.$(OBJ): jsinterp.h jsinterp.cpp
459 $(OBJDIR)/jsinvoke.obj : jsinterp.h jsinterp.cpp
460
461 -include $(DEPENDENCIES)
462
463 TARNAME = jsref.tar
464 TARFILES = files `cat files`
465
466 SUFFIXES: .i
467 %.i: %.cpp
468         $(CXX) -C -E $(CFLAGS) $< > $*.i