$$(call program_cmd,$(1))))
endef
-program_cmd = $(if $(filter %.cc,$($(1)_SOURCES)),$(CXX),$(CC)) \
+program_cmd = set -e; $(if $(filter %.cc,$($(1)_SOURCES)),$(CXX),$(CC)) \
$($(1)_OBJS) $($(1)_LIBS:%=-l%) $(LOADLIBES) $(LDFLAGS) -Wl,-rpath-link,$(USER_LIB_DIR) \
- -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@
+ -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@; \
+ echo "$$@: \\" >$(USER_OBJS_DIR)/$(1).exe.d; \
+ sed -n -e 's|^LOAD \(.*\)$$$$| \1 \&|p' $(USER_OBJS_DIR)/$(1).exe.map|tr '&' '\134' >>$(USER_OBJS_DIR)/$(1).exe.d; \
+ echo >>$(USER_OBJS_DIR)/$(1).exe.d
+
$(foreach prog,$(bin_PROGRAMS),$(eval $(call program_template,$(prog),bin)))
#$(foreach prog,$(bin_PROGRAMS),$(info >>>$(call program_template,$(prog),bin)<<<))
target_omk_file = $(OMK_WORK_DIR)/$(notdir $(1)).target.omk
+# >\< substitution to preserve \ in echo argument
# >'< substitution is for echo to work,
# >$< substitution to preserve $ when reloading .omk.inc file
-subst-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(1))))
+subst-cmd = $(subst $$,$$$$,$(call escsq,$(subst \,\\,$(1))))
###
# prepare_rule is used to generate .omk.inc files during prepare-pass.