################ # Prepare pass # ################ $(eval $(call omk_pass_template,prepare-pass)) ### # Name of the prepared rule. This name is used as prefix of variable # names in .omk.inc and is based on the first target omk_inc_rule = $(firstword $(1:$(OUTPUT_DIR)/%=%)) # The name of .omk.inc file is derived from $(omk_inc_rule) and # depends whether the target is under _build or elsewhere. omk_inc_file = $(if $(filter $(BUILD_DIR_NAME)%,$(omk_inc_rule)),\ $(OMK_WORK_DIR)/$(notdir $(omk_inc_rule)).omk.inc,\ $(OMK_WORK_DIR)/$(subst /,_,$(omk_inc_rule)).omk.inc) target_omk_file = $(OMK_WORK_DIR)/$(notdir $(1)).target.omk # >'< substitution is for echo to work, # >$< substitution to preserve $ when reloading .omk.inc file subst-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(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,,,,)) 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 endef ### # prepare_rule_goal - same as prepare rules but the target is put # as dependency to the default goal, which causes it to be built # upon calling make define prepare_rule_goal $(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