#
# 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
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)
-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