]> rtime.felk.cvut.cz Git - omk.git/blobdiff - snippets/prepare
Formating changes, added Emacs modelines
[omk.git] / snippets / prepare
index ed7fdedbfd5e7066cddde7826e570fb2cb292529..c978cbd0c9ab3e4ee92fbed6447e0eb35edf747b 100644 (file)
@@ -1,9 +1,9 @@
 
-################
+################ -*- makefile-gmake -*-
 # Prepare pass #
 ################
 
-$(eval $(call omk_pass_template,prepare-pass,$(USER_OBJS_DIR),,always))
+$(eval $(call omk_pass_template,prepare-pass))
 
 ###
 # Name of the prepared rule.  This name is used as prefix of variable
@@ -18,26 +18,25 @@ omk_inc_file = $(if $(filter $(BUILD_DIR_NAME)%,$(omk_inc_rule)),\
 
 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.
 # All paths in this file should be relative to $(OUTPUT_DIR)
 # Usage: $(eval $(call prepare_rule,<targets>,<deps>,<msg>,<cmd>))
 define prepare_rule
-prepare-pass-local: $(omk_inc_file)
-
-$(omk_inc_file): FORCE
-#TODO remove the next line
-       @echo "  PREP    "$$(call strip_out,$$@); \
-           echo 'prepared_rules += $(omk_inc_rule)' > $$@.tmp; \
-           echo '$(omk_inc_rule)_targets = $$(call strip_out,$(1))' >> $$@.tmp; \
-           echo '$(omk_inc_rule)_deps += $$(call strip_out,$(2))' >> $$@.tmp; \
-           echo '$(omk_inc_rule)_msg = $(3)' >> $$@.tmp; \
-           echo '$(omk_inc_rule)_cmd = $(call subst-cmd,$(4))' >> $$@.tmp; \
-       if cmp -s $$@.tmp $$@; then rm $$@.tmp; else mv $$@.tmp $$@; fi
+prepare-pass::
+#TODO remove echos from the next commands
+       @set -e;\
+           echo 'prepared_rules += $(omk_inc_rule)' > $(omk_inc_file).tmp; \
+           echo '$(omk_inc_rule)_targets = $$(call strip_out,$(1))' >> $(omk_inc_file).tmp; \
+           echo '$(omk_inc_rule)_deps += $$(call strip_out,$(2))' >> $(omk_inc_file).tmp; \
+           echo '$(omk_inc_rule)_msg = $(3)' >> $(omk_inc_file).tmp; \
+           echo '$(omk_inc_rule)_cmd = $(call subst-cmd,$(4))' >> $(omk_inc_file).tmp; \
+       if cmp -s $(omk_inc_file).tmp $(omk_inc_file); then rm $(omk_inc_file).tmp; echo "  CHK     "$$(call strip_out,$(omk_inc_file)); else mv $(omk_inc_file).tmp $(omk_inc_file); echo "  UPD     "$$(call strip_out,$(omk_inc_file)); fi
 endef
 
 ###
@@ -49,9 +48,12 @@ $(call prepare_rule,$(1),$(2),$(3),$(4))
 prepared_goals += $(call strip_out,$(1))
 endef
 
-prepare-pass-local: $(OMK_WORK_DIR)/__goals.omk.inc
-$(OMK_WORK_DIR)/__goals.omk.inc: FORCE
-       $(Q)echo 'omk_goals += $(prepared_goals)' > $@.tmp; \
-           if cmp -s $@.tmp $@; then rm $@.tmp; else mv $@.tmp $@; fi
+_goals := $(OMK_WORK_DIR)/__goals.omk.inc
+
+prepare-pass::
+       @echo 'omk_goals += $(prepared_goals)' > $(_goals).tmp; \
+           if cmp -s $(_goals).tmp $(_goals); \
+               then rm $(_goals).tmp; \
+               else mv $(_goals).tmp $(_goals); fi