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
16
# The Original Code is Mozilla Communicator client code, released
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.
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 *****
41
topsrcdir = @top_srcdir@
45
include $(DEPTH)/config/autoconf.mk
52
ifeq ($(OS_ARCH),WINNT)
53
LIBRARY_NAME = js$(MOZ_BITS)$(VERSION_NUMBER)
54
RESFILE = js$(MOZ_BITS)40.res
59
# JavaScript must be built shared, even for static builds, as it is used by
60
# other modules which are always built shared. Failure to do so results in
61
# the js code getting copied into xpinstall and jsd as well as mozilla-bin,
62
# and then the static data cells used for locking no longer work.
146
ifeq ($(OS_ARCH),WINNT)
147
EXPORTS += jscpucfg.h
150
FDLIBM_LIBRARY = fdlibm/$(LIB_PREFIX)fdm.$(LIB_SUFFIX)
151
JSMATH_PRELINK = jsmathtemp.o
156
include $(topsrcdir)/config/config.mk
158
EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
160
ifeq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
161
SHARED_LIBRARY_LIBS += $(FDLIBM_LIBRARY)
164
# When using gcc the assembly is inlined in the C-file (see jslock.c)
165
ifeq ($(OS_ARCH),SunOS)
166
ifneq ($(OS_TEST),i86pc)
168
ASFILES = lock_$(OS_ARCH).s
178
JSJAVA_STUBHEADERS = \
179
-I$(topsrcdir)/sun-java/include/_gen \
180
-I$(topsrcdir)/sun-java/netscape/javascript/_jri \
181
-I$(topsrcdir)/sun-java/netscape/security/_jri
183
JSJAVA_STUBHEADERS = -I$(JRI_GEN_DIR) -I$(JDK_GEN_DIR)
187
-I$(topsrcdir)/sun-java/md-include \
188
-I$(topsrcdir)/sun-java/include \
189
$(JSJAVA_STUBHEADERS)
191
include $(topsrcdir)/config/rules.mk
193
DEFINES += -DEXPORT_JS_API
195
INCLUDES += -I$(srcdir)
197
# MSVC '-Gy' cc flag and '/OPT:REF' linker flag cause JS_GetArgument and
198
# JS_GetLocalVariable to be folded to the same address by the linker,
199
# leading to a crash on startup. See bug 151066. So, in optimized builds,
200
# add the /OPT:NOICF flag, which turns off 'identical COMDAT folding'.
202
# N.B.: 'identical COMDAT folding' that folds functions whose addresses
203
# are taken violates the ISO C and C++ standards.
205
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
206
LDFLAGS += /OPT:NOICF
210
GARBAGE += $(JSMATH_PRELINK) jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg
212
ifneq (,$(CROSS_COMPILE)$(filter-out WINNT,$(OS_ARCH)))
213
TARGETS += jscpucfg$(HOST_BIN_SUFFIX)
217
DEFINES += -DJS_USE_SAFE_ARENA
221
DEFINES += -DJS_THREADSAFE
224
ifdef JS_NO_THIN_LOCKS
225
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
229
DEFINES += -DJS_VERSION=$(JS_VERSION)
232
ifneq ($(findstring -L,$(NSPR_LIBS)),)
233
NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
235
NSPR_STATIC_PATH = $(DIST)/lib
238
LDFLAGS += $(pathsubst -l%,$(NSPR_STATIC_PATH)/%.a,$(NSPR_LIBS))
240
# BeOS and HP-UX do not require the extra linking of "-lm"
241
ifeq (,$(filter BeOS HP-UX WINNT OpenVMS,$(OS_ARCH)))
245
# Prevent floating point errors caused by VC++ optimizations
246
ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
250
ifeq ($(OS_ARCH),FreeBSD)
253
ifeq ($(OS_ARCH),IRIX)
258
ifeq ($(OS_ARCH),Linux)
261
ifeq ($(OS_ARCH),OSF1)
264
ifeq ($(OS_ARCH),SunOS)
265
ifeq ($(TARGET_CPU),sparc)
267
ifdef JS_ULTRASPARC_OPTS
268
DEFINES += -DULTRA_SPARC
270
CFLAGS += -Wa,-xarch=v8plus,-DULTRA_SPARC,-P,-L,-D_ASM,-D__STDC__=0
271
CXXFLAGS += -Wa,-xarch=v8plus,-DULTRA_SPARC,-P,-L,-D_ASM,-D__STDC__=0,-K,PIC
273
ASFLAGS += -xarch=v8plus -DULTRA_SPARC -P -L -D_ASM -D__STDC__=0 -K PIC
275
endif # JS_ULTRASPARC_OPTS
278
ifeq ($(OS_RELEASE),4.1)
279
LDFLAGS += -ldl -lnsl
281
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
285
ifeq ($(OS_ARCH),QNX)
286
ifneq ($(OS_TARGET),NTO)
287
# Don't use wildcard here, because we only want this resolved at link time.
292
ifeq ($(OS_ARCH),IRIX)
294
_COMPILE_CFLAGS = $(patsubst -O%,-O1,$(COMPILE_CFLAGS))
295
jsapi.o jsarena.o jsarray.o jsatom.o jsemit.o jsfun.o jsinterp.o jsregexp.o jsparse.o jsopcode.o jsscript.o: %.o: %.c Makefile.in
298
$(CC) -o $@ -c $(_COMPILE_CFLAGS) $<
302
# On OS/2 & win32 we are already linking against fdlibm, so don't bother
303
# creating jsmathtemp
304
ifeq (,$(filter OS2 WINNT OpenVMS,$(OS_ARCH)))
305
# special rule for jsmath.o since we want to incrementally link
306
# against fdlibm to pull in only what is needed
307
# Do this in a single step to avoid dependency problems
308
jsmath.o: jsmath.c $(FDLIBM_LIBRARY) Makefile.in
311
$(ELOG) $(CC) $(OUTOPTION)$(JSMATH_PRELINK) -c $(COMPILE_CFLAGS) $<
312
ifeq ($(OS_ARCH),QNX)
313
ifneq ($(OS_TARGET),NTO)
314
@cp $(JSMATH_PRELINK) $@
316
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
319
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
321
@$(RM) -f $(JSMATH_PRELINK)
323
# Create dependency so we build fdlibm
324
jsmath.o: $(FDLIBM_LIBRARY) Makefile.in
327
# An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
328
# This suppresses optimization for this single compilation unit.
329
ifeq ($(OS_ARCH),AIX)
330
jsatom.o: jsatom.c Makefile.in
333
$(CC) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
334
jsdtoa.o: jsdtoa.c Makefile.in
337
$(CC) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $<
341
$(MAKE) -C $(@D) $(@F)
343
jsopcode.h jsopcode.c: jsopcode.tbl
345
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT,$(OS_ARCH)))
349
jsautocfg.h: jscpucfg$(HOST_BIN_SUFFIX)
350
@rm -f $@ jsautocfg.tmp
351
./jscpucfg > jsautocfg.tmp
355
# jscpucfg is a strange target
356
# Needs to be built with the host compiler but needs to include
357
# the mdcpucfg for the target so it needs the appropriate target defines
358
ifdef HOST_NSPR_MDCPUCFG
359
HOST_CC := $(HOST_CC) -DMDCPUCFG=$(TARGET_NSPR_MDCPUCFG)
362
ifeq ($(OS_ARCH),QNX)
363
ifneq ($(OS_TARGET),NTO)
364
# QNX's compiler apparently can't build a binary directly from a source file.
365
jscpucfg.o: jscpucfg.c Makefile.in
366
$(HOST_CC) $(HOST_CFLAGS) -c $(DEFINES) $(NSPR_CFLAGS) -o $@ $<
369
$(HOST_CC) $(HOST_CFLAGS) $(DEFINES) -o $@ $<
372
jscpucfg$(HOST_BIN_SUFFIX): jscpucfg.c Makefile.in
373
$(HOST_CC) $(HOST_CFLAGS) $(DEFINES) $(NSPR_CFLAGS) $(OUTOPTION)$@ $<