bug 447807 - allow to override the object dir when building js shell. r=crowder
authorIgor Bukanov <igor@mir2.org>
Thu, 24 Jul 2008 22:08:18 +0200
changeset 16184 e07bd297331ca3f5629cedcc9ab4f3f887f0e9f7
parent 16183 89773fe8713c875cf733a8f3d5e591aec29a25a4
child 16186 afcd085d73168a51208906704e0a145724388977
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscrowder
bugs447807
milestone1.9.1a2pre
bug 447807 - allow to override the object dir when building js shell. r=crowder
js/src/Makefile.ref
js/src/config.mk
js/src/editline/Makefile.ref
js/src/rules.mk
--- a/js/src/Makefile.ref
+++ b/js/src/Makefile.ref
@@ -128,17 +128,17 @@ ifdef JS_READLINE
 # For those platforms with the readline library installed.
 DEFINES += -DEDITLINE
 PROG_LIBS += -lreadline -ltermcap
 else
 ifdef JS_EDITLINE
 # Use the editline library, built locally.
 PREDIRS += editline
 DEFINES += -DEDITLINE
-PROG_LIBS += editline/$(OBJDIR)/libedit.a
+PROG_LIBS += $(OBJDIR)/editline/libedit.a
 endif
 endif
 
 # For purify
 PURE_CFLAGS     = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \
                   $(INCLUDES) $(XCFLAGS)
 
 #
@@ -298,16 +298,17 @@ GARBAGE	+= $(AUTO_HEADERS:$(OBJDIR)/jsau
 
 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
 	@$(MAKE_OBJDIR)
 	$(CXX) -Fo$(OBJDIR)/ -c $(CFLAGS) $<
 	link.exe -out:"$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX)" $(EXE_LINK_FLAGS) $(OBJDIR)/js$*gen.obj
 	$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
 else
 
+GARBAGE	+= $(AUTO_HEADERS:$(OBJDIR)/jsauto%.h=$(OBJDIR)/js%gen.d)
 $(AUTO_HEADERS): $(OBJDIR)/jsauto%.h: js%gen.cpp
 	@$(MAKE_OBJDIR)
 	$(CXX) -o $(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $(CFLAGS) $(LDFLAGS) $<
 	$(OBJDIR)/js$*gen$(HOST_BIN_SUFFIX) $@
 
 endif
 
 # force creation of autoheaders before compiling any source that may use them
@@ -336,19 +337,18 @@ ifndef PREBUILT_CPUCFG
 
 $(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
 	rm -f $@
 	$(OBJDIR)/jscpucfg > $@
 
 $(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
 	$(CXX) $(OS_LDFLAGS) -o $@ $(OBJDIR)/jscpucfg.o
 
-# Add to TARGETS for clobber rule
-TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \
-	$(OBJDIR)/jscpucfg.o
+GARBAGE += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \
+	   $(OBJDIR)/jscpucfg.o $(OBJDIR)/jscpucfg.d
 endif
 
 # Automatic make dependencies files
 DEPENDENCIES    = $(CPPFILES:%.cpp=$(OBJDIR)/%.d)
 
 #
 # Hardwire dependencies for jsinvoke.c
 #
--- a/js/src/config.mk
+++ b/js/src/config.mk
@@ -174,22 +174,28 @@ ifndef HOST_BIN_SUFFIX
 ifeq ($(OS_ARCH),WINNT)
 HOST_BIN_SUFFIX = .exe
 else
 HOST_BIN_SUFFIX =
 endif
 endif
 
 # Name of the binary code directories
-ifdef BUILD_IDG
-OBJDIR          = $(OS_CONFIG)$(OBJDIR_TAG).OBJD
+ifdef OBJROOT
+# prepend $(DEPTH) to the root unless it is an absolute path
+OBJDIR = $(if $(filter /%,$(OBJROOT)),$(OBJROOT),$(DEPTH)/$(OBJROOT))
 else
-OBJDIR          = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
+ifdef BUILD_IDG
+OBJDIR = $(DEPTH)/$(OS_CONFIG)$(OBJDIR_TAG).OBJD
+else
+OBJDIR = $(DEPTH)/$(OS_CONFIG)$(OBJDIR_TAG).OBJ
 endif
-VPATH           = $(OBJDIR)
+endif
+
+VPATH = $(OBJDIR)
 
 LCJAR = js15lc30.jar
 
 # Library name
 LIBDIR := lib
 ifeq ($(CPU_ARCH), x86_64)
 LIBDIR := lib64
 endif
--- a/js/src/editline/Makefile.ref
+++ b/js/src/editline/Makefile.ref
@@ -82,59 +82,62 @@
 
 DEFS	= -DANSI_ARROWS -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT -DSYS_UNIX \
 	-DHAVE_STDLIB -DUNIQUE_HISTORY
 
 DEPTH           = ..
 
 include $(DEPTH)/config.mk
 
+LOCAL_OBJDIR = $(OBJDIR)/editline
+
 #
 # Default IEEE libm
 #
 CFLAGS          += -DXP_UNIX $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
 		  -DJSFILE $(XCFLAGS) $(DEFS)
 
 INCFILES = editline.h
 .INIT: $(INCFILES)
 .KEEP_STATE:
 EDITLINE_CFILES = editline.c sysunix.c
 
-EDITLINE_OBJS = $(addprefix $(OBJDIR)/, $(EDITLINE_CFILES:.c=.o))
+EDITLINE_OBJS = $(addprefix $(LOCAL_OBJDIR)/, $(EDITLINE_CFILES:.c=.o))
 
-LIBRARY = $(OBJDIR)/libedit.a
+LIBRARY = $(LOCAL_OBJDIR)/libedit.a
 
 all: $(LIBRARY) 
 
 export:
 
-$(EDITLINE_OBJS) : $(OBJDIR)
+# make objects to depen on $(LOCAL_OBJDIR) only when it exists
+$(EDITLINE_OBJS) : $(filter-out $(wildcard $(LOCAL_OBJDIR)), $(LOCAL_OBJDIR))
 
-$(OBJDIR) :
+$(LOCAL_OBJDIR) :
 	mkdir -p $@
 
-$(OBJDIR)/%: %.c
+$(LOCAL_OBJDIR)/%: %.c
 	$(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
 
-$(OBJDIR)/%.o: %.c
+$(LOCAL_OBJDIR)/%.o: %.c
 	$(CC) -o $@ -c $(CFLAGS) $*.c
 
-$(OBJDIR)/%.o: %.s
+$(LOCAL_OBJDIR)/%.o: %.s
 	$(AS) -o $@ $(ASFLAGS) $*.s
 
 $(LIBRARY): $(EDITLINE_OBJS)
 	$(AR) rv $@ $?
 	$(RANLIB) $@
 
 #libedit.a : $(EDITLINE_OBJS) 
-#	$(AR) cru $(OBJDIR)/libedit.a $(EDITLINE_OBJS)
-#	$(RANLIB) $(OBJDIR)/libedit.a
+#	$(AR) cru $(LOCAL_OBJDIR)/libedit.a $(EDITLINE_OBJS)
+#	$(RANLIB) $(LOCAL_OBJDIR)/libedit.a
 
 clean:
 	rm -rf $(EDITLINE_OBJS) $(EDITLINE_OBJS:.o=.d)
 
 clobber: clean
 	rm -rf $(LIBRARY) $(DEPENDENCIES)
-	rmdir $(OBJDIR)
+	if test -d $(LOCAL_OBJDIR); then rmdir $(LOCAL_OBJDIR); fi
 
 SUFFIXES: .i
 %.i: %.c
 	$(CC) -C -E $(CFLAGS) $< > $*.i
--- a/js/src/rules.mk
+++ b/js/src/rules.mk
@@ -179,17 +179,20 @@ ifneq "$(strip $(SHARED_LIBRARY))" ""
 	$(CP) $(SHARED_LIBRARY) $(DIST)/$(LIBDIR)
 endif
 ifneq "$(strip $(PROGRAM))" ""
 	$(CP) $(PROGRAM) $(DIST)/bin
 endif
 	+$(LOOP_OVER_DIRS)
 
 clean:
+	+$(LOOP_OVER_PREDIRS)
 	rm -rf $(OBJS) $(GARBAGE)
 
 clobber:
-	rm -rf $(OBJS) $(TARGETS) $(DEPENDENCIES)
+	+$(LOOP_OVER_PREDIRS)
+	rm -rf $(OBJS) $(TARGETS) $(DEPENDENCIES) $(GARBAGE)
+	if test -d $(OBJDIR); then rmdir $(OBJDIR); fi
 
 tar:
 	tar cvf $(TARNAME) $(TARFILES)
 	gzip $(TARNAME)