From: Michal Sojka Date: Sat, 17 Jan 2009 22:07:02 +0000 (+0100) Subject: Pass definition simplified by not using -local target X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/commitdiff_plain/24a427e634a228cdae2eecf8e49032bb93374d41 Pass definition simplified by not using -local target Instead, pass targets are declared as double-colon rules meaning that there can be multiple definition of the pass target and all commands from these definitions are concatenated and executed together. The previous solution used dependencies as a way to specify multiple commands to be executed. This leaded to higher memory consumption and probably even to a problem with ordering of executed commands. Because processing of both SUBDIRS and -local commands was implemented as dependencies, in case of parallel make (-j) some commands in the current directory could be executed before the commands from subdirectories. (Note that this behavior was not observed. I only guess from manual that this could happen.) --- diff --git a/snippets/base b/snippets/base index ee31ce4..e80db84 100644 --- a/snippets/base +++ b/snippets/base @@ -55,7 +55,7 @@ build-pseudo-pass: prepare $(Q3)$(MAKE) -C $(MAKERULES_DIR) -f Makefile.rules build @$(QUIET_CMD_ECHO) "Compilation finished" -prepare-pass: $(omk_checks) +prepare-pass:: $(omk_checks) else # Run make in the top-level directory all: @@ -266,9 +266,8 @@ $(foreach subdir,$(EXTRA_RULES_SUBDIRS),$(eval $(call extra_rules_subdir_templat # Usage: $(call omk_pass_template,) define omk_pass_template -.PHONY: $(pass) $(pass)-local $(pass)-msg $(pass)-subdirs -$(pass): $(pass)-local -$(pass)-local: $(pass)-subdirs $(pass)-msg mkdir-omk-work +.PHONY: $(pass) $(pass)-msg $(pass)-subdirs +$(pass):: $(pass)-subdirs $(pass)-msg mkdir-omk-work $(foreach subdir,$(SUBDIRS),$$(eval $$(call omk_pass_subdir_template,$(pass),$(subdir)))) $(pass)-msg: $(pass)-subdirs @@ -294,7 +293,7 @@ default-config: $(eval $(call omk_pass_template,default-config-pass,$$(LOCAL_BUILD_DIR),,always)) -default-config-pass-local: +default-config-pass:: # $(Q3)echo Default config for $(RELATIVE_DIR) $(Q3)echo "# Config for $(RELATIVE_DIR)" >> "$(CONFIG_FILE)-default" $(Q3)$(foreach x, $(default_CONFIG), echo '$(x)' | \ diff --git a/snippets/config_h b/snippets/config_h index 98f717f..c78737e 100644 --- a/snippets/config_h +++ b/snippets/config_h @@ -53,7 +53,7 @@ _$(basename $(notdir $(confh)))_H \ config_h_stamp_files = $(addprefix $(USER_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H)))) # Add some hooks to standard passes -include-pass-local: $(config_h_stamp_files) +include-pass-local: $(config_h_stamp_files) # TODO remove -local ifneq ($(KERN_CONFIG_HEADERS_REQUIRED),) @@ -68,11 +68,11 @@ _$(basename $(notdir $(confh)))_H \ kern_config_h_stamp_files = $(addprefix $(KERN_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H)))) # Add some hooks to standard passes -include-pass-local: $(kern_config_h_stamp_files) +include-pass-local: $(kern_config_h_stamp_files) # TODO remove -local endif -clean-local: clean-local-config-h +clean-local: clean-local-config-h # TODO remove -local clean-local-config-h: @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\ diff --git a/snippets/cprog b/snippets/cprog index dfc1be0..8433ac5 100644 --- a/snippets/cprog +++ b/snippets/cprog @@ -62,10 +62,8 @@ $$(eval $$(call prepare_rule_goal,\ $$(call solib_cmd,$(1)))) endef -prepare-pass: create-build-dirs -create-build-dirs:: ifneq ($(bin_PROGRAMS)$(test_PROGRAMS)$(utils_PROGRAMS)$(lib_LIBRARIES)$(shared_LIBRARIES),) -create-build-dirs:: +prepare-pass:: @$(call mkdir_def,$(USER_OBJS_DIR)) endif diff --git a/snippets/prepare b/snippets/prepare index e4905e2..c8285d6 100644 --- a/snippets/prepare +++ b/snippets/prepare @@ -28,18 +28,15 @@ subst-cmd = $(subst $$,$$$$,$(call escsq,$(subst \,\\,$(1)))) # 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) - -.PHONY: $(omk_inc_file) -$(omk_inc_file): +prepare-pass:: #TODO remove echos from the next commands @set -e;\ - 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; echo " CHK "$$(call strip_out,$$@); else mv $$@.tmp $$@; echo " UPD "$$(call strip_out,$$@); fi + 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 ### @@ -51,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 - @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