diff --git a/js/src/Makefile.ref b/js/src/Makefile.ref index 6e1d219f9ba..756ae5af16f 100644 --- a/js/src/Makefile.ref +++ b/js/src/Makefile.ref @@ -18,6 +18,8 @@ # Rights Reserved. # # Contributor(s): +# Michael Ang +# # # Alternatively, the contents of this file may be used under the # terms of the GNU Public License (the "GPL"), in which case the @@ -213,6 +215,22 @@ JS_CFILES = \ $(NULL) PREDIRS += fdlibm +ifdef USE_MSVC +FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/fdlibm.lib +else +FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/libfdm.a +endif +JSMATH_PRELINK = $(OBJDIR)/jsmathtemp.o +# Flag for incremental linking +DASH_R = -r + +ifeq ($(OS_ARCH),QNX) +ifneq ($(OS_TARGET),NTO) +# Don't use wildcard here, because we only want this resolved at link time. +OBJS += fdlibm/*.o +endif +endif + ifdef JS_LIVECONNECT DIRS += liveconnect endif @@ -240,12 +258,6 @@ SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX) PROGRAM = $(OBJDIR)/js endif -ifdef USE_MSVC -FDLIBM_LIBRARY = fdlibm.lib -else -FDLIBM_LIBRARY = libfdm.a -endif - include rules.mk MOZ_DEPTH = ../.. @@ -254,10 +266,10 @@ include jsconfig.mk nsinstall-target: cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR) ifdef USE_MSVC -$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY) +$(PROGRAM): $(PROG_OBJS) $(LIBRARY) $(FDLIBM_LIBRARY) link.exe -out:"$@" $(EXE_LINK_FLAGS) $^ else -$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY) +$(PROGRAM): $(PROG_OBJS) $(LIBRARY) $(FDLIBM_LIBRARY) $(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \ $(PROG_LIBS) endif @@ -284,6 +296,31 @@ INCLUDES += -I$(OBJDIR) TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.o endif + +# special rule for jsmath.o since we want to incrementally link +# against fdlibm to pull in only what is needed +$(OBJDIR)/jsmath.o: $(FDLIBM_LIBRARY) $(JSMATH_PRELINK) +ifeq ($(OS_ARCH),QNX) +ifneq ($(OS_TARGET),NTO) + @cp $(JSMATH_PRELINK) $@ +else + $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) +endif +else +ifdef USE_MSVC + @echo Warning: to use $(LIBRARY) must also link against $(FDLIBM_LIBRARY) + @cp $(JSMATH_PRELINK) $@ +endif + $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) +endif + +$(JSMATH_PRELINK): jsmath.c +ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) + $(CC) -Fo$@ -c $(CFLAGS) $< +else + $(CC) -o $@ -c $(CFLAGS) $< +endif + # # Hardwire dependencies on jsopcode.tbl #