]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Pass definition simplified by not using -local target
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 17 Jan 2009 22:07:02 +0000 (23:07 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 17 Jan 2009 22:07:02 +0000 (23:07 +0100)
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.)

snippets/base
snippets/config_h
snippets/cprog
snippets/prepare

index ee31ce4ee5506d4318111fd2b314100e825b7ec8..e80db848773f4d9f8465b393c4be1e690467e7ad 100644 (file)
@@ -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,<pass name>)
 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)' | \
index 98f717f452eac50e0132c229f0b3caccf6c4ef49..c78737e1c144d323a86ed83e94fa764a19cc0556 100644 (file)
@@ -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),\
index dfc1be0d93c749da3ba06c5ff2ab4754d8d2c718..8433ac5d4be01ecd42c1c4993f1208db000902d8 100644 (file)
@@ -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
 
index e4905e24c7b692c3b7283bdeb03eb656ca7dc981..c8285d6bf3f7770edbdb190824e04cd6ce1eacd5 100644 (file)
@@ -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,<targets>,<deps>,<msg>,<cmd>))
 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