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 |
ifdef NARCISSUS |
78 |
DEFINES += -DNARCISSUS |
79 |
endif |
80 |
|
81 |
# Look in OBJDIR to find jsautocfg.h, jsautokw.h, and js-config.h |
82 |
INCLUDES += -I. -I$(OBJDIR) |
83 |
|
84 |
ifdef JS_THREADSAFE |
85 |
DEFINES += -DJS_THREADSAFE |
86 |
INCLUDES += -I$(DIST)/include/nspr |
87 |
ifdef USE_MSVC |
88 |
OTHER_LIBS += $(DIST)/lib/libnspr$(NSPR_LIBSUFFIX).lib |
89 |
else |
90 |
OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX) |
91 |
endif |
92 |
endif |
93 |
|
94 |
ifdef JS_NO_THIN_LOCKS |
95 |
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS |
96 |
endif |
97 |
|
98 |
ifdef JS_HAS_FILE_OBJECT |
99 |
DEFINES += -DJS_HAS_FILE_OBJECT |
100 |
endif |
101 |
|
102 |
ifdef JS_GC_ZEAL |
103 |
DEFINES += -DJS_GC_ZEAL |
104 |
endif |
105 |
|
106 |
# |
107 |
# XCFLAGS may be set in the environment or on the gmake command line |
108 |
# |
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) |
111 |
|
112 |
LDFLAGS = $(XLDFLAGS) |
113 |
LDFLAGS += $(OS_LDFLAGS) |
114 |
|
115 |
ifdef MOZ_SHARK |
116 |
DEFINES += -DMOZ_SHARK |
117 |
CFLAGS += -F/System/Library/PrivateFrameworks |
118 |
LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD |
119 |
endif |
120 |
ifdef MOZ_CALLGRIND |
121 |
DEFINES += -DMOZ_CALLGRIND |
122 |
endif |
123 |
ifdef MOZ_VTUNE |
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 |
127 |
endif |
128 |
|
129 |
ifndef NO_LIBM |
130 |
LDFLAGS += -lm |
131 |
endif |
132 |
|
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))) |
137 |
CFLAGS += -Op |
138 |
else |
139 |
CFLAGS += -fp:precise |
140 |
endif |
141 |
endif # WINNT |
142 |
|
143 |
# |
144 |
# Server-related changes : |
145 |
# |
146 |
ifdef NES40 |
147 |
DEFINES += -DNES40 |
148 |
endif |
149 |
|
150 |
# |
151 |
# Line editing support. |
152 |
# Define JS_READLINE or JS_EDITLINE to enable line editing in the |
153 |
# js command-line interpreter. |
154 |
# |
155 |
ifdef JS_READLINE |
156 |
# For those platforms with the readline library installed. |
157 |
DEFINES += -DEDITLINE |
158 |
PROG_LIBS += -lreadline -ltermcap |
159 |
else |
160 |
ifdef JS_EDITLINE |
161 |
# Use the editline library, built locally. |
162 |
PREDIRS += editline |
163 |
DEFINES += -DEDITLINE |
164 |
PROG_LIBS += $(OBJDIR)/editline/libedit.a |
165 |
endif |
166 |
endif |
167 |
|
168 |
# For purify |
169 |
PURE_CFLAGS = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \ |
170 |
$(INCLUDES) $(XCFLAGS) |
171 |
|
172 |
# |
173 |
# JS file lists |
174 |
# |
175 |
JS_HFILES = \ |
176 |
jsarray.h \ |
177 |
jsatom.h \ |
178 |
jsbool.h \ |
179 |
jscntxt.h \ |
180 |
jsdate.h \ |
181 |
jsemit.h \ |
182 |
jsexn.h \ |
183 |
jsfun.h \ |
184 |
jsgc.h \ |
185 |
jsinterp.h \ |
186 |
jsiter.h \ |
187 |
jslibmath.h \ |
188 |
jslock.h \ |
189 |
jsmath.h \ |
190 |
jsnum.h \ |
191 |
jsobj.h \ |
192 |
json.h \ |
193 |
jsopcode.h \ |
194 |
jsparse.h \ |
195 |
jsarena.h \ |
196 |
jsclist.h \ |
197 |
jsdhash.h \ |
198 |
jsdtoa.h \ |
199 |
jshash.h \ |
200 |
jslong.h \ |
201 |
jstypes.h \ |
202 |
jsprvtd.h \ |
203 |
jspubtd.h \ |
204 |
jsregexp.h \ |
205 |
jsscan.h \ |
206 |
jsscope.h \ |
207 |
jsscript.h \ |
208 |
jsstr.h \ |
209 |
jsversion.h \ |
210 |
jsxdrapi.h \ |
211 |
jsxml.h \ |
212 |
$(NULL) |
213 |
|
214 |
ifdef ENABLE_JIT |
215 |
JS_HFILES += \ |
216 |
jstracer.h \ |
217 |
nanojit/Assembler.h \ |
218 |
nanojit/LIR.h \ |
219 |
nanojit/Native$(NANOJIT_ARCH).h \ |
220 |
nanojit/avmplus.h \ |
221 |
nanojit/vm_fops.h \ |
222 |
nanojit/Fragmento.h \ |
223 |
nanojit/Native.h \ |
224 |
nanojit/RegAlloc.h \ |
225 |
nanojit/nanojit.h \ |
226 |
nanojit/TraceTreeDrawer.h \ |
227 |
$(NULL) |
228 |
endif |
229 |
|
230 |
ifndef BUILD_OPT |
231 |
#JS_HFILES += \ |
232 |
# vprof/vprof.h \ |
233 |
# $(NULL) |
234 |
endif |
235 |
|
236 |
API_HFILES = \ |
237 |
jsapi.h \ |
238 |
jsdbgapi.h \ |
239 |
$(NULL) |
240 |
|
241 |
OTHER_HFILES = \ |
242 |
jsbit.h \ |
243 |
jscompat.h \ |
244 |
jscpucfg.h \ |
245 |
jsotypes.h \ |
246 |
jsstddef.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 |
ifdef ENABLE_JIT |
257 |
OTHER_HFILES += builtins.tbl |
258 |
endif |
259 |
|
260 |
ifndef PREBUILT_CPUCFG |
261 |
OTHER_HFILES += $(OBJDIR)/jsautocfg.h |
262 |
endif |
263 |
OTHER_HFILES += $(OBJDIR)/jsautokw.h $(OBJDIR)/js-config.h |
264 |
|
265 |
HFILES = $(JS_HFILES) $(API_HFILES) $(OTHER_HFILES) |
266 |
|
267 |
JS_CPPFILES = \ |
268 |
jsapi.cpp \ |
269 |
jsarena.cpp \ |
270 |
jsarray.cpp \ |
271 |
jsatom.cpp \ |
272 |
jsbool.cpp \ |
273 |
jscntxt.cpp \ |
274 |
jsdate.cpp \ |
275 |
jsdbgapi.cpp \ |
276 |
jsdhash.cpp \ |
277 |
jsdtoa.cpp \ |
278 |
jsemit.cpp \ |
279 |
jsexn.cpp \ |
280 |
jsfun.cpp \ |
281 |
jsgc.cpp \ |
282 |
jshash.cpp \ |
283 |
jsinterp.cpp \ |
284 |
jsinvoke.cpp \ |
285 |
jsiter.cpp \ |
286 |
jslock.cpp \ |
287 |
jslog2.cpp \ |
288 |
jslong.cpp \ |
289 |
jsmath.cpp \ |
290 |
jsnum.cpp \ |
291 |
jsobj.cpp \ |
292 |
json.cpp \ |
293 |
jsopcode.cpp \ |
294 |
jsparse.cpp \ |
295 |
jsprf.cpp \ |
296 |
jsregexp.cpp \ |
297 |
jsscan.cpp \ |
298 |
jsscope.cpp \ |
299 |
jsscript.cpp \ |
300 |
jsstr.cpp \ |
301 |
jsutil.cpp \ |
302 |
jsxdrapi.cpp \ |
303 |
jsxml.cpp \ |
304 |
prmjtime.cpp \ |
305 |
$(NULL) |
306 |
|
307 |
ifdef ENABLE_JIT |
308 |
JS_CPPFILES += \ |
309 |
jsbuiltins.cpp \ |
310 |
jstracer.cpp \ |
311 |
nanojit/Assembler.cpp \ |
312 |
nanojit/Fragmento.cpp \ |
313 |
nanojit/LIR.cpp \ |
314 |
nanojit/Native$(NANOJIT_ARCH).cpp \ |
315 |
nanojit/RegAlloc.cpp \ |
316 |
nanojit/avmplus.cpp \ |
317 |
$(NULL) |
318 |
|
319 |
ifdef DEBUG |
320 |
JS_CPPFILES += nanojit/TraceTreeDrawer.cpp |
321 |
endif |
322 |
endif |
323 |
|
324 |
ifndef BUILD_OPT |
325 |
#JS_CPPFILES += \ |
326 |
# vprof/vprof.cpp \ |
327 |
# $(NULL) |
328 |
endif |
329 |
|
330 |
ifdef JS_LIVECONNECT |
331 |
DIRS += liveconnect |
332 |
endif |
333 |
|
334 |
ifdef JS_HAS_FILE_OBJECT |
335 |
JS_CPPFILES += jsfile.cpp |
336 |
JS_HFILES += jsfile.h |
337 |
endif |
338 |
|
339 |
LIB_CPPFILES = $(JS_CPPFILES) |
340 |
LIB_ASFILES := $(wildcard *_$(OS_ARCH).s) |
341 |
PROG_CPPFILES = js.cpp |
342 |
|
343 |
ifdef USE_MSVC |
344 |
LIBRARY = $(OBJDIR)/js32.lib |
345 |
SHARED_LIBRARY = $(OBJDIR)/js32.dll |
346 |
PROGRAM = $(OBJDIR)/js.exe |
347 |
else |
348 |
LIBRARY = $(OBJDIR)/libjs.a |
349 |
SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX) |
350 |
PROGRAM = $(OBJDIR)/js |
351 |
endif |
352 |
|
353 |
include rules.mk |
354 |
|
355 |
MOZ_DEPTH = ../.. |
356 |
include jsconfig.mk |
357 |
|
358 |
nsinstall-target: |
359 |
cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR) |
360 |
|
361 |
# |
362 |
# Automatic header generation |
363 |
# |
364 |
|
365 |
AUTO_HEADERS = \ |
366 |
$(OBJDIR)/jsautokw.h \ |
367 |
$(OBJDIR)/jsautooplen.h \ |
368 |
$(NULL) |
369 |
|
370 |
$(OBJDIR)/jsautokw.h: jskeyword.tbl |
371 |
|
372 |
$(OBJDIR)/jsautooplen.h: jsopcode.tbl |
373 |
|
374 |
GARBAGE += $(AUTO_HEADERS) |
375 |
GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen$(HOST_BIN_SUFFIX)) |
376 |
|
377 |
ifdef USE_MSVC |
378 |
|
379 |
GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.obj) |
380 |
|
381 |
$(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp |
382 |
@$(MAKE_OBJDIR) |
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) $@ |
386 |
else |
387 |
|
388 |
GARBAGE += $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.d) |
389 |
$(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp |
390 |
@$(MAKE_OBJDIR) |
391 |
$(CXX) -o $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $(CFLAGS) $(OPTIMIZER) $(LDFLAGS) $< |
392 |
$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@ |
393 |
|
394 |
endif |
395 |
|
396 |
# force creation of autoheaders before compiling any source that may use them |
397 |
$(LIB_OBJS) : $(AUTO_HEADERS) |
398 |
|
399 |
# |
400 |
# An installed header file describing configuration options that affect |
401 |
# the API. |
402 |
# |
403 |
|
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 |
411 |
@true |
412 |
|
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) \ |
418 |
-e :dummy |
419 |
if ! [ -f $(@:.stamp=) ] || ! cmp $(@:.stamp=.tmp) $(@:.stamp=); then \ |
420 |
mv $(@:.stamp=.tmp) $(@:.stamp=); \ |
421 |
fi |
422 |
touch $@ |
423 |
|
424 |
GARBAGE += $(OBJDIR)/js-config.h $(OBJDIR)/js-config.h.stamp |
425 |
|
426 |
# Force creation of js-config.h before compiling any source that may use it. |
427 |
$(LIB_OBJS) : $(OBJDIR)/js-config.h |
428 |
|
429 |
# |
430 |
# JS shell executable |
431 |
# |
432 |
|
433 |
ifdef USE_MSVC |
434 |
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) |
435 |
link.exe -out:"$@" $(EXE_LINK_FLAGS) $^ |
436 |
else |
437 |
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) |
438 |
$(CXX) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \ |
439 |
$(PROG_LIBS) |
440 |
endif |
441 |
|
442 |
$(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY) |
443 |
purify $(PUREFLAGS) \ |
444 |
$(CXX) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) \ |
445 |
$(OTHER_LIBS) $(PROG_LIBS) |
446 |
|
447 |
ifndef PREBUILT_CPUCFG |
448 |
$(filter-out jscpucfg.h $(OBJDIR)/jsautocfg.h, $(HFILES)) $(CPPFILES): $(OBJDIR)/jsautocfg.h |
449 |
|
450 |
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg |
451 |
rm -f $@ |
452 |
$(OBJDIR)/jscpucfg > $@ |
453 |
|
454 |
$(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o |
455 |
$(CXX) $(OS_LDFLAGS) -o $@ $(OBJDIR)/jscpucfg.o |
456 |
|
457 |
GARBAGE += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \ |
458 |
$(OBJDIR)/jscpucfg.o $(OBJDIR)/jscpucfg.d |
459 |
endif |
460 |
|
461 |
# Automatic make dependencies files |
462 |
DEPENDENCIES = $(CPPFILES:%.cpp=$(OBJDIR)/%.d) |
463 |
|
464 |
# |
465 |
# Hardwire dependencies for some files |
466 |
# |
467 |
ifdef USE_MSVC |
468 |
OBJ=obj |
469 |
else |
470 |
OBJ=o |
471 |
endif |
472 |
|
473 |
$(OBJDIR)/jsinvoke.$(OBJ): jsinterp.h jsinterp.cpp |
474 |
$(OBJDIR)/jsinvoke.obj : jsinterp.h jsinterp.cpp |
475 |
|
476 |
-include $(DEPENDENCIES) |
477 |
|
478 |
TARNAME = jsref.tar |
479 |
TARFILES = files `cat files` |
480 |
|
481 |
SUFFIXES: .i |
482 |
%.i: %.cpp |
483 |
$(CXX) -C -E $(CFLAGS) $< > $*.i |