2007-10-05 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / build / executable.make
index 726ac000f863871c3c92c8304a55a40fad2c4002..3f280abcd3383dcd6a42545e75ea3ade5f454441 100644 (file)
@@ -2,7 +2,8 @@
 #
 # 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
@@ -80,7 +81,13 @@ 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)
@@ -108,4 +115,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