--- old/make/common/NativeCompilation.gmk 2015-02-06 11:57:50.972126701 +0100 +++ new/make/common/NativeCompilation.gmk 2015-02-06 11:57:50.860126699 +0100 @@ -53,6 +53,8 @@ UNIX_PATH_PREFIX := endif +# This pattern is used to transform the output of the microsoft CL compiler +# into a make syntax dependency file (.d) WINDOWS_SHOWINCLUDE_SED_PATTERN := \ -e '/^Note: including file:/!d' \ -e 's|Note: including file: *||' \ @@ -62,6 +64,16 @@ -e 's|$$$$| \\|g' \ # +# This pattern is used to transform a dependency file (.d) to a list +# of make targets for dependent files (.d.targets) +DEPENDENCY_TARGET_SED_PATTERN := \ + -e 's/\#.*//' \ + -e 's/^[^:]*: *//' \ + -e 's/ *\\$$$$//' \ + -e '/^$$$$/ d' \ + -e 's/$$$$/ :/' \ + # + define add_native_source # param 1 = BUILD_MYPACKAGE # parma 2 = the source file name (..../alfa.c or .../beta.cpp) @@ -105,8 +117,13 @@ ifeq (,$$(filter %.s,$2)) # And this is the dependency file for this obj file. $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) + # The dependency target file lists all dependencies as empty targets + # to avoid make error "No rule to make target" for removed files + $1_$2_DEP_TARGETS:=$$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ)) + # Include previously generated dependency information. (if it exists) -include $$($1_$2_DEP) + -include $$($1_$2_DEP_TARGETS) ifeq ($(TOOLCHAIN_TYPE), microsoft) $1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \ @@ -139,6 +156,11 @@ ($(ECHO) $$@: \\ \ && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) > $$($1_$2_DEP) endif + # Create a dependency target file from the dependency file. + # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ + ifneq ($$($1_$2_DEP),) + $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS) + endif endif endef @@ -428,7 +450,7 @@ $1_BUILD_INFO := $$($1_OBJECT_DIR)/_build-info.marker # Track variable changes for all variables that affect the compilation command - # lines for all object files in this setup. This includes at least all the + # lines for all object files in this setup. This includes at least all the # variables used in the call to add_native_source below. $1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS) \ $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) \ @@ -452,7 +474,10 @@ ifeq ($$(wildcard $$($1_TARGET)),) $(ECHO) 'Creating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)' else - $(ECHO) 'Updating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)' + $(ECHO) $$(strip 'Updating $$($1_BASENAME)' \ + $$(if $$(filter-out %.vardeps, $$?), \ + 'from $$(words $$(filter-out %.vardeps, $$?)) file(s)') \ + $$(if $$(filter %.vardeps, $$?), 'due to makefile changes')) endif $(TOUCH) $$@ @@ -461,7 +486,9 @@ ifneq (,$$($1_VERSIONINFO_RESOURCE)) $1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res $1_RES_DEP:=$$($1_RES).d + $1_RES_DEP_TARGETS:=$$($1_RES).d.targets -include $$($1_RES_DEP) + -include $$($1_RES_DEP_TARGETS) $1_RES_VARDEPS := $(RC) $$($1_RC_FLAGS) $1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \ @@ -475,6 +502,7 @@ $(CC_OUT_OPTION)$$($1_RES_DEP).obj $$($1_VERSIONINFO_RESOURCE) > $$($1_RES_DEP).raw 2>&1 || exit 0 ($(ECHO) $$($1_RES): \\ \ && $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).raw) > $$($1_RES_DEP) + $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS) endif ifneq (,$$($1_MANIFEST)) $1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest