* COMException.cs: Added missing colon in ToString.
[mono.git] / mcs / build / executable.make
index 7ad29cd9eebda5838f16d420922f0e9b929ce3a4..f3113385a5ccf9c7cd8eeb44b56a3e17ce7246c2 100644 (file)
@@ -2,9 +2,13 @@
 #
 # The rules for building a program.
 
-base_prog = $(shell basename $(PROGRAM))
+base_prog = $(notdir $(PROGRAM))
+prog_dir := $(filter-out . ./, $(dir $(PROGRAM)))
 sourcefile = $(base_prog).sources
+base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
+ifndef base_prog_config
 base_prog_config := $(wildcard $(base_prog).config)
+endif
 ifdef base_prog_config
 PROGRAM_config := $(PROGRAM).config
 endif
@@ -18,6 +22,12 @@ response = $(depsdir)/$(base_prog).response
 executable_CLEAN_FILES += $(response)
 endif
 
+ifdef KEEP_OUTPUT_FILE_COPY
+       COPY_CMD = cp
+else
+       COPY_CMD = mv
+endif
+
 makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
 pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
 mdb = $(patsubst %.exe,%.mdb,$(PROGRAM))
@@ -77,11 +87,17 @@ ifndef PROGRAM_COMPILE
 PROGRAM_COMPILE = $(CSCOMPILE)
 endif
 
-$(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response)
+ifdef prog_dir
+$(prog_dir)/.stamp:
+       $(MKINSTALLDIRS) $(@D)
+       touch $@
+endif
+
+$(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(prog_dir:=/.stamp)
        $(PROGRAM_COMPILE) -target:exe -out:$(base_prog) $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
 ifneq ($(base_prog),$(PROGRAM))
-       mv $(base_prog) $(PROGRAM)
-       test ! -f $(base_prog).mdb || mv $(base_prog).mdb $(PROGRAM).mdb
+       $(COPY_CMD) $(base_prog) $(PROGRAM)
+       test ! -f $(base_prog).mdb || $(COPY_CMD) $(base_prog).mdb $(PROGRAM).mdb
 endif
 
 ifdef PROGRAM_config
@@ -105,4 +121,8 @@ endif
 -include $(makefrag)
 
 all-local: $(makefrag)
-$(makefrag): $(topdir)/build/executable.make
+
+ifneq ($(response),$(sourcefile))
+$(response): $(topdir)/build/executable.make $(depsdir)/.stamp
+endif
+$(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp